[{"id":21907,"web_url":"https://patchwork.libcamera.org/comment/21907/","msgid":"<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>","date":"2021-12-29T22:36:24","subject":"Re: [libcamera-devel] [PATCH v4] 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 Wed, Dec 29, 2021 at 12:20:14AM +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\nThis looks fine. As soon as you can test it with v4l2-ctl and capture\nimages, I think it can be merged.\n\nI've sent a patch for v4l2-ctl (which has been merged in the master\nbranch already) that should help with testing.\n\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n>  src/v4l2/v4l2_camera_proxy.h   |  1 +\n>  2 files changed, 31 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index c1375777c185..4d529bc29a4d 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -624,6 +624,32 @@ 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> +\tmemset(arg->reserved, 0, sizeof(arg->reserved));\n> +\n> +\t/* \\todo honor the O_ACCMODE flags passed to this function */\n> +\targ->fd = fcntl(vcam_->getBufferFd(arg->index),\n> +\t\t\targ->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\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 +711,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 +782,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), &proxyMutex_);\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 fa0a49e0439b..14e027c3e7d1 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -60,6 +60,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::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);\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 3BC3CBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Dec 2021 22:36:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 751B660905;\n\tWed, 29 Dec 2021 23:36:29 +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 85052608E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 23:36:27 +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 E9DBA33F;\n\tWed, 29 Dec 2021 23:36:26 +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=\"kqXdWdY7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640817387;\n\tbh=VEM3YD6QBZXuVtQj6UmTRolx7xlYSj3zAcgLKHqW0pg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=kqXdWdY7FeEGZsFE5jTpV/lhNjI0aZyHbwrLjKt30G2plJByhKI5IgsOvj4+Rot9B\n\tnQurpTqXzz3/iECkhExZKFSfpI1u13q056nqyKBMm+FgqUo1Cwa8uMBFKmH3D8wzY5\n\tawrRqa32oOvvvYCWPXuJD2Iz+Ov3Xgy7F+MXwyp0=","Date":"Thu, 30 Dec 2021 00:36:24 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>","References":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v4] 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":21909,"web_url":"https://patchwork.libcamera.org/comment/21909/","msgid":"<CACGrz-N24a1ZTq9kHx17QkVGu7weV4DrFYM8h_XtTO+yjYch6A@mail.gmail.com>","date":"2021-12-30T03:58:36","subject":"Re: [libcamera-devel] [PATCH v4] 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":"Hi Laurent,\nThanks for the v4l2-ctl patch. I'll test it soon and reply in this thread.\n\nRegards,\nVedant Paranjape\n\nOn Thu, 30 Dec, 2021, 04:06 Laurent Pinchart, <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Vedant,\n>\n> Thank you for the patch.\n>\n> On Wed, Dec 29, 2021 at 12:20:14AM +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> This looks fine. As soon as you can test it with v4l2-ctl and capture\n> images, I think it can be merged.\n>\n> I've sent a patch for v4l2-ctl (which has been merged in the master\n> branch already) that should help with testing.\n>\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n> >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> >  2 files changed, 31 insertions(+)\n> >\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp\n> b/src/v4l2/v4l2_camera_proxy.cpp\n> > index c1375777c185..4d529bc29a4d 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -624,6 +624,32 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile\n> *file, struct v4l2_buffer *arg,\n> >       return 0;\n> >  }\n> >\n> > +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct\n> v4l2_exportbuffer *arg)\n> > +{\n> > +     LOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" <<\n> file->efd();\n> > +\n> > +     if (!hasOwnership(file))\n> > +             return -EBUSY;\n> > +\n> > +     /* \\todo Verify that the memory type is MMAP when adding DMABUF\n> 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> > +     memset(arg->reserved, 0, sizeof(arg->reserved));\n> > +\n> > +     /* \\todo honor the O_ACCMODE flags passed to this function */\n> > +     arg->fd = fcntl(vcam_->getBufferFd(arg->index),\n> > +                     arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC :\n> F_DUPFD, 0);\n> > +\n> > +     return 0;\n> > +}\n> > +\n> >  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n> >  {\n> >       LOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" <<\n> file->efd();\n> > @@ -685,6 +711,7 @@ const std::set<unsigned long>\n> V4L2CameraProxy::supportedIoctls_ = {\n> >       VIDIOC_QUERYBUF,\n> >       VIDIOC_QBUF,\n> >       VIDIOC_DQBUF,\n> > +     VIDIOC_EXPBUF,\n> >       VIDIOC_STREAMON,\n> >       VIDIOC_STREAMOFF,\n> >  };\n> > @@ -755,6 +782,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file,\n> unsigned long request, void *ar\n> >       case VIDIOC_DQBUF:\n> >               ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer\n> *>(arg), &proxyMutex_);\n> >               break;\n> > +     case VIDIOC_EXPBUF:\n> > +             ret = vidioc_expbuf(file, static_cast<struct\n> 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 fa0a49e0439b..14e027c3e7d1 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.h\n> > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > @@ -60,6 +60,7 @@ private:\n> >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> >                        libcamera::Mutex *lock)\n> LIBCAMERA_TSA_REQUIRES(*lock);\n> > +     int vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer\n> *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\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 83F7FBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Dec 2021 03:58:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9EABA608EB;\n\tThu, 30 Dec 2021 04:58:50 +0100 (CET)","from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com\n\t[IPv6:2607:f8b0:4864:20::b2d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3192C6021B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Dec 2021 04:58:49 +0100 (CET)","by mail-yb1-xb2d.google.com with SMTP id p15so18195805ybk.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Dec 2021 19:58:49 -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=\"nEst1l+o\"; 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=UCPg+mSSSwiU9+EJXwpPY+htJvql7Dao9Sj+DorqFyU=;\n\tb=nEst1l+oMKseNi+oGBoDfQBZfUPTt742i5/DSTgYiRLjaGb9/+if1kHjG3hECUzeXW\n\tjHybJrRuotpIPfQhqQXt9V6MrYIPFRZNRbCmqdWU0Byhn6QI5zbwfbVTX9SYrARdrnTU\n\tQ8jhjAf3pEBfRHK+DPAHU3T9eI3rqXIXtw/iZT6G5KAdKBSKo6CttpUYl+FCrbjpi2Tk\n\tdBgEAwu076jsF3yCr3pD+LUcfcx1C99Q5CxcvKLHEBE80f7Jvgfob9So9RvEhhWYLMsB\n\tkEW4rw+wbA1c+DPP0bfwbgisbWigzrmGW5OXD3SRaOEytfQ5xFMXgN5dFkRPLcXdtHb7\n\tCsAg==","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=UCPg+mSSSwiU9+EJXwpPY+htJvql7Dao9Sj+DorqFyU=;\n\tb=g65pgF7pbzjU8MJ93wbpVBgm+Nshmq5uBIkz3XP+1mGu/0gk0CZhsWIiLQScQbzsEU\n\td8SLUWIC79RvIvQZ1mnmNEbe9eTUUcBljycl3ThH9cFo9tSTDDwbPjp5947Cmq7FnmpF\n\tVDKdiARBXIZEObvFRB0BQdfbBD/lMqKl3S/oMGYWMhcq1D+L0kE+g8JRX2+YWF8GYfyB\n\tXCrbxNVgDjmD5wpJGDZ72RkuM0gg4eCyGpotVrj00Ghs0AaL0MH+w10fob9qJaChT9Re\n\tLUNCJyBEgW10cFipr0Wzc7Q/B2fCpODpuu52l5ikbbGkm26dwkOJXSNEBy0H0UV3m3dP\n\tE17w==","X-Gm-Message-State":"AOAM5328EfeHtu7G7EABQaNyI7uxX/JkB9VYSumu7ZFk9kBksELD5HWp\n\tUb2LYqJvC6U/BEOg349ci8aQVczNBNmwMW2kQQdyXlSg","X-Google-Smtp-Source":"ABdhPJwJa8Pb1Kco/212lx8fA8fzDLIB2n2EnuAu2fRMCOdzBN2T/oqwOFTFjUlmQF/t8apYiUphvRdlnFjS1yU7nsw=","X-Received":"by 2002:a25:806:: with SMTP id 6mr39521432ybi.641.1640836727557; \n\tWed, 29 Dec 2021 19:58:47 -0800 (PST)","MIME-Version":"1.0","References":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>\n\t<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>","In-Reply-To":"<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Thu, 30 Dec 2021 09:28:36 +0530","Message-ID":"<CACGrz-N24a1ZTq9kHx17QkVGu7weV4DrFYM8h_XtTO+yjYch6A@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"00000000000047d03e05d4551289\"","Subject":"Re: [libcamera-devel] [PATCH v4] 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":21979,"web_url":"https://patchwork.libcamera.org/comment/21979/","msgid":"<CACGrz-NL=o9px-Qhcx=u5-HpaBRqA+eG=zCtZL3ZQFkckREd9g@mail.gmail.com>","date":"2022-01-07T21:40:15","subject":"Re: [libcamera-devel] [PATCH v4] 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,\nI have been able to get v4l2-ctl working to stream using dmabuf, here\nare the steps I followed:\n\n1) Apply the patch in the trailing email (v4) on the latest branch of libcamera\n2) Clone master of v4l-utils and apply this patch\nhttps://patchwork.kernel.org/project/linux-media/patch/20220104130708.166638-1-vedantparanjape160201@gmail.com/\n3) Compile v4l-utils\n4) give alias v4l2-ctl-edge=<PATH OF COMPILED V4l2-ctl>\n5) run the following command in libcamera root directory:\n     LD_PRELOAD=./build/src/v4l2/v4l2-compat.so v4l2-ctl-edge -d0\n--set-fmt-video=pixelformat='YUYV' --stream-mmap --out-device\n/dev/video3 --stream-out-dmabuf --get-fmt-video --get-fmt-video-out\n\nI have attached the output of lsv4l2 here as well:\n\nvideo0: HD WebCam: HD WebCam\nvideo1: HD WebCam: HD WebCam\nvideo2: vivid-000-vid-cap\nvideo3: vivid-000-vid-out\n\nHere's the terminal output: https://paste.debian.net/1226342/\n\nRegards,\nVedant Paranjape\n\nOn Thu, Dec 30, 2021 at 4:06 AM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Vedant,\n>\n> Thank you for the patch.\n>\n> On Wed, Dec 29, 2021 at 12:20:14AM +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> This looks fine. As soon as you can test it with v4l2-ctl and capture\n> images, I think it can be merged.\n>\n> I've sent a patch for v4l2-ctl (which has been merged in the master\n> branch already) that should help with testing.\n>\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n> >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> >  2 files changed, 31 insertions(+)\n> >\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index c1375777c185..4d529bc29a4d 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -624,6 +624,32 @@ 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> > +     memset(arg->reserved, 0, sizeof(arg->reserved));\n> > +\n> > +     /* \\todo honor the O_ACCMODE flags passed to this function */\n> > +     arg->fd = fcntl(vcam_->getBufferFd(arg->index),\n> > +                     arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\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 +711,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 +782,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), &proxyMutex_);\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 fa0a49e0439b..14e027c3e7d1 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.h\n> > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > @@ -60,6 +60,7 @@ private:\n> >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> >                        libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);\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 58C5CBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  7 Jan 2022 21:40:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9120E60930;\n\tFri,  7 Jan 2022 22:40:30 +0100 (CET)","from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com\n\t[IPv6:2607:f8b0:4864:20::b2f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 358EE604F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  7 Jan 2022 22:40:29 +0100 (CET)","by mail-yb1-xb2f.google.com with SMTP id d1so20397950ybh.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 07 Jan 2022 13:40:29 -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=\"iaerg8bh\"; 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=YXs5E2aSYVSkfGvGa6B9RsVIEkSRN9dJOiIB5vwPnMI=;\n\tb=iaerg8bhLrkc6kKbeHPf/6GoPvEGsgTIfVO0mmZAfRnLUNvwHtxaNV46lAKDYS0+sZ\n\tj/jw2/o87FJ+kJObWGy/JCyJmi6xIWxS7rqcDVT06kimwRFgiplZqo9zBxhghYN0yydR\n\tiyjHh263yK7IBGetDdPMBTMvEr9rqUwFWPl1/mMoZqIcNzvRED4ymBwDJcp/C/Ker57y\n\tbclce0BO39X/tQ7en2hYzdJmaanY4QWla1031eO34Z7qUelml88HNVOPhKE+4J1CVzGf\n\tzM7RpLA6GQEZUI0mPKnSzEcHUYSM6FXGickc0s7UwSOjfxLJx2E/8ZLxQ8Ihgchkp993\n\t9OTg==","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=YXs5E2aSYVSkfGvGa6B9RsVIEkSRN9dJOiIB5vwPnMI=;\n\tb=Q9Sl9fsD6JCyhM1Bc3c5Sp6yQms2ExY9MXD8vapWknzj2L8WFSHUF2eR8Bvg5yDaK5\n\tLaMwsZ2AYxcssWMtInXkBeSAiNZs730lw+yjEBbVV7SpvGPU+IQo5eTmi5b8kgY7YzzY\n\tACkDKjxVD8pzqv3WCDNEyNQirm8CrOYTKbG5nzuN4roSB1QkXA19EI2jolAmb0n6+NdV\n\toe+d0i0rdXLKc7v9bl3qXkSKWIzjPMImJRFTwb4k1/6K4NfPlSzOszlLFkNGHPtm+X0l\n\tDG0NI0XmZhe05i0iOEomgLX6W3w0bRD62b1HXYx0TAXJXk0DCKGdUlEuxMpXpHZXgxlX\n\tTzhw==","X-Gm-Message-State":"AOAM533m99F84E0nGfR+ufAeGWtC+8xPoAgIHZRRjN8fiMGRaa1JpVcL\n\t16agSi/iV+TsO7Zthm+pyYPOKuYK8l+2tvWtSYMtGiHFH3o=","X-Google-Smtp-Source":"ABdhPJz3scriHbAuKaoDqHa/vhUed3zEZeZoSopVsWBHkQKiwHYmzMfd156Kmr3NmLFJmVY976cClsPKoPtWR/MEpdc=","X-Received":"by 2002:a25:ab4e:: with SMTP id\n\tu72mr80336680ybi.679.1641591627875; \n\tFri, 07 Jan 2022 13:40:27 -0800 (PST)","MIME-Version":"1.0","References":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>\n\t<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>","In-Reply-To":"<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Sat, 8 Jan 2022 03:10:15 +0530","Message-ID":"<CACGrz-NL=o9px-Qhcx=u5-HpaBRqA+eG=zCtZL3ZQFkckREd9g@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v4] 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":21980,"web_url":"https://patchwork.libcamera.org/comment/21980/","msgid":"<YdmXGpY7F2ZYQuu9@pendragon.ideasonboard.com>","date":"2022-01-08T13:52:26","subject":"Re: [libcamera-devel] [PATCH v4] 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 Sat, Jan 08, 2022 at 03:10:15AM +0530, Vedant Paranjape wrote:\n> Hello Laurent,\n> I have been able to get v4l2-ctl working to stream using dmabuf, here\n> are the steps I followed:\n> \n> 1) Apply the patch in the trailing email (v4) on the latest branch of libcamera\n> 2) Clone master of v4l-utils and apply this patch\n> https://patchwork.kernel.org/project/linux-media/patch/20220104130708.166638-1-vedantparanjape160201@gmail.com/\n> 3) Compile v4l-utils\n> 4) give alias v4l2-ctl-edge=<PATH OF COMPILED V4l2-ctl>\n> 5) run the following command in libcamera root directory:\n>      LD_PRELOAD=./build/src/v4l2/v4l2-compat.so v4l2-ctl-edge -d0\n> --set-fmt-video=pixelformat='YUYV' --stream-mmap --out-device\n> /dev/video3 --stream-out-dmabuf --get-fmt-video --get-fmt-video-out\n\nYou can drop the last two arguments.\n\nWhile this show that the EXPBUF implementation works, in a real use case\nyou would still potentially have different formats on the capture and\noutput side, which would lead to garbled output. You should specify the\nformat and resolution explicitly on both the capture and output side.\n\nI'll merge the patch.\n\n> I have attached the output of lsv4l2 here as well:\n> \n> video0: HD WebCam: HD WebCam\n> video1: HD WebCam: HD WebCam\n> video2: vivid-000-vid-cap\n> video3: vivid-000-vid-out\n> \n> Here's the terminal output: https://paste.debian.net/1226342/\n> \n> Regards,\n> Vedant Paranjape\n> \n> On Thu, Dec 30, 2021 at 4:06 AM Laurent Pinchart wrote:\n> > On Wed, Dec 29, 2021 at 12:20:14AM +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> > This looks fine. As soon as you can test it with v4l2-ctl and capture\n> > images, I think it can be merged.\n> >\n> > I've sent a patch for v4l2-ctl (which has been merged in the master\n> > branch already) that should help with testing.\n> >\n> > > ---\n> > >  src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n> > >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> > >  2 files changed, 31 insertions(+)\n> > >\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > index c1375777c185..4d529bc29a4d 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > @@ -624,6 +624,32 @@ 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> > > +     memset(arg->reserved, 0, sizeof(arg->reserved));\n> > > +\n> > > +     /* \\todo honor the O_ACCMODE flags passed to this function */\n> > > +     arg->fd = fcntl(vcam_->getBufferFd(arg->index),\n> > > +                     arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);\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 +711,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 +782,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), &proxyMutex_);\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 fa0a49e0439b..14e027c3e7d1 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.h\n> > > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > > @@ -60,6 +60,7 @@ private:\n> > >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> > >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > >                        libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);\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 D2289BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  8 Jan 2022 13:52:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E1C9460935;\n\tSat,  8 Jan 2022 14:52:37 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 13C4F604F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  8 Jan 2022 14:52:36 +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 75D298AE;\n\tSat,  8 Jan 2022 14:52:35 +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=\"Qytjo7fE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1641649955;\n\tbh=/yhEHEW33VOXjn83OVamsd6oPGp69KGic7ipNjia+dg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Qytjo7fERos0cMsFhAOKbfnuhnrtzseCtKB/8LK6r9ym8mekZUlInY9flwJulbtU1\n\tJXtTZ1gY16t1WCLz8GckHBUGCSGeeMD4EZD5Fzb/3Q57bXNb0AEihVk5PkbqtSwP4+\n\t0h7Dcgp+o/V434wZLRdNRmGwEAKwabVWjCIWpSVo=","Date":"Sat, 8 Jan 2022 15:52:26 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<YdmXGpY7F2ZYQuu9@pendragon.ideasonboard.com>","References":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>\n\t<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>\n\t<CACGrz-NL=o9px-Qhcx=u5-HpaBRqA+eG=zCtZL3ZQFkckREd9g@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CACGrz-NL=o9px-Qhcx=u5-HpaBRqA+eG=zCtZL3ZQFkckREd9g@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v4] 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":21981,"web_url":"https://patchwork.libcamera.org/comment/21981/","msgid":"<CACGrz-OM0Bepy54_bdE1ypkS-kWt5vD5K3YeAFLAjZo7xN6wmg@mail.gmail.com>","date":"2022-01-08T14:04:15","subject":"Re: [libcamera-devel] [PATCH v4] 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":"Hi Laurent,\n\nOn Sat, 8 Jan, 2022, 19:22 Laurent Pinchart, <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Vedant,\n>\n> On Sat, Jan 08, 2022 at 03:10:15AM +0530, Vedant Paranjape wrote:\n> > Hello Laurent,\n> > I have been able to get v4l2-ctl working to stream using dmabuf, here\n> > are the steps I followed:\n> >\n> > 1) Apply the patch in the trailing email (v4) on the latest branch of\n> libcamera\n> > 2) Clone master of v4l-utils and apply this patch\n> >\n> https://patchwork.kernel.org/project/linux-media/patch/20220104130708.166638-1-vedantparanjape160201@gmail.com/\n> > 3) Compile v4l-utils\n> > 4) give alias v4l2-ctl-edge=<PATH OF COMPILED V4l2-ctl>\n> > 5) run the following command in libcamera root directory:\n> >      LD_PRELOAD=./build/src/v4l2/v4l2-compat.so v4l2-ctl-edge -d0\n> > --set-fmt-video=pixelformat='YUYV' --stream-mmap --out-device\n> > /dev/video3 --stream-out-dmabuf --get-fmt-video --get-fmt-video-out\n>\n> You can drop the last two arguments.\n>\n> While this show that the EXPBUF implementation works, in a real use case\n> you would still potentially have different formats on the capture and\n> output side, which would lead to garbled output. You should specify the\n> format and resolution explicitly on both the capture and output side.\n>\n\nMakes sense, I'll keep this in mind.\n\nI'll merge the patch.\n>\n> > I have attached the output of lsv4l2 here as well:\n> >\n> > video0: HD WebCam: HD WebCam\n> > video1: HD WebCam: HD WebCam\n> > video2: vivid-000-vid-cap\n> > video3: vivid-000-vid-out\n> >\n> > Here's the terminal output: https://paste.debian.net/1226342/\n> >\n> > Regards,\n> > Vedant Paranjape\n> >\n> > On Thu, Dec 30, 2021 at 4:06 AM Laurent Pinchart wrote:\n> > > On Wed, Dec 29, 2021 at 12:20:14AM +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> > > This looks fine. As soon as you can test it with v4l2-ctl and capture\n> > > images, I think it can be merged.\n> > >\n> > > I've sent a patch for v4l2-ctl (which has been merged in the master\n> > > branch already) that should help with testing.\n> > >\n> > > > ---\n> > > >  src/v4l2/v4l2_camera_proxy.cpp | 30 ++++++++++++++++++++++++++++++\n> > > >  src/v4l2/v4l2_camera_proxy.h   |  1 +\n> > > >  2 files changed, 31 insertions(+)\n> > > >\n> > > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp\n> b/src/v4l2/v4l2_camera_proxy.cpp\n> > > > index c1375777c185..4d529bc29a4d 100644\n> > > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > > @@ -624,6 +624,32 @@ int\n> V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > > >       return 0;\n> > > >  }\n> > > >\n> > > > +int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct\n> v4l2_exportbuffer *arg)\n> > > > +{\n> > > > +     LOG(V4L2Compat, Debug) << \"Servicing vidioc_expbuf fd = \" <<\n> file->efd();\n> > > > +\n> > > > +     if (!hasOwnership(file))\n> > > > +             return -EBUSY;\n> > > > +\n> > > > +     /* \\todo Verify that the memory type is MMAP when adding\n> 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> > > > +     memset(arg->reserved, 0, sizeof(arg->reserved));\n> > > > +\n> > > > +     /* \\todo honor the O_ACCMODE flags passed to this function */\n> > > > +     arg->fd = fcntl(vcam_->getBufferFd(arg->index),\n> > > > +                     arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC :\n> F_DUPFD, 0);\n> > > > +\n> > > > +     return 0;\n> > > > +}\n> > > > +\n> > > >  int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)\n> > > >  {\n> > > >       LOG(V4L2Compat, Debug) << \"Servicing vidioc_streamon fd = \" <<\n> file->efd();\n> > > > @@ -685,6 +711,7 @@ const std::set<unsigned long>\n> V4L2CameraProxy::supportedIoctls_ = {\n> > > >       VIDIOC_QUERYBUF,\n> > > >       VIDIOC_QBUF,\n> > > >       VIDIOC_DQBUF,\n> > > > +     VIDIOC_EXPBUF,\n> > > >       VIDIOC_STREAMON,\n> > > >       VIDIOC_STREAMOFF,\n> > > >  };\n> > > > @@ -755,6 +782,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file,\n> unsigned long request, void *ar\n> > > >       case VIDIOC_DQBUF:\n> > > >               ret = vidioc_dqbuf(file, static_cast<struct\n> v4l2_buffer *>(arg), &proxyMutex_);\n> > > >               break;\n> > > > +     case VIDIOC_EXPBUF:\n> > > > +             ret = vidioc_expbuf(file, static_cast<struct\n> 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\n> b/src/v4l2/v4l2_camera_proxy.h\n> > > > index fa0a49e0439b..14e027c3e7d1 100644\n> > > > --- a/src/v4l2/v4l2_camera_proxy.h\n> > > > +++ b/src/v4l2/v4l2_camera_proxy.h\n> > > > @@ -60,6 +60,7 @@ private:\n> > > >       int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n> > > >       int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> > > >                        libcamera::Mutex *lock)\n> LIBCAMERA_TSA_REQUIRES(*lock);\n> > > > +     int vidioc_expbuf(V4L2CameraFile *file, struct\n> 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\n\n\n>\nRegards,\nVedant Paranjape","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 DAB21BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  8 Jan 2022 14:04:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2EF1160868;\n\tSat,  8 Jan 2022 15:04:32 +0100 (CET)","from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com\n\t[IPv6:2607:f8b0:4864:20::b2c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D25D604F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  8 Jan 2022 15:04:30 +0100 (CET)","by mail-yb1-xb2c.google.com with SMTP id m6so14750269ybc.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 08 Jan 2022 06:04:30 -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=\"pvPhJThp\"; 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=A9D4MwZ6S+ZPBw9CNOgVEOZ9NUYWiqhIEVXUJ52f1sU=;\n\tb=pvPhJThpL3DpYhp9cDpZy9xY1d6gEO1NhWiOUIcnJvBQOag9l4pG8sqxDZQ+M5QOH3\n\tsEct/EelKanm4EB8Lr5QVJCNNy7UhKKRAfik4lTcye7rNvWcieWB6Ad0Ksy+1yvEqBhi\n\tgU+fn1ziRCKhbkI3qxcymcR3K8ERfogTdeQ57RRouMuLsfTAowUiH+vufa/U6zQvWJB+\n\tmu/yRhWtgXZGR+O1W3ZKHCxXW47CbChPxPt7W71PoAjPDtoGT73Pcko9reTcex4kSpO4\n\t8Ha7EOlvlSqeAqxjrQoNZ9iZrBvYZgF8iVeFntpjfMUX6gqTXP4aGup8XtEFw8eT5Ozq\n\tb9UQ==","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=A9D4MwZ6S+ZPBw9CNOgVEOZ9NUYWiqhIEVXUJ52f1sU=;\n\tb=s4HFjpDJCCBa1KkH1IVfiJuGLly4jpl9EHSrUaBQKn5kQlXJsCmzhft/0MXK7k5TeJ\n\tnPlSlN/ucWjE8akQXZBQ2QQZxqtn/jsBrtG03kDi7IhALJg/dMsHDyYkA+qF4FDnIpA4\n\tnPpv5WQ2hV/zM0oi3tJoHe7Ejh00mHGJjyTzxfQ5hkJuhxA0rq0NpHD+MAumxrh15eIF\n\t60g3/8sHMICyucfUzp1RQpr7kz7kmA5IowMIQVybGXViDaegOQlp+oUjRyyjCT9HYJZJ\n\ty7SlpAINyYo93Bo6MsiN5tTICF1nAJCeobJqvlRdC1CVwdQbF9cocHjwnPg8hVvSSm7x\n\tG14w==","X-Gm-Message-State":"AOAM5310goxd+h8T+QRfWAkA2GqCs9YMixrwTr6bCurB6U3sXR/utMos\n\tOyiilEuFlVqmXEFFA54xD+Y5SqdID593q2m+niDRfTP+","X-Google-Smtp-Source":"ABdhPJwyRsbwdiG+CaGLESR6+R7hLs1MbMiP0NfH0+Lc1JBYLXd8o7IVeMB5YsuVWvX63RWx3gS7KOckMxv5Nfu2640=","X-Received":"by 2002:a25:ab4e:: with SMTP id\n\tu72mr83644979ybi.679.1641650667426; \n\tSat, 08 Jan 2022 06:04:27 -0800 (PST)","MIME-Version":"1.0","References":"<20211228185014.98895-1-vedantparanjape160201@gmail.com>\n\t<Yczi6EbuzVuSRxjj@pendragon.ideasonboard.com>\n\t<CACGrz-NL=o9px-Qhcx=u5-HpaBRqA+eG=zCtZL3ZQFkckREd9g@mail.gmail.com>\n\t<YdmXGpY7F2ZYQuu9@pendragon.ideasonboard.com>","In-Reply-To":"<YdmXGpY7F2ZYQuu9@pendragon.ideasonboard.com>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Sat, 8 Jan 2022 19:34:15 +0530","Message-ID":"<CACGrz-OM0Bepy54_bdE1ypkS-kWt5vD5K3YeAFLAjZo7xN6wmg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000e0977305d512942d\"","Subject":"Re: [libcamera-devel] [PATCH v4] 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>"}}]