[{"id":18879,"web_url":"https://patchwork.libcamera.org/comment/18879/","msgid":"<YRxDk6AyubdYEcwX@pendragon.ideasonboard.com>","date":"2021-08-17T23:17:39","subject":"Re: [libcamera-devel] [RFC PATCH 01/10] libcamera: framebuffer: Add\n\toffset to FrameBuffer::Plane","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Mon, Aug 16, 2021 at 01:31:29PM +0900, Hirokazu Honda wrote:\n> This adds offset to FrameBuffer::Plane. It enables represents V4L2\n> multi-planar format and mapping with MappedFrameBuffer.\n\nThe change is good, but this isn't just about V4L2, especially given\nthat the FrameBuffer class doesn't know if V4L2 or a different API is\nused by the pipeline handler. Could you write this to avoid the V4L2\nreference, or at least to mention is as only an example ? Maybe\nsomething as this:\n\nThis adds offset to FrameBuffer::Plane. It enables representing frame\nbuffers that store planes in the same dmabuf at different offsets, as\nfor instance required by the V4L2 NV12 pixel format.\n\n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  include/libcamera/framebuffer.h |  1 +\n>  src/libcamera/framebuffer.cpp   | 11 ++++++++---\n>  2 files changed, 9 insertions(+), 3 deletions(-)\n> \n> diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h\n> index 28307890..5de3c744 100644\n> --- a/include/libcamera/framebuffer.h\n> +++ b/include/libcamera/framebuffer.h\n> @@ -42,6 +42,7 @@ class FrameBuffer final : public Extensible\n>  public:\n>  \tstruct Plane {\n>  \t\tFileDescriptor fd;\n> +\t\tunsigned int offset;\n>  \t\tunsigned int length;\n>  \t};\n>  \n> diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\n> index 42c73134..1d7d5ea3 100644\n> --- a/src/libcamera/framebuffer.cpp\n> +++ b/src/libcamera/framebuffer.cpp\n> @@ -131,7 +131,7 @@ FrameBuffer::Private::Private()\n>   *\n>   * The static information describes the memory planes that make a frame. The\n>   * planes are specified when creating the FrameBuffer and are expressed as a set\n> - * of dmabuf file descriptors and length.\n> + * of dmabuf file descriptors, offset and length.\n>   *\n>   * The dynamic information is grouped in a FrameMetadata instance. It is updated\n>   * during the processing of a queued capture request, and is valid from the\n> @@ -151,8 +151,8 @@ FrameBuffer::Private::Private()\n>   *\n>   * Planar pixel formats use multiple memory regions to store the different\n>   * colour components of a frame. The Plane structure describes such a memory\n> - * region by a dmabuf file descriptor and a length. A FrameBuffer then\n> - * contains one or multiple planes, depending on the pixel format of the\n> + * region by a dmabuf file descriptor, an offset and a length. A FrameBuffer\n\nI'd write s/offset/offset within the dmabuf/\n\n> + * then contains one or multiple planes, depending on the pixel format of the\n>   * frames it is meant to store.\n\nNow that we have offsets, I think they deserve a bit of a more detailed\nexplanation. How about adding the following paragraphs after the\nfollowing one, just before the todo comment ?\n\n * The offset identifies the location of the plane data from the start of the\n * memory referenced by the dmabuf file descriptor. Multiple planes may be\n * stored in the same dmabuf, in which case they will reference the same dmabuf\n * and different offsets. No two planes may overlap, as specified by their\n * offset and length.\n *\n * \\todo Specify how an application shall decide whether to use a single or\n * multiple dmabufs, based on the camera requirements.\n\n>   *\n>   * To support DMA access, planes are associated with dmabuf objects represented\n\nThere's a todo comment at the end of this documentation block related to\naddition of the offset field. You can drop it.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> @@ -170,6 +170,11 @@ FrameBuffer::Private::Private()\n>   * \\brief The dmabuf file descriptor\n>   */\n>  \n> +/**\n> + * \\var FrameBuffer::Plane::offset\n> + * \\brief The plane offset in bytes\n> +*/\n> +\n>  /**\n>   * \\var FrameBuffer::Plane::length\n>   * \\brief The plane length in bytes","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 CD9F3BD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 Aug 2021 23:17:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E56668894;\n\tWed, 18 Aug 2021 01:17:49 +0200 (CEST)","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 EA9066025D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Aug 2021 01:17:46 +0200 (CEST)","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 5EC65499;\n\tWed, 18 Aug 2021 01:17:46 +0200 (CEST)"],"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=\"q11q9OY1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629242266;\n\tbh=sdvnUU2voxOWVY3VqaUa2mQ1RdDZhfaazsU3RgJeAjs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=q11q9OY1pkuzR+c7+oSuFYW8AeQBD8cd38ofKqrcouF+mjb8NEfJ/YLsWOB6vZxDA\n\t4v3YtfYgjW1MSVXWVtErDWhIrF86O6pd3QmDUc/czLOjr9p4j3QRyaaIO1f+vbrO/V\n\tgcKo1rLxagrQnR+BnH6CVkieSHojliYKW9NLhbzM=","Date":"Wed, 18 Aug 2021 02:17:39 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YRxDk6AyubdYEcwX@pendragon.ideasonboard.com>","References":"<20210816043138.957984-1-hiroh@chromium.org>\n\t<20210816043138.957984-2-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210816043138.957984-2-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [RFC PATCH 01/10] libcamera: framebuffer: Add\n\toffset to FrameBuffer::Plane","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>"}}]