• Michael Tretter's avatar
    media: v4l2-mem2mem: reorder checks in v4l2_m2m_poll() · 7708065f
    Michael Tretter authored
    When reaching the end of stream, V4L2 m2m clients may expect the
    V4L2_EOS_EVENT. Although the V4L2_EOS_EVENT is deprecated behavior,
    drivers must signal that event before dequeuing the buffer that has the
    V4L2_BUF_FLAG_LAST flag set.
    
    If a driver queues the V4L2_EOS_EVENT event and returns the buffer after
    the check for events but before the check for buffers, vb2_m2m_poll()
    will signal that the buffer with V4L2_BUF_FLAG_LAST can be read but not
    that the V4L2_EOS_EVENT is available.
    
    Split the check for buffers into a separate function and check for
    available buffers before checking for events. This ensures that if
    vb2_m2m_poll() signals POLLIN | POLLRDNORM for the V4L2_BUF_FLAG_LAST
    buffer, it signals POLLPRI for the V4L2_EOS_EVENT, too.
    Signed-off-by: default avatarMichael Tretter <m.tretter@pengutronix.de>
    Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
    [hverkuil-cisco@xs4all.nl: fix checkpatch alignment warning]
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
    7708065f
v4l2-mem2mem.c 32 KB