[{"id":21380,"web_url":"https://patchwork.libcamera.org/comment/21380/","msgid":"<YaVoxlRIYJL0UkCx@pendragon.ideasonboard.com>","date":"2021-11-29T23:56:54","subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF 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 Tue, Nov 30, 2021 at 01:10:31AM +0530, Vedant Paranjape wrote:\n> To support importing DMABUF, we need to reqbufs with DMABUF mode.\n> \n> This patch enables using V4L2_MEMORY_DMABUF as one of the memory types\n> in vidioc_reqbuf to initialise DMA Buffer I/O\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 | 14 ++++++++++----\n>  1 file changed, 10 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index f194e06345b7..c8861a531399 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -160,7 +160,8 @@ bool V4L2CameraProxy::validateBufferType(uint32_t type)\n>  \n>  bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n>  {\n> -\treturn memory == V4L2_MEMORY_MMAP;\n> +\treturn (memory == V4L2_MEMORY_MMAP) ||\n> +\t\t\t  (memory == V4L2_MEMORY_DMABUF);\n\nhttps://git.libcamera.org/libcamera/libcamera.git/tree/Documentation/coding-style.rst#n421\n\n>  }\n>  \n>  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n> @@ -468,7 +469,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n>  \tif (!hasOwnership(file) && owner_)\n>  \t\treturn -EBUSY;\n>  \n> -\targ->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;\n> +\targ->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP |\n> +\t\t\t\t\t\t   V4L2_BUF_CAP_SUPPORTS_DMABUF;\n>  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n>  \n>  \tif (arg->count == 0) {\n> @@ -511,11 +513,15 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n>  \t\tstruct v4l2_buffer buf = {};\n>  \t\tbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n>  \t\tbuf.length = v4l2PixFormat_.sizeimage;\n> -\t\tbuf.memory = V4L2_MEMORY_MMAP;\n> -\t\tbuf.m.offset = i * v4l2PixFormat_.sizeimage;\n> +\t\tbuf.memory = arg->memory;\n>  \t\tbuf.index = i;\n>  \t\tbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n>  \n> +\t\tif (arg->memory == V4L2_MEMORY_MMAP)\n> +\t\t\tbuf.m.offset = i * v4l2PixFormat_.sizeimage;\n> +\t\telse if (arg->memory == V4L2_MEMORY_DMABUF)\n> +\t\t\tbuf.m.fd = vcam_->getBufferFd(i).fd();\n\nThis isn't right. Please test this patch with a V4L2 application that\nuses the device in DMABUF mode.\n\n> +\n>  \t\tbuffers_[i] = buf;\n>  \t}\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 12C1EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Nov 2021 23:57:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A68C605A4;\n\tTue, 30 Nov 2021 00:57:20 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 49D79604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 00:57:19 +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 A9BE38F0;\n\tTue, 30 Nov 2021 00:57:18 +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=\"fXgy0Wk3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638230239;\n\tbh=IH0f2nyHGopa73D1YenOVY78mPcidRgdPU51eB/BJwc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fXgy0Wk3qK7jzhjGy1dhGE4AhkVD5cXJfm1zvPTYEwiPpI7jsLkkxqk01gSXA+Bei\n\tAcVUmaFyxAqXeJ/xCYGmfDKbEHQqFoA+vo5sE+uNta2CMcWVVvVvpSp6UR9Z/ZD84h\n\tActKmtTtx66FHVKan/ePaxdrADFtVHYHQg+6Mlo8=","Date":"Tue, 30 Nov 2021 01:56:54 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<YaVoxlRIYJL0UkCx@pendragon.ideasonboard.com>","References":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF 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":21386,"web_url":"https://patchwork.libcamera.org/comment/21386/","msgid":"<20211130020643.GA3297112@pyrite.rasen.tech>","date":"2021-11-30T02:06:43","subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF ioctl","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Vedant,\n\nOn Tue, Nov 30, 2021 at 01:10:31AM +0530, Vedant Paranjape wrote:\n> To support importing DMABUF, we need to reqbufs with DMABUF mode.\n> \n> This patch enables using V4L2_MEMORY_DMABUF as one of the memory types\n> in vidioc_reqbuf to initialise DMA Buffer I/O\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 | 14 ++++++++++----\n>  1 file changed, 10 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index f194e06345b7..c8861a531399 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -160,7 +160,8 @@ bool V4L2CameraProxy::validateBufferType(uint32_t type)\n>  \n>  bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n>  {\n> -\treturn memory == V4L2_MEMORY_MMAP;\n> +\treturn (memory == V4L2_MEMORY_MMAP) ||\n> +\t\t\t  (memory == V4L2_MEMORY_DMABUF);\n\nThis is going to cause problems with expbuf if your memory type is\ndmabuf.\n\n\nPaul\n\n>  }\n>  \n>  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n> @@ -468,7 +469,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n>  \tif (!hasOwnership(file) && owner_)\n>  \t\treturn -EBUSY;\n>  \n> -\targ->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;\n> +\targ->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP |\n> +\t\t\t\t\t\t   V4L2_BUF_CAP_SUPPORTS_DMABUF;\n>  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n>  \n>  \tif (arg->count == 0) {\n> @@ -511,11 +513,15 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n>  \t\tstruct v4l2_buffer buf = {};\n>  \t\tbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n>  \t\tbuf.length = v4l2PixFormat_.sizeimage;\n> -\t\tbuf.memory = V4L2_MEMORY_MMAP;\n> -\t\tbuf.m.offset = i * v4l2PixFormat_.sizeimage;\n> +\t\tbuf.memory = arg->memory;\n>  \t\tbuf.index = i;\n>  \t\tbuf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n>  \n> +\t\tif (arg->memory == V4L2_MEMORY_MMAP)\n> +\t\t\tbuf.m.offset = i * v4l2PixFormat_.sizeimage;\n> +\t\telse if (arg->memory == V4L2_MEMORY_DMABUF)\n> +\t\t\tbuf.m.fd = vcam_->getBufferFd(i).fd();\n> +\n>  \t\tbuffers_[i] = buf;\n>  \t}\n>  \n> -- \n> 2.25.1\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 30BE2BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 02:06:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6AE87605B4;\n\tTue, 30 Nov 2021 03:06:52 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 40BBF604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 03:06:51 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C6DCB2A5;\n\tTue, 30 Nov 2021 03:06:49 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"cQenj0QL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638238010;\n\tbh=TtuFpxVADsdVxtw9H8sPH60Vy9n2zqOfKlBnlBKLMA0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=cQenj0QLxBzMSCzjcop3MlvcorkdwmFVsrULpF/GItu6hAiqlztpGPU/DfOAeGVZ/\n\tGKodNV1BAS4hcog+4Y3E3DvmIK4rgFFf3MjrEr/XcT+CZTODhoHyX3jyj1dLMoUrL4\n\t/sgdT01ewb4mgYgE25lXLBZTwjhec/fxVEgqfcR8=","Date":"Tue, 30 Nov 2021 11:06:43 +0900","From":"paul.elder@ideasonboard.com","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<20211130020643.GA3297112@pyrite.rasen.tech>","References":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF 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":21413,"web_url":"https://patchwork.libcamera.org/comment/21413/","msgid":"<CACGrz-MmUJ8LAvCPF3rB3DRDd=+q--O4Ttoj2vAqr8+B=vOx0g@mail.gmail.com>","date":"2021-11-30T06:50:30","subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF ioctl","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hi Laurent,\n\nOn Tue, Nov 30, 2021 at 5:27 AM Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Vedant,\n>\n> On Tue, Nov 30, 2021 at 01:10:31AM +0530, Vedant Paranjape wrote:\n> > To support importing DMABUF, we need to reqbufs with DMABUF mode.\n> >\n> > This patch enables using V4L2_MEMORY_DMABUF as one of the memory types\n> > in vidioc_reqbuf to initialise DMA Buffer I/O\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 | 14 ++++++++++----\n> >  1 file changed, 10 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index f194e06345b7..c8861a531399 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -160,7 +160,8 @@ bool V4L2CameraProxy::validateBufferType(uint32_t type)\n> >\n> >  bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n> >  {\n> > -     return memory == V4L2_MEMORY_MMAP;\n> > +     return (memory == V4L2_MEMORY_MMAP) ||\n> > +                       (memory == V4L2_MEMORY_DMABUF);\n>\n> https://git.libcamera.org/libcamera/libcamera.git/tree/Documentation/coding-style.rst#n421\n\nThere's a bug in checkstyle, that's why I had to ignore it on this\none. Checkstyle was changing some irrelevant part of the code too.\nSo, I manually tried to fix this, but checkstyle still won't budge. I\nhave setup the script long back :)\n\n>\n> >  }\n> >\n> >  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n> > @@ -468,7 +469,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n> >       if (!hasOwnership(file) && owner_)\n> >               return -EBUSY;\n> >\n> > -     arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;\n> > +     arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP |\n> > +                                                V4L2_BUF_CAP_SUPPORTS_DMABUF;\n> >       memset(arg->reserved, 0, sizeof(arg->reserved));\n> >\n> >       if (arg->count == 0) {\n> > @@ -511,11 +513,15 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n> >               struct v4l2_buffer buf = {};\n> >               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n> >               buf.length = v4l2PixFormat_.sizeimage;\n> > -             buf.memory = V4L2_MEMORY_MMAP;\n> > -             buf.m.offset = i * v4l2PixFormat_.sizeimage;\n> > +             buf.memory = arg->memory;\n> >               buf.index = i;\n> >               buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n> >\n> > +             if (arg->memory == V4L2_MEMORY_MMAP)\n> > +                     buf.m.offset = i * v4l2PixFormat_.sizeimage;\n> > +             else if (arg->memory == V4L2_MEMORY_DMABUF)\n> > +                     buf.m.fd = vcam_->getBufferFd(i).fd();\n>\n> This isn't right. Please test this patch with a V4L2 application that\n> uses the device in DMABUF mode.\n\nOkay, I'll do so.\n\n>\n> > +\n> >               buffers_[i] = buf;\n> >       }\n> >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 9B9A5BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 06:50:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D38E3605B7;\n\tTue, 30 Nov 2021 07:50:44 +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 0B23B604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 07:50:43 +0100 (CET)","by mail-yb1-xb34.google.com with SMTP id g17so49554874ybe.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 22:50:42 -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=\"H06lC36t\"; 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=JqqDTbACgRAtK0CEn+MtLDfjCYjZBVU0Lp2gsFeNd+A=;\n\tb=H06lC36tTZIJR/Dy6f0US+UWHLESzuI84UtlPAJ/QELdJnrMfCjby05mnQFnq9wBxL\n\th5kODh7yoxe8JcSti8jpl9i+GUORZ6auXriYsUWo/9mjeiKGtOesznKC5UHMop5LmX32\n\tG6h8B38SPzklWBrg860cDI8F1mTxhYgtlEm1IRATUDEg/L09J8FbBK818EcbfgW7Fh/p\n\tJcwdzuctvaov/3ufYyktRCuLB3Vxb4sgRlRL/MvBCTt/aPksRU0SM52GSDxYwJipTyQw\n\tS0Ye7a/NtEkJjxRxE2x3yd4Qb/IqYaBPnInTPVCgqCAktOTb1Nv2YcfIZYHRWToOf3eu\n\td2hw==","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=JqqDTbACgRAtK0CEn+MtLDfjCYjZBVU0Lp2gsFeNd+A=;\n\tb=UbiZnCImJ/4eLoMzihg2Iviqi4q9utyLYW/kk9Q9fC46gVe4Hh2j4iW8dKvXruXVTr\n\tf3Gkck6L23pa3lYD7KJZMkL2XCLssYjnq8azi3A+e9BFDj1k7nYidtF0otUVb31HRaBq\n\t8Cut7IxT56SYtnzrrqBIkGk1LMNhcpV8zUjhaaCpBAYdla3xaGXExrUlwj9sL8acpgyz\n\tquqxaVNkZgS7MZN6+/11hGgfyzW3GDwEw9YN7BwazZph61Jn2rsmtgFTt7Ju4RMksIs9\n\tO71V1Dx8w1gYmGT2/Xrw2c0Yin/a0tZu53f6KkJfNaGgzsgbIWwciBejYnLEkuHolqWk\n\tFNcw==","X-Gm-Message-State":"AOAM532bniDJ4/KbuttEhnSCyn91Yftcqh2HWztNWDQdk+5bH9uAQgAG\n\tu/NWWM93TBv3Y2bTv9rFTaN2PpKKwow7CEn698CtRn24NUUXnQ==","X-Google-Smtp-Source":"ABdhPJzCBgkoZcYxw+W78s2g28drtMIYC+SQoLIGhaz7yqpxr/w+DLEMdPobztQW/XgZVfM+feIOJyrd+M0Msgs3qiQ=","X-Received":"by 2002:a25:ba0e:: with SMTP id\n\tt14mr10818688ybg.49.1638255041573; \n\tMon, 29 Nov 2021 22:50:41 -0800 (PST)","MIME-Version":"1.0","References":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>\n\t<YaVoxlRIYJL0UkCx@pendragon.ideasonboard.com>","In-Reply-To":"<YaVoxlRIYJL0UkCx@pendragon.ideasonboard.com>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Tue, 30 Nov 2021 12:20:30 +0530","Message-ID":"<CACGrz-MmUJ8LAvCPF3rB3DRDd=+q--O4Ttoj2vAqr8+B=vOx0g@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF 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":21414,"web_url":"https://patchwork.libcamera.org/comment/21414/","msgid":"<CACGrz-MdLnwvWE+MnYYB3ZBqseGR-s255FvoKgyk5TXPPDMD=g@mail.gmail.com>","date":"2021-11-30T06:53:19","subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF ioctl","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hi Paul,\n\nOn Tue, Nov 30, 2021 at 7:36 AM <paul.elder@ideasonboard.com> wrote:\n>\n> Hi Vedant,\n>\n> On Tue, Nov 30, 2021 at 01:10:31AM +0530, Vedant Paranjape wrote:\n> > To support importing DMABUF, we need to reqbufs with DMABUF mode.\n> >\n> > This patch enables using V4L2_MEMORY_DMABUF as one of the memory types\n> > in vidioc_reqbuf to initialise DMA Buffer I/O\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 | 14 ++++++++++----\n> >  1 file changed, 10 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index f194e06345b7..c8861a531399 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -160,7 +160,8 @@ bool V4L2CameraProxy::validateBufferType(uint32_t type)\n> >\n> >  bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n> >  {\n> > -     return memory == V4L2_MEMORY_MMAP;\n> > +     return (memory == V4L2_MEMORY_MMAP) ||\n> > +                       (memory == V4L2_MEMORY_DMABUF);\n>\n> This is going to cause problems with expbuf if your memory type is\n> dmabuf.\n\nI am not sure what needs to be done for importing dmabuf then, according to this\nhttps://www.kernel.org/doc/html/v5.3/media/uapi/v4l/dmabuf.html#example-queueing-dmabuf-using-single-plane-api\n\nWhat do you suggest ?\n\n>\n>\n> Paul\n>\n> >  }\n> >\n> >  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n> > @@ -468,7 +469,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n> >       if (!hasOwnership(file) && owner_)\n> >               return -EBUSY;\n> >\n> > -     arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;\n> > +     arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP |\n> > +                                                V4L2_BUF_CAP_SUPPORTS_DMABUF;\n> >       memset(arg->reserved, 0, sizeof(arg->reserved));\n> >\n> >       if (arg->count == 0) {\n> > @@ -511,11 +513,15 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n> >               struct v4l2_buffer buf = {};\n> >               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n> >               buf.length = v4l2PixFormat_.sizeimage;\n> > -             buf.memory = V4L2_MEMORY_MMAP;\n> > -             buf.m.offset = i * v4l2PixFormat_.sizeimage;\n> > +             buf.memory = arg->memory;\n> >               buf.index = i;\n> >               buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n> >\n> > +             if (arg->memory == V4L2_MEMORY_MMAP)\n> > +                     buf.m.offset = i * v4l2PixFormat_.sizeimage;\n> > +             else if (arg->memory == V4L2_MEMORY_DMABUF)\n> > +                     buf.m.fd = vcam_->getBufferFd(i).fd();\n> > +\n> >               buffers_[i] = buf;\n> >       }\n> >\n> > --\n> > 2.25.1\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 03D38BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 06:53:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3967E605B4;\n\tTue, 30 Nov 2021 07:53:33 +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 ED830604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 07:53:31 +0100 (CET)","by mail-yb1-xb2d.google.com with SMTP id e136so49563013ybc.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 22:53:31 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"lmzOt10d\"; 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=HQgCCTcyPdgzuadHCCxzODad1HdPUX6+J1zwK2bQ5po=;\n\tb=lmzOt10doO9cD/PTYrNcy1moBIW6R9Bzuj+m1m7mhu63gL0M8q+iqa63dyAFKpPoiY\n\trb4Ph1+KEC7wpXcOvv5n2RYJd5YkFx8GPF8A1J1dYWd1/ZUpR41LmAA5J2y27iY/cGQf\n\tARjhTab3wKf4j6zuALQTIeUH69FlJnxzQ8LvXqw+CGaI5RxWM3LbhZN0O73fgQFFm7wi\n\twyx2wrnIyq8TNZJFscP26FLYiSUu7B5PIw/WJFMQqMHVrj1imlHm1DLRpPV9JKRB7PSS\n\tkMWgfIMApWVWgHuzIZ+Lu6F0wk9vFDUoOKGv5SeFN9k5sMg5xaIhQs5X8H1X9HFtzswS\n\trrNQ==","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=HQgCCTcyPdgzuadHCCxzODad1HdPUX6+J1zwK2bQ5po=;\n\tb=rMIGMez0oJyFaQ+IEomxSXnaZLmrsjbq0UBwtvpKDs5XqyzWQinhRIBejGwNp6yigr\n\t44BGyRvnAC6/mMBhYCexGpyKrrRz9vt2sPdPmgUaGzO+gRqHVjo1ckmoKIQCGRuP6wEQ\n\tkCsXIoe7uvfEdtso4uL+GKUDpwfc8CIb0Mgkq9X4ug6PZ5+gA38WPWGtWEQyIPaIgcVs\n\tJ6+89CPEw6XAYrkrd0/Mfp3Q9PYPbtcPJlGl67xSDRZlUTXxc8eyCMUSsQEJwn244e07\n\tUcVNgIYh57OndNlisuQVSAH+Xy/JpbzJti9i2S7viTqGsspK9KSNJQHfCvdBY5FhSPaN\n\tuSfQ==","X-Gm-Message-State":"AOAM530xDNzBp9MFzNeFdi7Dwy8ovCj5D2DiJ+sONFiW7KBpGhkGQ3rf\n\tR3sj71QbnihYL8ne/Jad53zkP3l1IUpEJbYSVVA8CxuSKxShY71/","X-Google-Smtp-Source":"ABdhPJzeQb0FeSFXy91uEZT60rZveOUuLiZT1WUVU+6GKkxOFIxYQDBalcZ40cgPa/edkmnTtHn9ASByOqudc7OiWaU=","X-Received":"by 2002:a25:a064:: with SMTP id\n\tx91mr11343286ybh.607.1638255210674; \n\tMon, 29 Nov 2021 22:53:30 -0800 (PST)","MIME-Version":"1.0","References":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>\n\t<20211130020643.GA3297112@pyrite.rasen.tech>","In-Reply-To":"<20211130020643.GA3297112@pyrite.rasen.tech>","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Tue, 30 Nov 2021 12:23:19 +0530","Message-ID":"<CACGrz-MdLnwvWE+MnYYB3ZBqseGR-s255FvoKgyk5TXPPDMD=g@mail.gmail.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF 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":21416,"web_url":"https://patchwork.libcamera.org/comment/21416/","msgid":"<20211130070458.GB3297112@pyrite.rasen.tech>","date":"2021-11-30T07:04:58","subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF ioctl","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Tue, Nov 30, 2021 at 12:23:19PM +0530, Vedant Paranjape wrote:\n> Hi Paul,\n> \n> On Tue, Nov 30, 2021 at 7:36 AM <paul.elder@ideasonboard.com> wrote:\n> >\n> > Hi Vedant,\n> >\n> > On Tue, Nov 30, 2021 at 01:10:31AM +0530, Vedant Paranjape wrote:\n> > > To support importing DMABUF, we need to reqbufs with DMABUF mode.\n> > >\n> > > This patch enables using V4L2_MEMORY_DMABUF as one of the memory types\n> > > in vidioc_reqbuf to initialise DMA Buffer I/O\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 | 14 ++++++++++----\n> > >  1 file changed, 10 insertions(+), 4 deletions(-)\n> > >\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > index f194e06345b7..c8861a531399 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > @@ -160,7 +160,8 @@ bool V4L2CameraProxy::validateBufferType(uint32_t type)\n> > >\n> > >  bool V4L2CameraProxy::validateMemoryType(uint32_t memory)\n> > >  {\n> > > -     return memory == V4L2_MEMORY_MMAP;\n> > > +     return (memory == V4L2_MEMORY_MMAP) ||\n> > > +                       (memory == V4L2_MEMORY_DMABUF);\n> >\n> > This is going to cause problems with expbuf if your memory type is\n> > dmabuf.\n> \n> I am not sure what needs to be done for importing dmabuf then, according to this\n> https://www.kernel.org/doc/html/v5.3/media/uapi/v4l/dmabuf.html#example-queueing-dmabuf-using-single-plane-api\n\nWell the issue with importing isn't here, it's the hunk below, which\nLaurent has reviewed (and we're discussing now on irc).\n\nThe issue here is that the memory type validator needs to be expanded.\nexpbuf for example should error out if the device is configured for\ndmabuf. You'll have to check the docs for the other ioctls.\n\n> \n> What do you suggest ?\n\nYou can come up with a design/patch, and we can discuss it.\n\n\nPaul\n\n> \n> >\n> > >  }\n> > >\n> > >  void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig)\n> > > @@ -468,7 +469,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n> > >       if (!hasOwnership(file) && owner_)\n> > >               return -EBUSY;\n> > >\n> > > -     arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP;\n> > > +     arg->capabilities = V4L2_BUF_CAP_SUPPORTS_MMAP |\n> > > +                                                V4L2_BUF_CAP_SUPPORTS_DMABUF;\n> > >       memset(arg->reserved, 0, sizeof(arg->reserved));\n> > >\n> > >       if (arg->count == 0) {\n> > > @@ -511,11 +513,15 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf\n> > >               struct v4l2_buffer buf = {};\n> > >               buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n> > >               buf.length = v4l2PixFormat_.sizeimage;\n> > > -             buf.memory = V4L2_MEMORY_MMAP;\n> > > -             buf.m.offset = i * v4l2PixFormat_.sizeimage;\n> > > +             buf.memory = arg->memory;\n> > >               buf.index = i;\n> > >               buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n> > >\n> > > +             if (arg->memory == V4L2_MEMORY_MMAP)\n> > > +                     buf.m.offset = i * v4l2PixFormat_.sizeimage;\n> > > +             else if (arg->memory == V4L2_MEMORY_DMABUF)\n> > > +                     buf.m.fd = vcam_->getBufferFd(i).fd();\n> > > +\n> > >               buffers_[i] = buf;\n> > >       }\n> > >\n> > > --\n> > > 2.25.1\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 BBC7DBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 07:05:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B699605B4;\n\tTue, 30 Nov 2021 08:05:07 +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 AEB94604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 08:05:05 +0100 (CET)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 46D028F0;\n\tTue, 30 Nov 2021 08:05:04 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XyXKdCq6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638255905;\n\tbh=51rGn/0C2+aO9JjKM775QPRetf6m7ZdXSrcpccbJhWg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XyXKdCq6JsGwSwvz6gw62xa+ZcUrae7C3A+z423F6y0YG8SUf9kDugbYYXOIWrhAj\n\twgxBeppdMHC7QBydb5/iCnuRqjSm32u9fiWJoda/SlnNHGvkT5LBswzoufhR2JviHd\n\tg0glsnMae9VFLcyr4abpKHqB2/wY4N2yYul/yr/8=","Date":"Tue, 30 Nov 2021 16:04:58 +0900","From":"paul.elder@ideasonboard.com","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<20211130070458.GB3297112@pyrite.rasen.tech>","References":"<20211129194031.1340933-1-vedantparanjape160201@gmail.com>\n\t<20211130020643.GA3297112@pyrite.rasen.tech>\n\t<CACGrz-MdLnwvWE+MnYYB3ZBqseGR-s255FvoKgyk5TXPPDMD=g@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<CACGrz-MdLnwvWE+MnYYB3ZBqseGR-s255FvoKgyk5TXPPDMD=g@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v1] v4l2: V4L2CameraProxy: Add support\n\tfor DMABUF buffer I/O in REQBUF 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>"}}]