[{"id":27678,"web_url":"https://patchwork.libcamera.org/comment/27678/","msgid":"<CACGrz-Mk1Q6b__gNSykUZdgXF5E_iVp2rC9MqBv0eyjUePK9xA@mail.gmail.com>","date":"2023-08-21T14:43:55","subject":"Re: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: v4l2 device:\n\tStore buffer info in planes","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"content":"Hello Gabby,\n\nThanks for your patch. This patch looks good to me.\n\nOn Mon, Aug 21, 2023 at 6:40 PM Gabby George <gabbymg94@gmail.com> wrote:\n>\n> To perform a memory mapping using mmap, the MappedFrameBuffer class\n> needs the plane offset and file descriptor information of the frame\n> buffer's plane(s). This information is provided in the response to\n> REQBUF, which happens during buffer allocation. Store the plane offset\n> and file descriptor information in the buffer's plane at the time of\n> allocation.\n>\n> Currently, there is a metadata buffer type (metadata format UVCH) that\n> does not support exporting buffers using EXPBUF, so this should only\n> be done if the buffer type is metadata capture.\n>\n> Signed-off-by: Gabby George <gabbymg94@gmail.com>\n\nReviewed-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 31 +++++++++++++++++++-----------\n>  1 file changed, 20 insertions(+), 11 deletions(-)\n>\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index a72ef64d..e57cb131 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1402,18 +1402,27 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n>\n>         std::vector<FrameBuffer::Plane> planes;\n>         for (unsigned int nplane = 0; nplane < numPlanes; nplane++) {\n> -               UniqueFD fd = exportDmabufFd(buf.index, nplane);\n> -               if (!fd.isValid())\n> -                       return nullptr;\n> -\n>                 FrameBuffer::Plane plane;\n> -               plane.fd = SharedFD(std::move(fd));\n> -               /*\n> -                * V4L2 API doesn't provide dmabuf offset information of plane.\n> -                * Set 0 as a placeholder offset.\n> -                * \\todo Set the right offset once V4L2 API provides a way.\n> -                */\n> -               plane.offset = 0;\n> +\n> +               if (buf.type == V4L2_BUF_TYPE_META_CAPTURE) {\n> +                       /*\n> +                        * Dmabuf fd is not exported for metadata, so store\n> +                        * the offset from the querybuf call and this device's fd.\n> +                        */\n> +                       plane.fd = SharedFD(this->fd());\n> +                       plane.offset = buf.m.offset;\n> +               } else {\n> +                       UniqueFD fd = exportDmabufFd(buf.index, nplane);\n> +                       if (!fd.isValid())\n> +                               return nullptr;\n> +                       plane.fd = SharedFD(std::move(fd));\n> +                       /*\n> +                       * V4L2 API doesn't provide dmabuf offset information of plane.\n> +                       * Set 0 as a placeholder offset.\n> +                       * \\todo Set the right offset once V4L2 API provides a way.\n> +                       */\n> +                       plane.offset = 0;\n> +               }\n>                 plane.length = multiPlanar ? buf.m.planes[nplane].length : buf.length;\n>\n>                 planes.push_back(std::move(plane));\n> --\n> 2.34.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 ABCA2BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Aug 2023 14:44:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2BB161EB0;\n\tMon, 21 Aug 2023 16:44:09 +0200 (CEST)","from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com\n\t[IPv6:2001:4860:4864:20::2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 77E7661E09\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Aug 2023 16:44:08 +0200 (CEST)","by mail-oa1-x2e.google.com with SMTP id\n\t586e51a60fabf-1c4de3b9069so2188240fac.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Aug 2023 07:44:08 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1692629049;\n\tbh=7DsrGTTxqP+vN+FedzDiPzAdK21ILqwbNzveCVB+zK0=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=l1poJrUV0kPUQJICpIlx/jk9YugxHCKQUx299+L/97N4myu37tSvQWpDKYtuSRk5o\n\t3A/sBtVEuweSXPuyognyihcm3/H5zR9arv3igrS1sD6lRqJcbC0Cngs6Fn479jcYaT\n\tgIf+cE9SNRIoVqME+OvTV8RlRCgn6GUPHWdZWxSk3n8VoEV3I7JEKEMtc+RcDNwpKB\n\tHJ+SuUCCVvpmnJVWW8NzUjNDN/h8+/15fVIplNCb51zkSgTsMEPRiyXX2VO7dpFv/K\n\twx3PpmdR4IJZhb8EG4rxANtyWGVFqfc38Lbi2jYOcQAr+dBG3LWGKPFLUpP+CPhf5y\n\tlLrFTon78FlIQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20221208; t=1692629047; x=1693233847;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=H9HSYN9lX6KuHtfRlyUVZxm8kvmuj7+ENw4HKmCrha0=;\n\tb=K+JfZqeel1ghtuynfy/dGME9T2eFj+y5cKddYgwI4M5SVjWeGx94v8CgvWLBbjiwTO\n\tkzPOCsxCusJPrkQ2caADHp+222iEF42qleRY8aAt6Wh64le/pg7vnoaYVyisyL5S6M5D\n\t5f0rjF0wEtgm3DNuk6ExRNutC1ggi66WIihyEWTjWAeqniSP9XGtPUIZeY38U8fDEr4t\n\tOE/WSydhGNdoPS/ZV3tbuPxzk+/30oWqPNy7PzeRAkVmeocAEJvg9t/H65a8Djh6DOM6\n\tb8vUgZwk0dF+lUD+6HsH8dolcEJ6ARUtkMrjT5fuj40Mdx8HA/KbXejiPMXERFM6yAWB\n\tytkg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"K+JfZqee\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1692629047; x=1693233847;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=H9HSYN9lX6KuHtfRlyUVZxm8kvmuj7+ENw4HKmCrha0=;\n\tb=QOMXN3HOFz0L1rhooVFb6NTVGyD5n7tDLIJrV8wQneiAunQjA2aO5H9OSauuSIiSWQ\n\t6NApmqEmQGz9kLBkgbNOIxRIzWtCpSBYfOyJj/GAZqFkVjYtXNm0F7KKudmTvumFfoOt\n\txFJAvOqnIwQnMRI6zRSK95nVHcDplx65c8ttW5VTmR8CN5/x7ts8z+WSNKX/HsbBQHUR\n\tLcccalz++06KxIzWU6jvzmeBGdr0WRHMlPcSWl/Mr71fsG+JqsjnNJjo2uxyMp1vZ6pj\n\tSTbnjVr9uCVcxLLckRNE7QWKZ9OGGLMrprrQuc+fKl9zVdmJvp8vexWr1ChALxMBqm4D\n\tyxKA==","X-Gm-Message-State":"AOJu0YzFSFORGqSKvTlQ243Q+7AaXcPOJV3jZXbqv9B/eM3aa54CRPo7\n\tPJYxU/fCZPqsUzN/fwl4+xtLy0354/l1vvqOR/2XFffg77y4Jg==","X-Google-Smtp-Source":"AGHT+IEtAFs8udJ0Wf262tSfDjeGl+tDesZkdIWdBwaBG945St4oZWvwU1W6sWYMx542O0bRXuraRooXBVaERMMZxn4=","X-Received":"by 2002:a05:6870:7391:b0:1bb:ac7:2e34 with SMTP id\n\tz17-20020a056870739100b001bb0ac72e34mr10282537oam.40.1692629047092;\n\tMon, 21 Aug 2023 07:44:07 -0700 (PDT)","MIME-Version":"1.0","References":"<20230821131039.127370-1-gabbymg94@gmail.com>\n\t<20230821131039.127370-4-gabbymg94@gmail.com>","In-Reply-To":"<20230821131039.127370-4-gabbymg94@gmail.com>","Date":"Mon, 21 Aug 2023 20:13:55 +0530","Message-ID":"<CACGrz-Mk1Q6b__gNSykUZdgXF5E_iVp2rC9MqBv0eyjUePK9xA@mail.gmail.com>","To":"Gabby George <gabbymg94@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: v4l2 device:\n\tStore buffer info in planes","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>","From":"Vedant Paranjape via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27680,"web_url":"https://patchwork.libcamera.org/comment/27680/","msgid":"<169265329616.435850.12483095307488079980@ping.linuxembedded.co.uk>","date":"2023-08-21T21:28:16","subject":"Re: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: v4l2 device:\n\tStore buffer info in planes","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Vedant Paranjape (2023-08-21 15:43:55)\n> Hello Gabby,\n> \n> Thanks for your patch. This patch looks good to me.\n> \n> On Mon, Aug 21, 2023 at 6:40 PM Gabby George <gabbymg94@gmail.com> wrote:\n> >\n> > To perform a memory mapping using mmap, the MappedFrameBuffer class\n> > needs the plane offset and file descriptor information of the frame\n> > buffer's plane(s). This information is provided in the response to\n> > REQBUF, which happens during buffer allocation. Store the plane offset\n> > and file descriptor information in the buffer's plane at the time of\n> > allocation.\n> >\n> > Currently, there is a metadata buffer type (metadata format UVCH) that\n> > does not support exporting buffers using EXPBUF, so this should only\n> > be done if the buffer type is metadata capture.\n> >\n> > Signed-off-by: Gabby George <gabbymg94@gmail.com>\n> \n> Reviewed-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> \n> > ---\n> >  src/libcamera/v4l2_videodevice.cpp | 31 +++++++++++++++++++-----------\n> >  1 file changed, 20 insertions(+), 11 deletions(-)\n> >\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index a72ef64d..e57cb131 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -1402,18 +1402,27 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)\n> >\n> >         std::vector<FrameBuffer::Plane> planes;\n> >         for (unsigned int nplane = 0; nplane < numPlanes; nplane++) {\n> > -               UniqueFD fd = exportDmabufFd(buf.index, nplane);\n> > -               if (!fd.isValid())\n> > -                       return nullptr;\n> > -\n> >                 FrameBuffer::Plane plane;\n> > -               plane.fd = SharedFD(std::move(fd));\n> > -               /*\n> > -                * V4L2 API doesn't provide dmabuf offset information of plane.\n> > -                * Set 0 as a placeholder offset.\n> > -                * \\todo Set the right offset once V4L2 API provides a way.\n> > -                */\n> > -               plane.offset = 0;\n> > +\n> > +               if (buf.type == V4L2_BUF_TYPE_META_CAPTURE) {\n> > +                       /*\n> > +                        * Dmabuf fd is not exported for metadata, so store\n> > +                        * the offset from the querybuf call and this device's fd.\n> > +                        */\n> > +                       plane.fd = SharedFD(this->fd());\n> > +                       plane.offset = buf.m.offset;\n> > +               } else {\n> > +                       UniqueFD fd = exportDmabufFd(buf.index, nplane);\n> > +                       if (!fd.isValid())\n> > +                               return nullptr;\n> > +                       plane.fd = SharedFD(std::move(fd));\n> > +                       /*\n> > +                       * V4L2 API doesn't provide dmabuf offset information of plane.\n\nThis indent is still incorrect.\n /*\n  *\ninstead of \n /*\n *\n\n\n> > +                       * Set 0 as a placeholder offset.\n> > +                       * \\todo Set the right offset once V4L2 API provides a way.\n> > +                       */\n> > +                       plane.offset = 0;\n\nSo are plane.offset's *always* zero ? Does anything else ever set it to\nsomething else? That looks like it signals the same information as\n'usePlaneOffset' to me in that case ?\n\n> > +               }\n> >                 plane.length = multiPlanar ? buf.m.planes[nplane].length : buf.length;\n> >\n> >                 planes.push_back(std::move(plane));\n> > --\n> > 2.34.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 88806BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Aug 2023 21:28:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CAEA4627E0;\n\tMon, 21 Aug 2023 23:28:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A047B61E09\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Aug 2023 23:28:19 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BFD9683F;\n\tMon, 21 Aug 2023 23:27:02 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1692653300;\n\tbh=Rwi2oOhQ7AGLXyRRnsEX+NFCdV13EJ6YY/m9XFpEyt8=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=fRWqirYu+aEwA/3j1ykHVOAKEYVi4L/oWQ869g11zeFBTU8F7pWUSXOTd562ojePK\n\t9taDTdM1oEHtui+X3G2WorsDL/UA86Ds3Fj6j4MUgeU59ZK5Ykpy423sVewLDEACA8\n\tX3sEHmXsS7xiQBAuKoE1AMH81Bu6JbVgbT1E5WZmT+8W12q/4bwmDi+yVJ0X5kXwyb\n\tHk1Gsml8AWsPdQSLXxCdoWys9icE8uwOmVd3PqoTs5hzoCTdFL+n7EVJ6pxJptjVg3\n\t3czIY0yfBqPt21V37vaH6W1L76CClXK+pvGpvSvhb4hSSaI/8wNV5IuKN3KOYe1FkB\n\tOA5RjahkqmWAA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1692653222;\n\tbh=Rwi2oOhQ7AGLXyRRnsEX+NFCdV13EJ6YY/m9XFpEyt8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=OhE91q1hlXYOtSPmORKBtkiuBrBLZ+vONwNmX1Fi8rXBIyBWfYZxF/1CYmcu3uUQh\n\tlZVvftBOojNIL7oaTkzhMxwsRguECJ0OzZWAkcbQ9MZN8lG0tAaCNy59grevX4vNAD\n\tEv4EftaIh6y/5qe9y738wkO+xm7/HvtVIJhLoI2s="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OhE91q1h\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<CACGrz-Mk1Q6b__gNSykUZdgXF5E_iVp2rC9MqBv0eyjUePK9xA@mail.gmail.com>","References":"<20230821131039.127370-1-gabbymg94@gmail.com>\n\t<20230821131039.127370-4-gabbymg94@gmail.com>\n\t<CACGrz-Mk1Q6b__gNSykUZdgXF5E_iVp2rC9MqBv0eyjUePK9xA@mail.gmail.com>","To":"Gabby George <gabbymg94@gmail.com>,\n\tVedant Paranjape <vedantparanjape160201@gmail.com>","Date":"Mon, 21 Aug 2023 22:28:16 +0100","Message-ID":"<169265329616.435850.12483095307488079980@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: v4l2 device:\n\tStore buffer info in planes","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27694,"web_url":"https://patchwork.libcamera.org/comment/27694/","msgid":"<CAJ4q4HiyjwF+_qxVQ=ea-nbi1x4AZDs=aUz2Rf+Y8ykuK0rizQ@mail.gmail.com>","date":"2023-08-27T07:11:25","subject":"Re: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: v4l2 device:\n\tStore buffer info in planes","submitter":{"id":160,"url":"https://patchwork.libcamera.org/api/people/160/","name":"Gabrielle George","email":"gabbymg94@gmail.com"},"content":"On Mon, Aug 21, 2023 at 2:28 PM Kieran Bingham <\nkieran.bingham@ideasonboard.com> wrote:\n\n> Quoting Vedant Paranjape (2023-08-21 15:43:55)\n> > Hello Gabby,\n> >\n> > Thanks for your patch. This patch looks good to me.\n> >\n>\nThanks Vedant!\n\n> > On Mon, Aug 21, 2023 at 6:40 PM Gabby George <gabbymg94@gmail.com>\n> wrote:\n> > >\n> > > To perform a memory mapping using mmap, the MappedFrameBuffer class\n> > > needs the plane offset and file descriptor information of the frame\n> > > buffer's plane(s). This information is provided in the response to\n> > > REQBUF, which happens during buffer allocation. Store the plane offset\n> > > and file descriptor information in the buffer's plane at the time of\n> > > allocation.\n> > >\n> > > Currently, there is a metadata buffer type (metadata format UVCH) that\n> > > does not support exporting buffers using EXPBUF, so this should only\n> > > be done if the buffer type is metadata capture.\n> > >\n> > > Signed-off-by: Gabby George <gabbymg94@gmail.com>\n> >\n> > Reviewed-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> >\n> > > ---\n> > >  src/libcamera/v4l2_videodevice.cpp | 31 +++++++++++++++++++-----------\n> > >  1 file changed, 20 insertions(+), 11 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/v4l2_videodevice.cpp\n> b/src/libcamera/v4l2_videodevice.cpp\n> > > index a72ef64d..e57cb131 100644\n> > > --- a/src/libcamera/v4l2_videodevice.cpp\n> > > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > > @@ -1402,18 +1402,27 @@ std::unique_ptr<FrameBuffer>\n> V4L2VideoDevice::createBuffer(unsigned int index)\n> > >\n> > >         std::vector<FrameBuffer::Plane> planes;\n> > >         for (unsigned int nplane = 0; nplane < numPlanes; nplane++) {\n> > > -               UniqueFD fd = exportDmabufFd(buf.index, nplane);\n> > > -               if (!fd.isValid())\n> > > -                       return nullptr;\n> > > -\n> > >                 FrameBuffer::Plane plane;\n> > > -               plane.fd = SharedFD(std::move(fd));\n> > > -               /*\n> > > -                * V4L2 API doesn't provide dmabuf offset information\n> of plane.\n> > > -                * Set 0 as a placeholder offset.\n> > > -                * \\todo Set the right offset once V4L2 API provides a\n> way.\n> > > -                */\n> > > -               plane.offset = 0;\n> > > +\n> > > +               if (buf.type == V4L2_BUF_TYPE_META_CAPTURE) {\n> > > +                       /*\n> > > +                        * Dmabuf fd is not exported for metadata, so\n> store\n> > > +                        * the offset from the querybuf call and this\n> device's fd.\n> > > +                        */\n> > > +                       plane.fd = SharedFD(this->fd());\n> > > +                       plane.offset = buf.m.offset;\n> > > +               } else {\n> > > +                       UniqueFD fd = exportDmabufFd(buf.index,\n> nplane);\n> > > +                       if (!fd.isValid())\n> > > +                               return nullptr;\n> > > +                       plane.fd = SharedFD(std::move(fd));\n> > > +                       /*\n> > > +                       * V4L2 API doesn't provide dmabuf offset\n> information of plane.\n>\n> This indent is still incorrect.\n>  /*\n>   *\n> instead of\n>  /*\n>  *\n>\n>\n> I will fix it!\n\n> > > +                       * Set 0 as a placeholder offset.\n> > > +                       * \\todo Set the right offset once V4L2 API\n> provides a way.\n> > > +                       */\n> > > +                       plane.offset = 0;\n>\n> So are plane.offset's *always* zero ? Does anything else ever set it to\n> something else? That looks like it signals the same information as\n> 'usePlaneOffset' to me in that case ?\n>\n>\nI looked into this and there are cases in android code where it gets set to\nsomething other than 0, and for multi planar formats it will be set to\nsomething else a few lines down in this function.\n\nI can't easily determine if MappedFrameBuffers would be used in these\nscenarios, but I suspect it could.\n\nHere's why (warning, this is kind of confusing):\nIt does appear that multiplanar code could end up being used for the frame\nbuffer that gets mapped in MappedFrameBuffers in camera_device.cpp.  There\nis a loop that runs through all possible planes and sets the buffer offset\nto what is presumably a non-zero value since the planes would have\ndifferent offsets.\n\nIt seems like the returned frame buffer of that function can end up being\nused in a MappedFrameBuffer constructor  (for example, the one in\nPostProcessorYuv::process, which takes in a buffer that could have been\ncreated using \"createFrameBuffer\") and therefore end up hitting the flagged\ncode, but it's really hard to tell if that would happen in practice.\n\nSaying that, I think this connection makes sense, because if you're\ncreating an mmap-ed address for YUV data which is what\nPostProcessorYuv::process appears to do, you would be using multiple planes\nand therefore would need to make use of the (non-zero) offset.\n\nI'll keep thinking about ways to possibly get rid of the usePlaneOffset\nflag, but I'm not sure just assuming that plane offset will always be 0\nunless we're dealing with metadata won't break something.\n\n> > > +               }\n> > >                 plane.length = multiPlanar ?\n> buf.m.planes[nplane].length : buf.length;\n> > >\n> > >                 planes.push_back(std::move(plane));\n> > > --\n> > > 2.34.1\n> > >\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 0C956BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 27 Aug 2023 07:11:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 48E18627E0;\n\tSun, 27 Aug 2023 09:11:40 +0200 (CEST)","from mail-ed1-x529.google.com (mail-ed1-x529.google.com\n\t[IPv6:2a00:1450:4864:20::529])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 805C961E03\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Aug 2023 09:11:38 +0200 (CEST)","by mail-ed1-x529.google.com with SMTP id\n\t4fb4d7f45d1cf-5298e43bb67so4681217a12.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Aug 2023 00:11:38 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1693120300;\n\tbh=FIi5Q6G73OdgIgdsxUrcFZDlbLr2iBneXY8T7Tgwnu4=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=wLmxAPxES1/vjtl2mEsWMIH2iPTNvL/5+1Px7bLLbTpaUO0bM3H1bs+a2cRwt6Js6\n\tPAE0gzGYbD2RMZZ+8GpPGjmWLtSzUd/L71l1TiZjnL0Jsu2unTgJbIiqe2mr93bp5z\n\tjVXJcoH9QGqqYBbEgPL36PHFjWX7doORi+BsEe/QtH1h0+flwKfzz02im59RuhZtDU\n\t2KMzTEc5Ah1yQTwSLRMBhZwG3jNyZMW6Ct3LNdjO4Mu2E056kIJL0FJunesq3ANsdK\n\tVBocQlbL3L7ynN7dfACD3wfHdGAz1e2uG6JTMVTocvhN8o58XHcUg3qHfZSpRColud\n\t+aWllX7BgMyAA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20221208; t=1693120298; x=1693725098;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=WNp7q3IcndHV/DNLwHKnOyMfdW/XAczFRKZ5sHQgXe8=;\n\tb=cnzWo7LJtWJM390N/lq/KsVVI9hIhtQ4J4WHe2dmXb5uosYD2H3ajGd5+KfJpxsh+h\n\tH/7OnufCjfs4VhEO+JPFZ1WDq1pzSxHoUonNKbiZaBuOkmUHFNCL1UseUjNYB6GYhO6W\n\tQgap5grDonj8BDZzYZo2l9juolLWXn1Zg2fY9FH/b08GwjYWvsPzaRKufORTD/nvbBTG\n\tdqG6p+yMil9ep064eZuvphnxHhCzHrvkOKXJt0tlIfB9YnNRyv52aykJF5H/fGPTe735\n\t2GcyxJUFKpBKMYJBrn6CAUjBhuDOKHdEcJSeUIMSJ7LBbafKFY1vpp0fi6fT6OugBLNu\n\t9JYw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"cnzWo7LJ\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1693120298; x=1693725098;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=WNp7q3IcndHV/DNLwHKnOyMfdW/XAczFRKZ5sHQgXe8=;\n\tb=b85aJqO8ZSGUFkMiV3j4+z2OrWG0DWgsMwX90RmyqxJzs/gL2fJgocdftiGwuHQ6T+\n\tUZbedFV1yf9lYmtwBmPmoOsRps4FlEW7QM1Mh35vJqjumAuomTnMke4/sKjry5nkNY4F\n\tmBXgSF451soOflT24fD2WodxaJe6WAiJBNbtmZ2pMQc/R0wtS0+7dCJpBcjFToFiUF0/\n\ti8S7BRtpVj9GaThgoLNvQWLZ0Q/OMiD+S8+OfN9pcOpzlMlHT7e0ckBwEKP3O8g3Tt2L\n\tEslK7fA9p4t+P4fEsSmEQ/KCRo9wLZXk9sxhRIoGhPZyKVSN+YFhNjQYFvrDqKYg7UfA\n\tI0Tg==","X-Gm-Message-State":"AOJu0YwXrx1YYXyPj5DY5IxhyENxCPkiZ29vLpJ20he9rM97xl7BfmEW\n\tRNjQB05pKW/2t9OEIOUvln4FSHOaO/ldEfHYDh8In/+E/5g=","X-Google-Smtp-Source":"AGHT+IEmiMdhc4WHwG4y+S7SDV6DHCfdUj6p8s9i/p0gLYZJbKjByqbUIjLMGmyBjxPwR114aYklak+rgXSsSeguuwo=","X-Received":"by 2002:aa7:d297:0:b0:522:2add:5841 with SMTP id\n\tw23-20020aa7d297000000b005222add5841mr24419959edq.7.1693120297308;\n\tSun, 27 Aug 2023 00:11:37 -0700 (PDT)","MIME-Version":"1.0","References":"<20230821131039.127370-1-gabbymg94@gmail.com>\n\t<20230821131039.127370-4-gabbymg94@gmail.com>\n\t<CACGrz-Mk1Q6b__gNSykUZdgXF5E_iVp2rC9MqBv0eyjUePK9xA@mail.gmail.com>\n\t<169265329616.435850.12483095307488079980@ping.linuxembedded.co.uk>","In-Reply-To":"<169265329616.435850.12483095307488079980@ping.linuxembedded.co.uk>","Date":"Sun, 27 Aug 2023 00:11:25 -0700","Message-ID":"<CAJ4q4HiyjwF+_qxVQ=ea-nbi1x4AZDs=aUz2Rf+Y8ykuK0rizQ@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"000000000000e214870603e24951\"","Subject":"Re: [libcamera-devel] [RFC PATCH v2 3/5] libcamera: v4l2 device:\n\tStore buffer info in planes","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>","From":"Gabrielle George via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Gabrielle George <gabbymg94@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tVedant Paranjape <vedantparanjape160201@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]