diff mbox

[media] vb2: clear V4L2_BUF_FLAG_LAST when filling vb2_buffer

Message ID 20171208140128.19740-1-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Philipp Zabel Dec. 8, 2017, 2:01 p.m. UTC
V4L2_BUF_FLAG_LAST is a signal from the driver to userspace for buffers
on the capture queue. When userspace queues back a capture buffer with
the flag set, we should clear it.

Otherwise, if userspace restarts streaming after EOS, without
reallocating the buffers, mem2mem devices will erroneously signal EOS
prematurely, as soon as the already flagged buffer is dequeued.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/v4l2-core/videobuf2-v4l2.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Sakari Ailus Dec. 14, 2017, 1:49 p.m. UTC | #1
Hi Philipp,

On Fri, Dec 08, 2017 at 03:01:28PM +0100, Philipp Zabel wrote:
> V4L2_BUF_FLAG_LAST is a signal from the driver to userspace for buffers
> on the capture queue. When userspace queues back a capture buffer with
> the flag set, we should clear it.
> 
> Otherwise, if userspace restarts streaming after EOS, without
> reallocating the buffers, mem2mem devices will erroneously signal EOS
> prematurely, as soon as the already flagged buffer is dequeued.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/media/v4l2-core/videobuf2-v4l2.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
> index 4075314a69893..fac3cd6f901d5 100644
> --- a/drivers/media/v4l2-core/videobuf2-v4l2.c
> +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
> @@ -434,6 +434,8 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb,
>  	} else {
>  		/* Zero any output buffer flags as this is a capture buffer */
>  		vbuf->flags &= ~V4L2_BUFFER_OUT_FLAGS;
> +		/* Zero last flag, this is a signal from driver to userspace */
> +		vbuf->flags &= ~V4L2_BUF_FLAG_LAST;

Thanks for the patch.

How about:

	vbuf->flags &= ~(V4L2_BUFFER_OUT_FLAGS | V4L2_BUF_FLAG_LAST);
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c
index 4075314a69893..fac3cd6f901d5 100644
--- a/drivers/media/v4l2-core/videobuf2-v4l2.c
+++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
@@ -434,6 +434,8 @@  static int __fill_vb2_buffer(struct vb2_buffer *vb,
 	} else {
 		/* Zero any output buffer flags as this is a capture buffer */
 		vbuf->flags &= ~V4L2_BUFFER_OUT_FLAGS;
+		/* Zero last flag, this is a signal from driver to userspace */
+		vbuf->flags &= ~V4L2_BUF_FLAG_LAST;
 	}
 
 	return 0;