[1/4] v4l2: v4l2_camera_proxy: Clear PREPARED flag when queuing buffer
diff mbox series

Message ID 20261027212447.2551591-2-laurent.pinchart@ideasonboard.com
State New
Headers show
Series
  • v4l2: Fix v4l2-compliance errors
Related show

Commit Message

Laurent Pinchart Oct. 27, 2026, 9:24 p.m. UTC
When a buffer is queued with VIDIOC_QBUF, the V4L2 API clears the
V4L2_BUF_FLAG_PREPARED flag and set V4L2_BUF_FLAG_QUEUED. The
v4l2-compat layer instead sets boths flags, which is reported as an
error by v4l2-compliance:

Streaming ioctls:
        test read/write: OK (Not Supported)
                fail: v4l2-test-buffers.cpp(381): buf_states > 1
                fail: v4l2-test-buffers.cpp(1548): buf.check(q, Queued, i)
                fail: v4l2-test-buffers.cpp(1708): setupMmap(node, q)
        test MMAP (no poll, REQBUFS): FAIL

Fix it by clearing the V4L2_BUF_FLAG_PREPARED flag. There is then no
need to clear the flag in vidioc_dqbuf() any more.

Fixes: 7278a59eba64 ("v4l2: v4l2_camera_proxy: Dispatch VIDIOC_PREPARE_BUF")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/v4l2/v4l2_camera_proxy.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jacopo Mondi Oct. 28, 2026, 7:31 a.m. UTC | #1
Hi Laurent

On Tue, Oct 27, 2026 at 11:24:44PM +0200, Laurent Pinchart wrote:
> When a buffer is queued with VIDIOC_QBUF, the V4L2 API clears the
> V4L2_BUF_FLAG_PREPARED flag and set V4L2_BUF_FLAG_QUEUED. The
> v4l2-compat layer instead sets boths flags, which is reported as an
> error by v4l2-compliance:
>
> Streaming ioctls:
>         test read/write: OK (Not Supported)
>                 fail: v4l2-test-buffers.cpp(381): buf_states > 1
>                 fail: v4l2-test-buffers.cpp(1548): buf.check(q, Queued, i)
>                 fail: v4l2-test-buffers.cpp(1708): setupMmap(node, q)
>         test MMAP (no poll, REQBUFS): FAIL
>
> Fix it by clearing the V4L2_BUF_FLAG_PREPARED flag. There is then no
> need to clear the flag in vidioc_dqbuf() any more.
>
> Fixes: 7278a59eba64 ("v4l2: v4l2_camera_proxy: Dispatch VIDIOC_PREPARE_BUF")
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 210c8e875528..ca1115d017ac 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -649,8 +649,8 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
>  	if (ret < 0)
>  		return ret;
>
> -	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED |
> -				      V4L2_BUF_FLAG_PREPARED;
> +	buffers_[arg->index].flags &= ~V4L2_BUF_FLAG_PREPARED;
> +	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
>
>  	arg->flags = buffers_[arg->index].flags;
>
> @@ -694,7 +694,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,
>
>  	struct v4l2_buffer &buf = buffers_[currentBuf_];
>
> -	buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_PREPARED);
> +	buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
>  	buf.length = sizeimage_;
>  	*arg = buf;
>
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 210c8e875528..ca1115d017ac 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -649,8 +649,8 @@  int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
 	if (ret < 0)
 		return ret;
 
-	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED |
-				      V4L2_BUF_FLAG_PREPARED;
+	buffers_[arg->index].flags &= ~V4L2_BUF_FLAG_PREPARED;
+	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
 
 	arg->flags = buffers_[arg->index].flags;
 
@@ -694,7 +694,7 @@  int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,
 
 	struct v4l2_buffer &buf = buffers_[currentBuf_];
 
-	buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_PREPARED);
+	buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
 	buf.length = sizeimage_;
 	*arg = buf;