{"id":13502,"url":"https://patchwork.libcamera.org/api/1.1/patches/13502/?format=json","web_url":"https://patchwork.libcamera.org/patch/13502/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210826112539.170694-2-hiroh@chromium.org>","date":"2021-08-26T11:25:31","name":"[libcamera-devel,v3,1/9] libcamera: framebuffer: Add offset to FrameBuffer::Plane","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8a526687ed9b4ada63d6e7b97de99fb9b3cd6b79","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13502/mbox/","series":[{"id":2398,"url":"https://patchwork.libcamera.org/api/1.1/series/2398/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2398","date":"2021-08-26T11:25:30","name":"Add offset to FrameBuffer::Plane","version":3,"mbox":"https://patchwork.libcamera.org/series/2398/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13502/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13502/checks/","tags":{},"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 BB120BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Aug 2021 11:25:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 848D368911;\n\tThu, 26 Aug 2021 13:25:51 +0200 (CEST)","from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com\n\t[IPv6:2607:f8b0:4864:20::102b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A84C6890C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Aug 2021 13:25:48 +0200 (CEST)","by mail-pj1-x102b.google.com with SMTP id\n\tz24-20020a17090acb1800b0018e87a24300so2152968pjt.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Aug 2021 04:25:48 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:a5bc:b3dd:7208:bec1])\n\tby smtp.gmail.com with ESMTPSA id\n\ts29sm3472057pgl.38.2021.08.26.04.25.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 26 Aug 2021 04:25:46 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"n7J7aybe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=wG9z/g9FQd1O8kxRzBe7Lxs5OeUPvX5W5GJCjSV3vmk=;\n\tb=n7J7aybelzfalJnBm0WRp5fldoAN8CG7vh/jDS8PQRB5pfu7yHzUCPbGyfJpgWsUGf\n\trl256/cGVw9tl19J/rpdDLaI8m0TKQNoU9VoR5TCnEqtrKWKdtRH/94wbB8jNjIHZVu0\n\tqtZJMpEtCVwx2W81Cl9egxfK+b75TPyKYt148=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=wG9z/g9FQd1O8kxRzBe7Lxs5OeUPvX5W5GJCjSV3vmk=;\n\tb=WojU+9udjdEhE9LWA8/pPJkeryT1AXDSokHwo/AkOAQVTvKWpOLs31z/zAofKsaHsJ\n\t0GQFL0kIR1E9eSekGzb0Szc7joVJadkS6B4gEOU5OdHVJLZkEOrrUxnoBWjmVv28LXss\n\tIux1lm/7sJ1bKgN7uE4RTvJKnKscugtc5F0pZFlZYc3Fd7rBe+aiybm/2NUq3Wat0vuN\n\t1kxuzPS9GsybcdxIfDAYzGliSu3MEM+F21ytyEAnpPG+RrTd0JxuJwioYaWTqk1N9i1U\n\tpfgw8hHJWWEhDXMZdyJZU5KubKxgAPyJNz4xB0n/2pqWjo7wNHfeVm3GcjgV3frmyWgD\n\t0dhg==","X-Gm-Message-State":"AOAM533QwLt4ipjBRgv4PWWfV9YL+2ymAFKZsMfQajh1Q+ryRwWFUz4g\n\tTzsTGGlWHp5cNsJ19F3VNQGxcriFnGZaMw==","X-Google-Smtp-Source":"ABdhPJx+N+Sxgm8LOJ59FvlLXDK/VbLfTQjn+KwR/2upevWedWwhBsZHriKaAjRrD7QP50bjNwyRZQ==","X-Received":"by 2002:a17:902:c406:b0:12d:d0ff:fb7 with SMTP id\n\tk6-20020a170902c40600b0012dd0ff0fb7mr3184398plk.70.1629977147126; \n\tThu, 26 Aug 2021 04:25:47 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 26 Aug 2021 20:25:31 +0900","Message-Id":"<20210826112539.170694-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.33.0.rc2.250.ged5fa647cd-goog","In-Reply-To":"<20210826112539.170694-1-hiroh@chromium.org>","References":"<20210826112539.170694-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 1/9] libcamera: framebuffer: Add offset\n\tto 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This 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\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/framebuffer.h       |  1 +\n src/libcamera/framebuffer.cpp         | 24 +++++++++++++++++-------\n src/libcamera/ipa_data_serializer.cpp |  5 ++++-\n 3 files changed, 22 insertions(+), 8 deletions(-)","diff":"diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h\nindex 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 \ndiff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex b401c50e..bf7a52ad 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,18 +151,23 @@ 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- * frames it is meant to store.\n+ * region by a dmabuf file descriptor, an offset within the dmabuf and a length.\n+ * A FrameBuffer then contains one or multiple planes, depending on the pixel\n+ * format of the frames it is meant to store.\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  * To support DMA access, planes are associated with dmabuf objects represented\n  * by FileDescriptor handles. The Plane class doesn't handle mapping of the\n  * memory to the CPU, but applications and IPAs may use the dmabuf file\n  * descriptors to map the plane memory with mmap() and access its contents.\n  *\n- * \\todo Once we have a Kernel API which can express offsets within a plane\n- * this structure shall be extended to contain this information. See commit\n- * 83148ce8be55e for initial documentation of this feature.\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 /**\n@@ -170,6 +175,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\ndiff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp\nindex 5b183c70..82ec9b20 100644\n--- a/src/libcamera/ipa_data_serializer.cpp\n+++ b/src/libcamera/ipa_data_serializer.cpp\n@@ -569,6 +569,7 @@ FileDescriptor IPADataSerializer<FileDescriptor>::deserialize(const std::vector<\n  * FrameBuffer::Plane is serialized as:\n  *\n  * 4 byte  - FileDescriptor\n+ * 4 bytes - uint32_t Offset\n  * 4 bytes - uint32_t Length\n  */\n template<>\n@@ -586,6 +587,7 @@ IPADataSerializer<FrameBuffer::Plane>::serialize(const FrameBuffer::Plane &data,\n \tdataVec.insert(dataVec.end(), fdBuf.begin(), fdBuf.end());\n \tfdsVec.insert(fdsVec.end(), fdFds.begin(), fdFds.end());\n \n+\tappendPOD<uint32_t>(dataVec, data.offset);\n \tappendPOD<uint32_t>(dataVec, data.length);\n \n \treturn { dataVec, fdsVec };\n@@ -603,7 +605,8 @@ IPADataSerializer<FrameBuffer::Plane>::deserialize(std::vector<uint8_t>::const_i\n \n \tret.fd = IPADataSerializer<FileDescriptor>::deserialize(dataBegin, dataBegin + 4,\n \t\t\t\t\t\t\t\tfdsBegin, fdsBegin + 1);\n-\tret.length = readPOD<uint32_t>(dataBegin, 4, dataEnd);\n+\tret.offset = readPOD<uint32_t>(dataBegin, 4, dataEnd);\n+\tret.length = readPOD<uint32_t>(dataBegin, 8, dataEnd);\n \n \treturn ret;\n }\n","prefixes":["libcamera-devel","v3","1/9"]}