]> asedeno.scripts.mit.edu Git - linux.git/commit
media: v4l2-mem2mem: reorder checks in v4l2_m2m_poll()
authorMichael Tretter <m.tretter@pengutronix.de>
Thu, 27 Jun 2019 12:44:33 +0000 (08:44 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 23 Jul 2019 12:46:12 +0000 (08:46 -0400)
commit7708065f5d51a9ae80df29d1257d91fc6a6e50a0
tree060191cd2bf07819f102709bdc589771aec773d4
parent8d86a15649957c182e90fa2b1267c16699bc12f1
media: v4l2-mem2mem: reorder checks in v4l2_m2m_poll()

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: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: fix checkpatch alignment warning]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/v4l2-core/v4l2-mem2mem.c