[{"id":21294,"web_url":"https://patchwork.libcamera.org/comment/21294/","msgid":"<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>","date":"2021-11-28T13:31:38","subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Vedant,\n\nThank you for the patch.\n\nOn Sun, Nov 28, 2021 at 11:45:56AM +0530, Vedant Paranjape wrote:\n> To support DMABUF as one of the memory buffer, we need to implement\n> EXPBUF in the v4l2 compat layer.\n> \n> This patch implements vidioc_expbuf as one of the supported ioctls.\n> \n> Bug: https://bugs.libcamera.org/show_bug.cgi?id=89\n> \n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 37 ++++++++++++++++++++++++++++++++++\n>  src/v4l2/v4l2_camera_proxy.h   |  1 +\n>  2 files changed, 38 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 3610e63cade3..cb2f93631ab9 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -624,6 +624,39 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n>  \treturn 0;\n>  }\n>  \n> +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)\n> +{\n> +\tLOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" << file->efd();\n> +\n> +\tif (!hasOwnership(file))\n> +\t\treturn -EBUSY;\n> +\n> +\t/* \\todo Verify that the memory type is MMAP when adding DMABUF support */\n> +\tif (!validateBufferType(arg->type))\n> +\t\treturn -EINVAL;\n> +\n> +\tif (arg->index >= bufferCount_)\n> +\t\treturn -EINVAL;\n> +\n> +\tif (arg->flags & ~(O_CLOEXEC | O_ACCMODE))\n> +\t\treturn -EINVAL;\n> +\n> +\tLOG(V4L2Compat, Debug) << arg->index << \" : index of the buffer\";\n\nI'd either drop this, or combine it with the message at the top of the\nfunction.\n\n> +\n> +\tif (file->priority() < maxPriority())\n> +\t\treturn -EBUSY;\n\nWhy is this chech needed ?\n\n> +\n> +\tmemset(arg->reserved, 0, sizeof(arg->reserved));\n> +\n> +\targ->fd = fcntl(buffers_[arg->index].m.fd,\n> +\t\t\targ->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\n> +\targ->fd = fcntl(arg->fd, F_SETFL, 0);\n\n0 isn't the right value.\n\n> +\n> +\tLOG(V4L2Compat, Debug) << \"Exported buffer at index: \" << arg->index;\n\nI'd drop this too.\n\n> +\n> +\treturn 0;\n> +}\n> +\n>  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n>  {\n>  \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" << file->efd();\n> @@ -685,6 +718,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n>  \tVIDIOC_QUERYBUF,\n>  \tVIDIOC_QBUF,\n>  \tVIDIOC_DQBUF,\n> +\tVIDIOC_EXPBUF,\n>  \tVIDIOC_STREAMON,\n>  \tVIDIOC_STREAMOFF,\n>  };\n> @@ -755,6 +789,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n>  \tcase VIDIOC_DQBUF:\n>  \t\tret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker);\n>  \t\tbreak;\n> +\tcase VIDIOC_EXPBUF:\n> +\t\tret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));\n> +\t\tbreak;\n>  \tcase VIDIOC_STREAMON:\n>  \t\tret = vidioc_streamon(file, static_cast<int *>(arg));\n>  \t\tbreak;\n> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> index fccec241879d..81ef7788e9fe 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -58,6 +58,7 @@ private:\n>  \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n>  \tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n>  \t\t\t libcamera::MutexLocker *locker);\n> +\tint vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);\n>  \tint vidioc_streamon(V4L2CameraFile *file, int *arg);\n>  \tint vidioc_streamoff(V4L2CameraFile *file, int *arg);\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6C185BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 13:32:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 99CD46057D;\n\tSun, 28 Nov 2021 14:32:04 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 366F36011C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 14:32:03 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 90135F1;\n\tSun, 28 Nov 2021 14:32:02 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sLvcioye\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638106322;\n\tbh=n43oG+oBHG4ko+mODyTJkqth8bgtmj4fETUtcaNfxkM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=sLvcioyelHC19dj5srWUJAdYnvRYHDxQaOl/zoQMvDGQVs2/hxrOz817mviF9/hT0\n\t9vjV+nBibqlKV3oDLf5T4+2CemfxI6pdbNcdImFj+EnBYQLoAaPpzKZ8QG/rU3556R\n\thhJKvF+QEvKX9BGEhWam6M9m0gL9GJR6HmjDeVQk=","Date":"Sun, 28 Nov 2021 15:31:38 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>","References":"<20211128061556.503443-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211128061556.503443-1-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21296,"web_url":"https://patchwork.libcamera.org/comment/21296/","msgid":"<YaOwPl+4tN5oavZq@pendragon.ideasonboard.com>","date":"2021-11-28T16:37:18","subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Sun, Nov 28, 2021 at 03:31:40PM +0200, Laurent Pinchart wrote:\n> Hi Vedant,\n> \n> Thank you for the patch.\n> \n> On Sun, Nov 28, 2021 at 11:45:56AM +0530, Vedant Paranjape wrote:\n> > To support DMABUF as one of the memory buffer, we need to implement\n> > EXPBUF in the v4l2 compat layer.\n> > \n> > This patch implements vidioc_expbuf as one of the supported ioctls.\n> > \n> > Bug: https://bugs.libcamera.org/show_bug.cgi?id=89\n> > \n> > Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 37 ++++++++++++++++++++++++++++++++++\n> >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> >  2 files changed, 38 insertions(+)\n> > \n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index 3610e63cade3..cb2f93631ab9 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -624,6 +624,39 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> >  \treturn 0;\n> >  }\n> >  \n> > +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)\n> > +{\n> > +\tLOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" << file->efd();\n> > +\n> > +\tif (!hasOwnership(file))\n> > +\t\treturn -EBUSY;\n> > +\n> > +\t/* \\todo Verify that the memory type is MMAP when adding DMABUF support */\n> > +\tif (!validateBufferType(arg->type))\n> > +\t\treturn -EINVAL;\n> > +\n> > +\tif (arg->index >= bufferCount_)\n> > +\t\treturn -EINVAL;\n> > +\n> > +\tif (arg->flags & ~(O_CLOEXEC | O_ACCMODE))\n> > +\t\treturn -EINVAL;\n> > +\n> > +\tLOG(V4L2Compat, Debug) << arg->index << \" : index of the buffer\";\n> \n> I'd either drop this, or combine it with the message at the top of the\n> function.\n> \n> > +\n> > +\tif (file->priority() < maxPriority())\n> > +\t\treturn -EBUSY;\n> \n> Why is this chech needed ?\n> \n> > +\n> > +\tmemset(arg->reserved, 0, sizeof(arg->reserved));\n> > +\n> > +\targ->fd = fcntl(buffers_[arg->index].m.fd,\n> > +\t\t\targ->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\n\nActually I don't think this is correct. .m.fd is for importing dmabufs,\nit's always 0 at the moment.\n\nIf this has passed v4l2-compliance, it means EXPBUF isn't properly\ntested by it.\n\n> > +\targ->fd = fcntl(arg->fd, F_SETFL, 0);\n> \n> 0 isn't the right value.\n> \n> > +\n> > +\tLOG(V4L2Compat, Debug) << \"Exported buffer at index: \" << arg->index;\n> \n> I'd drop this too.\n> \n> > +\n> > +\treturn 0;\n> > +}\n> > +\n> >  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n> >  {\n> >  \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" << file->efd();\n> > @@ -685,6 +718,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n> >  \tVIDIOC_QUERYBUF,\n> >  \tVIDIOC_QBUF,\n> >  \tVIDIOC_DQBUF,\n> > +\tVIDIOC_EXPBUF,\n> >  \tVIDIOC_STREAMON,\n> >  \tVIDIOC_STREAMOFF,\n> >  };\n> > @@ -755,6 +789,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n> >  \tcase VIDIOC_DQBUF:\n> >  \t\tret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker);\n> >  \t\tbreak;\n> > +\tcase VIDIOC_EXPBUF:\n> > +\t\tret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));\n> > +\t\tbreak;\n> >  \tcase VIDIOC_STREAMON:\n> >  \t\tret = vidioc_streamon(file, static_cast<int *>(arg));\n> >  \t\tbreak;\n> > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> > index fccec241879d..81ef7788e9fe 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.h\n> > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > @@ -58,6 +58,7 @@ private:\n> >  \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> >  \tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> >  \t\t\t libcamera::MutexLocker *locker);\n> > +\tint vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);\n> >  \tint vidioc_streamon(V4L2CameraFile *file, int *arg);\n> >  \tint vidioc_streamoff(V4L2CameraFile *file, int *arg);\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C0A7BBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 16:37:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CF2C56057D;\n\tSun, 28 Nov 2021 17:37:43 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA1E96011C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 17:37:42 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 599CEF1;\n\tSun, 28 Nov 2021 17:37:42 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZnsURDzD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638117462;\n\tbh=mx0+CxW2CnMnCsBFnTS0gK/E8isVE1lWfwpBkeY4/uw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZnsURDzD06+OxPJ1StLJed0Q8Jvw6Ny7KyzxdP6M8WPdC3lDkgPxNlAM+INBNl8cO\n\t4/NPycZPeFRHMEVFwaRGF8D65U4OQoLCCG3TXp76YhG7XqELmItGJ7ilCX3L4w5Gtb\n\tUzvUXjae3bPPQ8je14GzFvm8XYoARGNmPARXX4SI=","Date":"Sun, 28 Nov 2021 18:37:18 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<YaOwPl+4tN5oavZq@pendragon.ideasonboard.com>","References":"<20211128061556.503443-1-vedantparanjape160201@gmail.com>\n\t<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21297,"web_url":"https://patchwork.libcamera.org/comment/21297/","msgid":"<CACGrz-MZbt8oQZ7=-kZfZubbMZML2UMfQoATk6c+=QeJjdbv+A@mail.gmail.com>","date":"2021-11-28T19:06:50","subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hello Laurent,\nThanks for the review.\n\nOn Sun, Nov 28, 2021 at 7:02 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Vedant,\n>\n> Thank you for the patch.\n>\n> On Sun, Nov 28, 2021 at 11:45:56AM +0530, Vedant Paranjape wrote:\n> > To support DMABUF as one of the memory buffer, we need to implement\n> > EXPBUF in the v4l2 compat layer.\n> >\n> > This patch implements vidioc_expbuf as one of the supported ioctls.\n> >\n> > Bug: https://bugs.libcamera.org/show_bug.cgi?id=89\n> >\n> > Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 37 ++++++++++++++++++++++++++++++++++\n> >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> >  2 files changed, 38 insertions(+)\n> >\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index 3610e63cade3..cb2f93631ab9 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -624,6 +624,39 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> >       return 0;\n> >  }\n> >\n> > +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)\n> > +{\n> > +     LOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" << file->efd();\n> > +\n> > +     if (!hasOwnership(file))\n> > +             return -EBUSY;\n> > +\n> > +     /* \\todo Verify that the memory type is MMAP when adding DMABUF support */\n> > +     if (!validateBufferType(arg->type))\n> > +             return -EINVAL;\n> > +\n> > +     if (arg->index >= bufferCount_)\n> > +             return -EINVAL;\n> > +\n> > +     if (arg->flags & ~(O_CLOEXEC | O_ACCMODE))\n> > +             return -EINVAL;\n> > +\n> > +     LOG(V4L2Compat, Debug) << arg->index << \" : index of the buffer\";\n>\n> I'd either drop this, or combine it with the message at the top of the\n> function.\n>\n> > +\n> > +     if (file->priority() < maxPriority())\n> > +             return -EBUSY;\n>\n> Why is this chech needed ?\n>\n> > +\n> > +     memset(arg->reserved, 0, sizeof(arg->reserved));\n> > +\n> > +     arg->fd = fcntl(buffers_[arg->index].m.fd,\n> > +                     arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\n> > +     arg->fd = fcntl(arg->fd, F_SETFL, 0);\n>\n> 0 isn't the right value.\n\nI am not sure what will come here, the Docs are not super clear about it.\nIs this right instead ?\n\n> arg->fd = fcntl(arg->fd, F_SETFL);\n\n>\n> > +\n> > +     LOG(V4L2Compat, Debug) << \"Exported buffer at index: \" << arg->index;\n>\n> I'd drop this too.\n>\n> > +\n> > +     return 0;\n> > +}\n> > +\n> >  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n> >  {\n> >       LOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" << file->efd();\n> > @@ -685,6 +718,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n> >       VIDIOC_QUERYBUF,\n> >       VIDIOC_QBUF,\n> >       VIDIOC_DQBUF,\n> > +     VIDIOC_EXPBUF,\n> >       VIDIOC_STREAMON,\n> >       VIDIOC_STREAMOFF,\n> >  };\n> > @@ -755,6 +789,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n> >       case VIDIOC_DQBUF:\n> >               ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker);\n> >               break;\n> > +     case VIDIOC_EXPBUF:\n> > +             ret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));\n> > +             break;\n> >       case VIDIOC_STREAMON:\n> >               ret = vidioc_streamon(file, static_cast<int *>(arg));\n> >               break;\n> > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> > index fccec241879d..81ef7788e9fe 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.h\n> > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > @@ -58,6 +58,7 @@ private:\n> >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> >                        libcamera::MutexLocker *locker);\n> > +     int vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);\n> >       int vidioc_streamon(V4L2CameraFile *file, int *arg);\n> >       int vidioc_streamoff(V4L2CameraFile *file, int *arg);\n> >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id DC57EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 19:07:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 30EE56057B;\n\tSun, 28 Nov 2021 20:07:06 +0100 (CET)","from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com\n\t[IPv6:2607:f8b0:4864:20::b36])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F1B2604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 20:07:04 +0100 (CET)","by mail-yb1-xb36.google.com with SMTP id q74so35620519ybq.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 11:07:03 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"BQ0HzlpL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=CiYdJZX2LR0eBlDg+3tVd4xr3Z+zFBi9rG36hu8nCA0=;\n\tb=BQ0HzlpLnreSYP2rkjE+wwUzMEqVE0nJgCIJiYsrn80VoBsW1nYbbEsNDDXde6MhZD\n\toB3/uRJHwriufOrcTpCbAEqlc5en2Xm0+XXZ4JK7xp+PwAw1zVJPFT2j3JtJt9r0Kd/f\n\t9lAOYDVZLoFjQGDQFAmr2xb6eIJyO/LbaodC6S3HFPaSBYZgB+GwNLuWwRu67/DaX+Vu\n\trfeB36jSOZ80j2mXA4oJrqOBZSY7JX9ReGHA0bQ76bAE4Aud6nYDRMQvGiwEM89In7F3\n\t9wB9Ef/hBM1oCSSiUupBQmc/PUh8+jxHVU8PmyrRrfZI/gJTQBH1XT44WN673gSoQ8xg\n\tH+Vw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=CiYdJZX2LR0eBlDg+3tVd4xr3Z+zFBi9rG36hu8nCA0=;\n\tb=yzwi6f80tKzdHi/vR/eFauoSS89nG/b++5wqbzJX+cf8s8Cv0OWzfPnNvVDTiwS053\n\tpOR/o30sCI9JJakE4ojeBJqgRUnCexBCJYZ2vBP6SPa4IXN+FqM0DRuIWmOrXvgkriPJ\n\tANNHv/wmt1sS/vWleuNL+1HAfmFJ/Q8x5jH2SQ+G8+0JvOR39L2oTAU2XOR7A1rYwXi/\n\tkk0HtMz6DkHlD4GeAB7yDLJJveIp990FownT+rM3XXvKC/6RSTq55p56X9BkiMLKWqLS\n\tMHeXLIcCdYI10/ICxqMpndXjxA+VtIss6BOffo8QzdC0McpUYF42gepsCBUfL+1SFcYG\n\tD9Zw==","X-Gm-Message-State":"AOAM531d7a2Ci33fobP6Qc9l9FNxG44uBHKjFJcMjiwXRPW5JLLu6Hkl\n\tdNWT9SCZBqIgzhPVsu11QZ6Muieg2jCEi9990C4=","X-Google-Smtp-Source":"ABdhPJwdfqmkh86b6f9VhbzkQPn4b0gNatdH5PInNemowrCOFUkbbyq4/BEl9Qo2KrMiRyfOWMwkjB3YeJ+zxtKopRE=","X-Received":"by 2002:a25:baca:: with SMTP id\n\ta10mr2550435ybk.598.1638126422658; \n\tSun, 28 Nov 2021 11:07:02 -0800 (PST)","MIME-Version":"1.0","References":"<20211128061556.503443-1-vedantparanjape160201@gmail.com>\n\t<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>","In-Reply-To":"<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Mon, 29 Nov 2021 00:36:50 +0530","Message-ID":"<CACGrz-MZbt8oQZ7=-kZfZubbMZML2UMfQoATk6c+=QeJjdbv+A@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21298,"web_url":"https://patchwork.libcamera.org/comment/21298/","msgid":"<CACGrz-PewQw_krNdwUp3X-yB-NL2FLg7VvrM9JjEcD+rAK8nLQ@mail.gmail.com>","date":"2021-11-28T19:10:33","subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"From the docs\n> * @fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;\n> * a userspace file descriptor associated with this buffer\n\nMy guess is since memory is not equal to V4L2_MEMORY_DMABUF yet, this\nwon't work.\n\nOn Sun, Nov 28, 2021 at 10:07 PM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> On Sun, Nov 28, 2021 at 03:31:40PM +0200, Laurent Pinchart wrote:\n> > Hi Vedant,\n> >\n> > Thank you for the patch.\n> >\n> > On Sun, Nov 28, 2021 at 11:45:56AM +0530, Vedant Paranjape wrote:\n> > > To support DMABUF as one of the memory buffer, we need to implement\n> > > EXPBUF in the v4l2 compat layer.\n> > >\n> > > This patch implements vidioc_expbuf as one of the supported ioctls.\n> > >\n> > > Bug: https://bugs.libcamera.org/show_bug.cgi?id=89\n> > >\n> > > Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> > > ---\n> > >  src/v4l2/v4l2_camera_proxy.cpp | 37 ++++++++++++++++++++++++++++++++++\n> > >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> > >  2 files changed, 38 insertions(+)\n> > >\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > index 3610e63cade3..cb2f93631ab9 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > @@ -624,6 +624,39 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > >     return 0;\n> > >  }\n> > >\n> > > +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)\n> > > +{\n> > > +   LOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" << file->efd();\n> > > +\n> > > +   if (!hasOwnership(file))\n> > > +           return -EBUSY;\n> > > +\n> > > +   /* \\todo Verify that the memory type is MMAP when adding DMABUF support */\n> > > +   if (!validateBufferType(arg->type))\n> > > +           return -EINVAL;\n> > > +\n> > > +   if (arg->index >= bufferCount_)\n> > > +           return -EINVAL;\n> > > +\n> > > +   if (arg->flags & ~(O_CLOEXEC | O_ACCMODE))\n> > > +           return -EINVAL;\n> > > +\n> > > +   LOG(V4L2Compat, Debug) << arg->index << \" : index of the buffer\";\n> >\n> > I'd either drop this, or combine it with the message at the top of the\n> > function.\n> >\n> > > +\n> > > +   if (file->priority() < maxPriority())\n> > > +           return -EBUSY;\n> >\n> > Why is this chech needed ?\n> >\n> > > +\n> > > +   memset(arg->reserved, 0, sizeof(arg->reserved));\n> > > +\n> > > +   arg->fd = fcntl(buffers_[arg->index].m.fd,\n> > > +                   arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\n>\n> Actually I don't think this is correct. .m.fd is for importing dmabufs,\n> it's always 0 at the moment.\n>\n> If this has passed v4l2-compliance, it means EXPBUF isn't properly\n> tested by it.\n>\n> > > +   arg->fd = fcntl(arg->fd, F_SETFL, 0);\n> >\n> > 0 isn't the right value.\n> >\n> > > +\n> > > +   LOG(V4L2Compat, Debug) << \"Exported buffer at index: \" << arg->index;\n> >\n> > I'd drop this too.\n> >\n> > > +\n> > > +   return 0;\n> > > +}\n> > > +\n> > >  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n> > >  {\n> > >     LOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" << file->efd();\n> > > @@ -685,6 +718,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n> > >     VIDIOC_QUERYBUF,\n> > >     VIDIOC_QBUF,\n> > >     VIDIOC_DQBUF,\n> > > +   VIDIOC_EXPBUF,\n> > >     VIDIOC_STREAMON,\n> > >     VIDIOC_STREAMOFF,\n> > >  };\n> > > @@ -755,6 +789,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n> > >     case VIDIOC_DQBUF:\n> > >             ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker);\n> > >             break;\n> > > +   case VIDIOC_EXPBUF:\n> > > +           ret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));\n> > > +           break;\n> > >     case VIDIOC_STREAMON:\n> > >             ret = vidioc_streamon(file, static_cast<int *>(arg));\n> > >             break;\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> > > index fccec241879d..81ef7788e9fe 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.h\n> > > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > > @@ -58,6 +58,7 @@ private:\n> > >     int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> > >     int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > >                      libcamera::MutexLocker *locker);\n> > > +   int vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);\n> > >     int vidioc_streamon(V4L2CameraFile *file, int *arg);\n> > >     int vidioc_streamoff(V4L2CameraFile *file, int *arg);\n> > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9C7D0BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 19:10:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E71936058E;\n\tSun, 28 Nov 2021 20:10:46 +0100 (CET)","from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com\n\t[IPv6:2607:f8b0:4864:20::b34])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B24D604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 20:10:45 +0100 (CET)","by mail-yb1-xb34.google.com with SMTP id f9so35665384ybq.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 11:10:45 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"lL56ouJQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=ARo7/xMr7JN1SLrZ8XljBofQ97WO38h7SyWMMK+eHJo=;\n\tb=lL56ouJQ/G3BGQDNlBzszWkGUMZiIhCqNPCgK9mTPBQDu+zi8/2rlcqpDD6Y0JRP/n\n\ttOvFRTTfloEBtgGDlNcuL5dF38Axk/1Eps141EhUbIbW5fD51Mxndpdgx9c/4h/sMfaG\n\tCEh19hdhwoYsfLo6rWylr6TtmPZm97EGvcBpmIt1uGiGJCFowKVfWWwYM1RFkpr4fmD5\n\thTo2VYbpISENH5DkD7FScSw3cqv+BY3jG0qtb0OnxFSTARYKxD30A5bEfEDmxaSQHMRQ\n\tUY8/xis7rL/XklSLNXsdvecDai0PtZLFdqQItf19TaJmOESJAa9LJ2BbW6iwYVG4Hmre\n\trUTA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=ARo7/xMr7JN1SLrZ8XljBofQ97WO38h7SyWMMK+eHJo=;\n\tb=xYOknv38CF/JazDEVE7/6UAbcuiisdS8heCT0pO2LT/IXJZfGDHxX470P/SKvSAFr0\n\tLc2aOuMToEkJAE7+9NVb0Xb4FffQv/OCIlDnsRhtRpV4vBnIjtxAaOntlecVp2WamTwv\n\tqVWgGDYmz43f6cUS02KVRbLjuV+HI5hha1KkUBDM9VdsnBJHBVc9KFxTfD7o9kCjhatk\n\tB79jQJjoTyS+Q2J5PAcUjmEGQA96ltR0qpu+Yz1XcD+DWxGzuiNSKK6+KeQ6XWWSRIlj\n\tCKpokWB+WPbyqke8ZE5mod0ZrW9kqniIB7ZKMe6NwhJxJMKCJujtmb0HuGvVKOfuuVqx\n\tG1Tg==","X-Gm-Message-State":"AOAM5338jW5QOfsl+Qp1w/7Xfw1bbPj2e7ZOova44HVnXh19J7EfxnDW\n\twjb1J53s8pzgDdnP5ymMjJNrCof0XO/B9guRR4E=","X-Google-Smtp-Source":"ABdhPJwXjPqF9rLRpNfB09F2c46zCfyNRn8pC6nqTLEZwH/4GysSrSVKuRxygdsGJRxsLzlAG6aKMV50tktzGhKG7gE=","X-Received":"by 2002:a25:3c07:: with SMTP id j7mr2840035yba.612.1638126644092;\n\tSun, 28 Nov 2021 11:10:44 -0800 (PST)","MIME-Version":"1.0","References":"<20211128061556.503443-1-vedantparanjape160201@gmail.com>\n\t<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>\n\t<YaOwPl+4tN5oavZq@pendragon.ideasonboard.com>","In-Reply-To":"<YaOwPl+4tN5oavZq@pendragon.ideasonboard.com>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Mon, 29 Nov 2021 00:40:33 +0530","Message-ID":"<CACGrz-PewQw_krNdwUp3X-yB-NL2FLg7VvrM9JjEcD+rAK8nLQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":21303,"web_url":"https://patchwork.libcamera.org/comment/21303/","msgid":"<YaQHlW9rnzINlupd@pendragon.ideasonboard.com>","date":"2021-11-28T22:49:57","subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Vedant,\n\nOn Mon, Nov 29, 2021 at 12:36:50AM +0530, Vedant Paranjape wrote:\n> On Sun, Nov 28, 2021 at 7:02 PM Laurent Pinchart wrote:\n> > On Sun, Nov 28, 2021 at 11:45:56AM +0530, Vedant Paranjape wrote:\n> > > To support DMABUF as one of the memory buffer, we need to implement\n> > > EXPBUF in the v4l2 compat layer.\n> > >\n> > > This patch implements vidioc_expbuf as one of the supported ioctls.\n> > >\n> > > Bug: https://bugs.libcamera.org/show_bug.cgi?id=89\n> > >\n> > > Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> > > ---\n> > >  src/v4l2/v4l2_camera_proxy.cpp | 37 ++++++++++++++++++++++++++++++++++\n> > >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> > >  2 files changed, 38 insertions(+)\n> > >\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > index 3610e63cade3..cb2f93631ab9 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > @@ -624,6 +624,39 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > >       return 0;\n> > >  }\n> > >\n> > > +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)\n> > > +{\n> > > +     LOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" << file->efd();\n> > > +\n> > > +     if (!hasOwnership(file))\n> > > +             return -EBUSY;\n> > > +\n> > > +     /* \\todo Verify that the memory type is MMAP when adding DMABUF support */\n> > > +     if (!validateBufferType(arg->type))\n> > > +             return -EINVAL;\n> > > +\n> > > +     if (arg->index >= bufferCount_)\n> > > +             return -EINVAL;\n> > > +\n> > > +     if (arg->flags & ~(O_CLOEXEC | O_ACCMODE))\n> > > +             return -EINVAL;\n> > > +\n> > > +     LOG(V4L2Compat, Debug) << arg->index << \" : index of the buffer\";\n> >\n> > I'd either drop this, or combine it with the message at the top of the\n> > function.\n> >\n> > > +\n> > > +     if (file->priority() < maxPriority())\n> > > +             return -EBUSY;\n> >\n> > Why is this chech needed ?\n> >\n> > > +\n> > > +     memset(arg->reserved, 0, sizeof(arg->reserved));\n> > > +\n> > > +     arg->fd = fcntl(buffers_[arg->index].m.fd,\n> > > +                     arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\n> > > +     arg->fd = fcntl(arg->fd, F_SETFL, 0);\n> >\n> > 0 isn't the right value.\n> \n> I am not sure what will come here, the Docs are not super clear about it.\n> Is this right instead ?\n> \n> > arg->fd = fcntl(arg->fd, F_SETFL);\n\nNo, F_SETFL takes an int argument:\n\n       F_SETFL (int)\n\t      Set the file status flags to the value specified by arg.\n\t      File access mode (O_RDONLY, O_WRONLY, O_RDWR)  and  file\n\t      creation  flags  (i.e.,  O_CREAT,  O_EXCL,  O_NOCTTY,\n\t      O_TRUNC)  in arg are ignored.  On Linux, this command can\n\t      change only the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME,\n\t      and O_NONBLOCK flags.  It is not possible to change the\n\t      O_DSYNC and O_SYNC flags; see BUGS, below.\n\nAnd now that I read this more carefully, it's clear that it's not the\nright command, as it ignores the file access mode.\n\nIt seems fcntl() can't change the access mode. The question is thus how\nto honour the O_ACCMODE flags passed to this function, or possibly, how\nto emulate them. That doesn't seem straightforward, intercepting mmap()\non the exported dmabufs could be the only way. I don't think that needs\nto be implemented here, but a \\todo would be good.\n\n> > > +\n> > > +     LOG(V4L2Compat, Debug) << \"Exported buffer at index: \" << arg->index;\n> >\n> > I'd drop this too.\n> >\n> > > +\n> > > +     return 0;\n> > > +}\n> > > +\n> > >  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n> > >  {\n> > >       LOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" << file->efd();\n> > > @@ -685,6 +718,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {\n> > >       VIDIOC_QUERYBUF,\n> > >       VIDIOC_QBUF,\n> > >       VIDIOC_DQBUF,\n> > > +     VIDIOC_EXPBUF,\n> > >       VIDIOC_STREAMON,\n> > >       VIDIOC_STREAMOFF,\n> > >  };\n> > > @@ -755,6 +789,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n> > >       case VIDIOC_DQBUF:\n> > >               ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker);\n> > >               break;\n> > > +     case VIDIOC_EXPBUF:\n> > > +             ret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));\n> > > +             break;\n> > >       case VIDIOC_STREAMON:\n> > >               ret = vidioc_streamon(file, static_cast<int *>(arg));\n> > >               break;\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> > > index fccec241879d..81ef7788e9fe 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.h\n> > > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > > @@ -58,6 +58,7 @@ private:\n> > >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> > >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > >                        libcamera::MutexLocker *locker);\n> > > +     int vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);\n> > >       int vidioc_streamon(V4L2CameraFile *file, int *arg);\n> > >       int vidioc_streamoff(V4L2CameraFile *file, int *arg);\n> > >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 85828BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Nov 2021 22:50:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D08266058C;\n\tSun, 28 Nov 2021 23:50:22 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C587D604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Nov 2021 23:50:21 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A72DF1;\n\tSun, 28 Nov 2021 23:50:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wQaR1+Hk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638139821;\n\tbh=nPBFw8YkLvFfNrf5VwF9zCDDWedvCYI4tR62QZ79/uU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wQaR1+Hk4KEa5zqkJTcCvi0YtbTdwHMmUhSQBDyGPzgR6pVA472Ep+DbuWBFR2y5/\n\t+8MHMH7YqDg9OW4tu0hLV886678UzNRJUwd0Oz/7Akijlh2qxGZqL3+XDKtpb4IBEK\n\t+1DgON7Hk4XVydxd9nMExSkUUzjo9xbNPJVwO3Tk=","Date":"Mon, 29 Nov 2021 00:49:57 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<YaQHlW9rnzINlupd@pendragon.ideasonboard.com>","References":"<20211128061556.503443-1-vedantparanjape160201@gmail.com>\n\t<YaOEumoak1WIyMrm@pendragon.ideasonboard.com>\n\t<CACGrz-MZbt8oQZ7=-kZfZubbMZML2UMfQoATk6c+=QeJjdbv+A@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CACGrz-MZbt8oQZ7=-kZfZubbMZML2UMfQoATk6c+=QeJjdbv+A@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2] v4l2: V4L2CameraProxy: Add EXPBUF\n\tas one of the supported ioctl","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]