<div dir="auto">Hello Laurent,<div dir="auto">Sorry for the delay, I've had a busy week, and will check it's working this week and report back.</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 Mon, 6 Dec, 2021, 18:05 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>
On Mon, Nov 29, 2021 at 09:18:38PM +0200, Laurent Pinchart wrote:<br>
> On Tue, Nov 30, 2021 at 12:29:45AM +0530, Vedant Paranjape wrote:<br>
> > On Mon, Nov 29, 2021 at 10:01 PM Laurent Pinchart wrote:<br>
> > > On Mon, Nov 29, 2021 at 09:43:36PM +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,<br>
> > ><br>
> > > Reviewed-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank" rel="noreferrer">laurent.pinchart@ideasonboard.com</a>><br>
> > ><br>
> > > Now we need to get this tested before merging it :-) v4l2-ctl could be<br>
> > > an option, with (taken from the example in the manpage)<br>
> > ><br>
> > > v4l2-ctl --device /dev/video1 --stream-mmap \<br>
> > >         --out-device /dev/video2 --stream-out-dmabuf<br>
> > <br>
> > This should be preceded by LD_PRELOD, right ?<br>
> <br>
> Otherwise you wouldn't be testing much, yes :-) You should enable<br>
> logging and make sure the the "Servicing vidioc_expbuf" message is<br>
> printed during your tests.<br>
<br>
Have you been able to test this patch successfully (with enough<br>
confidence that the test case actually exercises the EXPBUF code path) ?<br>
<br>
> > > using the vivid output device.<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 3610e63cade3..f194e06345b7 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).fd(),<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), &locker);<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 fccec241879d..81ef7788e9fe 100644<br>
> > > > --- a/src/v4l2/v4l2_camera_proxy.h<br>
> > > > +++ b/src/v4l2/v4l2_camera_proxy.h<br>
> > > > @@ -58,6 +58,7 @@ private:<br>
> > > >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);<br>
> > > >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,<br>
> > > >                        libcamera::MutexLocker *locker);<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>