<div dir="auto">Hi Laurent,<div dir="auto">Thanks for the v4l2-ctl patch. I'll test it soon and reply in this thread.</div><div dir="auto"><br></div><div dir="auto">Regards,</div><div dir="auto">Vedant Paranjape</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 30 Dec, 2021, 04:06 Laurent Pinchart, <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Vedant,<br>
<br>
Thank you for the patch.<br>
<br>
On Wed, Dec 29, 2021 at 12:20:14AM +0530, Vedant Paranjape wrote:<br>
> To support DMABUF as one of the memory buffer, we need to implement<br>
> EXPBUF in the v4l2 compat layer.<br>
> <br>
> This patch implements vidioc_expbuf as one of the supported ioctls.<br>
> <br>
> Bug: <a href="https://bugs.libcamera.org/show_bug.cgi?id=89" rel="noreferrer noreferrer" target="_blank">https://bugs.libcamera.org/show_bug.cgi?id=89</a><br>
> <br>
> Signed-off-by: Vedant Paranjape <<a href="mailto:vedantparanjape160201@gmail.com" target="_blank" rel="noreferrer">vedantparanjape160201@gmail.com</a>><br>
<br>
This looks fine. As soon as you can test it with v4l2-ctl and capture<br>
images, I think it can be merged.<br>
<br>
I've sent a patch for v4l2-ctl (which has been merged in the master<br>
branch already) that should help with testing.<br>
<br>
> ---<br>
> src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++<br>
> src/v4l2/v4l2_camera_proxy.h | 1 +<br>
> 2 files changed, 31 insertions(+)<br>
> <br>
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp<br>
> index c1375777c185..4d529bc29a4d 100644<br>
> --- a/src/v4l2/v4l2_camera_proxy.cpp<br>
> +++ b/src/v4l2/v4l2_camera_proxy.cpp<br>
> @@ -624,6 +624,32 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,<br>
> return 0;<br>
> }<br>
> <br>
> +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)<br>
> +{<br>
> + LOG(V4L2Compat, Debug) << "Servicing vidioc_expbuf fd = " << file->efd();<br>
> +<br>
> + if (!hasOwnership(file))<br>
> + return -EBUSY;<br>
> +<br>
> + /* \todo Verify that the memory type is MMAP when adding DMABUF support */<br>
> + if (!validateBufferType(arg->type))<br>
> + return -EINVAL;<br>
> +<br>
> + if (arg->index >= bufferCount_)<br>
> + return -EINVAL;<br>
> +<br>
> + if (arg->flags & ~(O_CLOEXEC | O_ACCMODE))<br>
> + return -EINVAL;<br>
> +<br>
> + memset(arg->reserved, 0, sizeof(arg->reserved));<br>
> +<br>
> + /* \todo honor the O_ACCMODE flags passed to this function */<br>
> + arg->fd = fcntl(vcam_->getBufferFd(arg->index),<br>
> + arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)<br>
> {<br>
> LOG(V4L2Compat, Debug) << "Servicing vidioc_streamon fd = " << file->efd();<br>
> @@ -685,6 +711,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {<br>
> VIDIOC_QUERYBUF,<br>
> VIDIOC_QBUF,<br>
> VIDIOC_DQBUF,<br>
> + VIDIOC_EXPBUF,<br>
> VIDIOC_STREAMON,<br>
> VIDIOC_STREAMOFF,<br>
> };<br>
> @@ -755,6 +782,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar<br>
> case VIDIOC_DQBUF:<br>
> ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &proxyMutex_);<br>
> break;<br>
> + case VIDIOC_EXPBUF:<br>
> + ret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));<br>
> + break;<br>
> case VIDIOC_STREAMON:<br>
> ret = vidioc_streamon(file, static_cast<int *>(arg));<br>
> break;<br>
> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h<br>
> index fa0a49e0439b..14e027c3e7d1 100644<br>
> --- a/src/v4l2/v4l2_camera_proxy.h<br>
> +++ b/src/v4l2/v4l2_camera_proxy.h<br>
> @@ -60,6 +60,7 @@ private:<br>
> int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);<br>
> int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,<br>
> libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);<br>
> + int vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);<br>
> int vidioc_streamon(V4L2CameraFile *file, int *arg);<br>
> int vidioc_streamoff(V4L2CameraFile *file, int *arg);<br>
> <br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div>