Patch Detail
Show a patch.
GET /api/patches/20739/?format=api
{ "id": 20739, "url": "https://patchwork.libcamera.org/api/patches/20739/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20739/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240801073339.4061027-2-chenghaoyang@google.com>", "date": "2024-08-01T07:30:57", "name": "[v7,1/7] libcamera: add DmaBufAllocation::exportFrameBuffers()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "2752b7f420b07ee3f40fe3879522c25a03317e14", "submitter": { "id": 117, "url": "https://patchwork.libcamera.org/api/people/117/?format=api", "name": "Cheng-Hao Yang", "email": "chenghaoyang@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20739/mbox/", "series": [ { "id": 4472, "url": "https://patchwork.libcamera.org/api/series/4472/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4472", "date": "2024-08-01T07:30:56", "name": "Add VirtualPipelineHandler", "version": 7, "mbox": "https://patchwork.libcamera.org/series/4472/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20739/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20739/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 ECDD9BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 1 Aug 2024 07:33:54 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A616C63381;\n\tThu, 1 Aug 2024 09:33:50 +0200 (CEST)", "from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com\n\t[IPv6:2607:f8b0:4864:20::52d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D41C86336E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 1 Aug 2024 09:33:48 +0200 (CEST)", "by mail-pg1-x52d.google.com with SMTP id\n\t41be03b00d2f7-6c5bcb8e8edso5026235a12.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 01 Aug 2024 00:33:48 -0700 (PDT)", "from chenghaoyang-low.c.googlers.com.com\n\t(237.198.80.34.bc.googleusercontent.com. [34.80.198.237])\n\tby smtp.gmail.com with ESMTPSA id\n\td9443c01a7336-1fed7cd3dcbsm131839165ad.73.2024.08.01.00.33.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 01 Aug 2024 00:33:46 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"ml5R8m3m\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1722497627; x=1723102427;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=1CEAOFSE3yro1ER8LBRGSD86TGgGuzI5qgNS96RTubY=;\n\tb=ml5R8m3mmwbOQYI5sbuQuHRodrwvU282+BlC0R4nv8moB5HTuUXASlmrcT2Srau0Ve\n\tJrmnORJQ2Kk9mwg0gSrAxu++RhGR1wEvkM1ElFvQV9s9vjaS0mKe5snifO4mKv/o8W9D\n\teb7A6dFlKg38vITQnaI+iYj0wrSQDx13+aSgc=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1722497627; x=1723102427;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=1CEAOFSE3yro1ER8LBRGSD86TGgGuzI5qgNS96RTubY=;\n\tb=KVdKI3vSv4dUuXSBe0UWpgvrIeBUwvYfNnUSyU7d2x8bLEXZDSvK0Qx+epK9qAWGM7\n\tvUWL2sud5Cc7rbMeP+8WdgjLeCDkBA0JVZ8LJ65puKFyn8Gq/wzV7iEkfDNTMX5VpSnZ\n\tG6zj7pIzKw2ROMxU0Cfgkmt4gPkHvDyckdJ1UgqklWW8uehy2YojknwBnbBz9KVY4HcO\n\tB3mNiLNMbjQug2n9Sx8i+uN/HSigjfgKnAR+qsXGN6xtm+ZTcYqRbFkPS2zUWb9nEHdY\n\tO2Krdqsq/AcU0FeFlyrWgWsD9HYEdKdRJ9iJs05Z+CeFLygNgpGHjNmkDy3MeCP7Cwqj\n\tYGMQ==", "X-Gm-Message-State": "AOJu0YxgIaRcVjjpDwJ/abnVTaotZXUQyfbMkbLnJbIY+2x7qRP+Vl3Z\n\tznx+vJd6m5xT9ee8g5H20CV0myTU+ulqMj3u4SGuUeq34Z3opgnXpBLSGSlTPZL+eap7Qf8z1k2\n\tQ2Q==", "X-Google-Smtp-Source": "AGHT+IEXXiXbZ0hKdn9Rgnsspya41rcNpBZAEoYwNF1UpYIQzWmcRZ054Y0ze+LrbAOOBP/gRvIw/Q==", "X-Received": "by 2002:a05:6a20:e607:b0:1c4:818c:299d with SMTP id\n\tadf61e73a8af0-1c68cec900bmr1945453637.11.1722497626944; \n\tThu, 01 Aug 2024 00:33:46 -0700 (PDT)", "From": "Harvey Yang <chenghaoyang@chromium.org>", "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Harvey Yang <chenghaoyang@google.com>,\n\tHarvey Yang <chenghaoyang@chromium.org>", "Subject": "[PATCH v7 1/7] libcamera: add DmaBufAllocation::exportFrameBuffers()", "Date": "Thu, 1 Aug 2024 07:30:57 +0000", "Message-ID": "<20240801073339.4061027-2-chenghaoyang@google.com>", "X-Mailer": "git-send-email 2.46.0.rc1.232.g9752f9e123-goog", "In-Reply-To": "<20240801073339.4061027-1-chenghaoyang@google.com>", "References": "<20240801073339.4061027-1-chenghaoyang@google.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "Add a helper function exportFrameBuffers in DmaBufAllocator to make it\neasier to use.\n\nIt'll be used in Virtual Pipeline Handler specifically.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n .../libcamera/internal/dma_buf_allocator.h | 10 +++\n src/libcamera/dma_buf_allocator.cpp | 68 ++++++++++++++++++-\n 2 files changed, 76 insertions(+), 2 deletions(-)", "diff": "diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h\nindex 36ec1696..dd2cc237 100644\n--- a/include/libcamera/internal/dma_buf_allocator.h\n+++ b/include/libcamera/internal/dma_buf_allocator.h\n@@ -8,12 +8,16 @@\n #pragma once\n \n #include <stddef.h>\n+#include <vector>\n \n #include <libcamera/base/flags.h>\n #include <libcamera/base/unique_fd.h>\n \n namespace libcamera {\n \n+class FrameBuffer;\n+struct StreamConfiguration;\n+\n class DmaBufAllocator\n {\n public:\n@@ -30,7 +34,13 @@ public:\n \tbool isValid() const { return providerHandle_.isValid(); }\n \tUniqueFD alloc(const char *name, std::size_t size);\n \n+\tint exportFrameBuffers(\n+\t\tconst StreamConfiguration &config,\n+\t\tstd::vector<std::unique_ptr<FrameBuffer>> *buffers);\n+\n private:\n+\tstd::unique_ptr<FrameBuffer> createBuffer(const StreamConfiguration &config);\n+\n \tUniqueFD allocFromHeap(const char *name, std::size_t size);\n \tUniqueFD allocFromUDmaBuf(const char *name, std::size_t size);\n \tUniqueFD providerHandle_;\ndiff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\nindex c06eca7d..6b406880 100644\n--- a/src/libcamera/dma_buf_allocator.cpp\n+++ b/src/libcamera/dma_buf_allocator.cpp\n@@ -23,6 +23,11 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/framebuffer.h>\n+#include <libcamera/stream.h>\n+\n+#include \"libcamera/internal/formats.h\"\n+\n /**\n * \\file dma_buf_allocator.cpp\n * \\brief dma-buf allocator\n@@ -130,8 +135,8 @@ DmaBufAllocator::~DmaBufAllocator() = default;\n /* uClibc doesn't provide the file sealing API. */\n #ifndef __DOXYGEN__\n #if not HAVE_FILE_SEALS\n-#define F_ADD_SEALS\t\t1033\n-#define F_SEAL_SHRINK\t\t0x0002\n+#define F_ADD_SEALS 1033\n+#define F_SEAL_SHRINK 0x0002\n #endif\n #endif\n \n@@ -243,4 +248,63 @@ UniqueFD DmaBufAllocator::alloc(const char *name, std::size_t size)\n \t\treturn allocFromHeap(name, size);\n }\n \n+/**\n+ * \\brief Allocate and export buffers for \\a stream from the DmaBufAllocator\n+ * \\param[in] config The config of the stream to allocate buffers for\n+ * \\param[out] buffers Array of buffers successfully allocated\n+ *\n+ * Allocates buffers for a stream from the DmaBufAllocator. It's a helper\n+ * function that'll be used in PipelineHandler::exportFrameBuffers().\n+ *\n+ * \\return The number of allocated buffers on success or a negative error code\n+ * otherwise\n+ */\n+int DmaBufAllocator::exportFrameBuffers(\n+\tconst StreamConfiguration &config,\n+\tstd::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+{\n+\tunsigned int count = config.bufferCount;\n+\n+\tfor (unsigned i = 0; i < count; ++i) {\n+\t\tstd::unique_ptr<FrameBuffer> buffer = createBuffer(config);\n+\t\tif (!buffer) {\n+\t\t\tLOG(DmaBufAllocator, Error) << \"Unable to create buffer\";\n+\n+\t\t\tbuffers->clear();\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tbuffers->push_back(std::move(buffer));\n+\t}\n+\n+\treturn count;\n+}\n+\n+std::unique_ptr<FrameBuffer> DmaBufAllocator::createBuffer(\n+\tconst StreamConfiguration &config)\n+{\n+\tstd::vector<FrameBuffer::Plane> planes;\n+\n+\tauto info = PixelFormatInfo::info(config.pixelFormat);\n+\tfor (size_t i = 0; i < info.planes.size(); ++i) {\n+\t\tunsigned int planeSize = info.planeSize(config.size, i);\n+\t\tif (planeSize == 0)\n+\t\t\tcontinue;\n+\n+\t\tUniqueFD fd = alloc(\"FrameBuffer\", planeSize);\n+\t\tif (!fd.isValid())\n+\t\t\treturn nullptr;\n+\n+\t\tSharedFD sharedFd(std::move(fd));\n+\n+\t\tFrameBuffer::Plane plane;\n+\t\tplane.fd = sharedFd;\n+\t\tplane.offset = 0;\n+\t\tplane.length = planeSize;\n+\t\tplanes.push_back(std::move(plane));\n+\t}\n+\n+\treturn std::make_unique<FrameBuffer>(planes);\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "v7", "1/7" ] }