[v3] v4l2: v4l2_camera_proxy: Dispatch VIDIOC_PREPARE_BUF
diff mbox series

Message ID 20261021001303.173938-1-ragaprasanth@gmail.com
State Superseded
Headers show
Series
  • [v3] v4l2: v4l2_camera_proxy: Dispatch VIDIOC_PREPARE_BUF
Related show

Commit Message

Prasanth Ramesh Oct. 21, 2026, 12:13 a.m. UTC
Commit b5225f00cde0 added VIDIOC_PREPARE_BUF to the supported ioctls,
but did not add it to the switch case. Add the missing case.

Also set V4L2_BUF_FLAG_PREPARED in QBUF and clear it in STREAMOFF, as
videobuf2 does, so a buffer can be prepared again after STREAMOFF.

Fixes: b5225f00cde0 ("v4l2: V4L2CameraProxy: Add support for PREPARE_BUF as one of the supported ioctl")
Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
---
Tested on a Raspberry Pi 4 with a UVC webcam - preparing a buffer again
after STREAMOFF failed with EINVAL in v1 and works in v3.

 src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Oct. 21, 2026, 9 a.m. UTC | #1
Quoting Prasanth R (2026-10-21 01:13:03)
> Commit b5225f00cde0 added VIDIOC_PREPARE_BUF to the supported ioctls,
> but did not add it to the switch case. Add the missing case.
> 
> Also set V4L2_BUF_FLAG_PREPARED in QBUF and clear it in STREAMOFF, as
> videobuf2 does, so a buffer can be prepared again after STREAMOFF.
> 
> Fixes: b5225f00cde0 ("v4l2: V4L2CameraProxy: Add support for PREPARE_BUF as one of the supported ioctl")
> Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>

Same issue here, please supply a matching SoB.

With that:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
> Tested on a Raspberry Pi 4 with a UVC webcam - preparing a buffer again
> after STREAMOFF failed with EINVAL in v1 and works in v3.
> 
>  src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 7f8522d5e..d1f3ac7df 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -708,7 +708,8 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
>         if (ret < 0)
>                 return ret;
>  
> -       buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
> +       buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED |
> +                                     V4L2_BUF_FLAG_PREPARED;
>  
>         arg->flags = buffers_[arg->index].flags;
>  
> @@ -835,7 +836,8 @@ int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile *file, int *arg)
>         int ret = vcam_->streamOff();
>  
>         for (struct v4l2_buffer &buf : buffers_)
> -               buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
> +               buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE |
> +                              V4L2_BUF_FLAG_PREPARED);
>  
>         return ret;
>  }
> @@ -997,6 +999,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long longRequest, void
>         case VIDIOC_QUERYBUF:
>                 ret = vidioc_querybuf(file, static_cast<struct v4l2_buffer *>(arg));
>                 break;
> +       case VIDIOC_PREPARE_BUF:
> +               ret = vidioc_prepare_buf(file, static_cast<struct v4l2_buffer *>(arg));
> +               break;
>         case VIDIOC_QBUF:
>                 ret = vidioc_qbuf(file, static_cast<struct v4l2_buffer *>(arg));
>                 break;
> -- 
> 2.34.1
>
Prasanth Ramesh Oct. 21, 2026, 9:07 a.m. UTC | #2
Hi Kieran,

Apologize! sent modified for both

Thanks,
Prasanth R


On Wed, Oct 21, 2026 at 6:00 PM Kieran Bingham <
kieran.bingham@ideasonboard.com> wrote:

> Quoting Prasanth R (2026-10-21 01:13:03)
> > Commit b5225f00cde0 added VIDIOC_PREPARE_BUF to the supported ioctls,
> > but did not add it to the switch case. Add the missing case.
> >
> > Also set V4L2_BUF_FLAG_PREPARED in QBUF and clear it in STREAMOFF, as
> > videobuf2 does, so a buffer can be prepared again after STREAMOFF.
> >
> > Fixes: b5225f00cde0 ("v4l2: V4L2CameraProxy: Add support for PREPARE_BUF
> as one of the supported ioctl")
> > Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
>
> Same issue here, please supply a matching SoB.
>
> With that:
>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
> > ---
> > Tested on a Raspberry Pi 4 with a UVC webcam - preparing a buffer again
> > after STREAMOFF failed with EINVAL in v1 and works in v3.
> >
> >  src/v4l2/v4l2_camera_proxy.cpp | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp
> b/src/v4l2/v4l2_camera_proxy.cpp
> > index 7f8522d5e..d1f3ac7df 100644
> > --- a/src/v4l2/v4l2_camera_proxy.cpp
> > +++ b/src/v4l2/v4l2_camera_proxy.cpp
> > @@ -708,7 +708,8 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile
> *file, struct v4l2_buffer *arg)
> >         if (ret < 0)
> >                 return ret;
> >
> > -       buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
> > +       buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED |
> > +                                     V4L2_BUF_FLAG_PREPARED;
> >
> >         arg->flags = buffers_[arg->index].flags;
> >
> > @@ -835,7 +836,8 @@ int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile
> *file, int *arg)
> >         int ret = vcam_->streamOff();
> >
> >         for (struct v4l2_buffer &buf : buffers_)
> > -               buf.flags &= ~(V4L2_BUF_FLAG_QUEUED |
> V4L2_BUF_FLAG_DONE);
> > +               buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE
> |
> > +                              V4L2_BUF_FLAG_PREPARED);
> >
> >         return ret;
> >  }
> > @@ -997,6 +999,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file,
> unsigned long longRequest, void
> >         case VIDIOC_QUERYBUF:
> >                 ret = vidioc_querybuf(file, static_cast<struct
> v4l2_buffer *>(arg));
> >                 break;
> > +       case VIDIOC_PREPARE_BUF:
> > +               ret = vidioc_prepare_buf(file, static_cast<struct
> v4l2_buffer *>(arg));
> > +               break;
> >         case VIDIOC_QBUF:
> >                 ret = vidioc_qbuf(file, static_cast<struct v4l2_buffer
> *>(arg));
> >                 break;
> > --
> > 2.34.1
> >
>

Patch
diff mbox series

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 7f8522d5e..d1f3ac7df 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -708,7 +708,8 @@  int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)
 	if (ret < 0)
 		return ret;
 
-	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;
+	buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED |
+				      V4L2_BUF_FLAG_PREPARED;
 
 	arg->flags = buffers_[arg->index].flags;
 
@@ -835,7 +836,8 @@  int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile *file, int *arg)
 	int ret = vcam_->streamOff();
 
 	for (struct v4l2_buffer &buf : buffers_)
-		buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);
+		buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE |
+			       V4L2_BUF_FLAG_PREPARED);
 
 	return ret;
 }
@@ -997,6 +999,9 @@  int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long longRequest, void
 	case VIDIOC_QUERYBUF:
 		ret = vidioc_querybuf(file, static_cast<struct v4l2_buffer *>(arg));
 		break;
+	case VIDIOC_PREPARE_BUF:
+		ret = vidioc_prepare_buf(file, static_cast<struct v4l2_buffer *>(arg));
+		break;
 	case VIDIOC_QBUF:
 		ret = vidioc_qbuf(file, static_cast<struct v4l2_buffer *>(arg));
 		break;