Patch Detail
Show a patch.
GET /api/patches/21207/?format=api
{ "id": 21207, "url": "https://patchwork.libcamera.org/api/patches/21207/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21207/", "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": "<20240910044834.2477701-2-chenghaoyang@google.com>", "date": "2024-09-10T04:40:14", "name": "[v12,1/7] libcamera: add DmaBufAllocator::exportBuffers()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d64230c3d543d52a8c6e489f819a511e21a3a14e", "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/21207/mbox/", "series": [ { "id": 4572, "url": "https://patchwork.libcamera.org/api/series/4572/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4572", "date": "2024-09-10T04:40:13", "name": "Add VirtualPipelineHandler", "version": 12, "mbox": "https://patchwork.libcamera.org/series/4572/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21207/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21207/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 36EAFC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Sep 2024 04:48:49 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D2E1634F7;\n\tTue, 10 Sep 2024 06:48:45 +0200 (CEST)", "from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com\n\t[IPv6:2607:f8b0:4864:20::52c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 14BAE618F2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Sep 2024 06:48:43 +0200 (CEST)", "by mail-pg1-x52c.google.com with SMTP id\n\t41be03b00d2f7-70b2421471aso3366305a12.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 09 Sep 2024 21:48:43 -0700 (PDT)", "from chenghaoyang-low.c.googlers.com.com\n\t(0.223.81.34.bc.googleusercontent.com. [34.81.223.0])\n\tby smtp.gmail.com with ESMTPSA id\n\td2e1a72fcca58-71909092522sm530734b3a.111.2024.09.09.21.48.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 09 Sep 2024 21:48:40 -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=\"StSbiW7E\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1725943721; x=1726548521;\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=u898qJhf26WnkN+KdJDHerBl0GLRgYehB01hPG2JNFE=;\n\tb=StSbiW7Eusz04CadGMK9fSnL8uuHMokygZxuzhKN0uNi2Nd4BCKkzA09TufUhh8zv/\n\tD7LetYcXcCDKyxkzgyrQ5sfHP4BU8XwghkvAFoZqlEnNhc/RJPlBWtsvX8Ty2yHlOWWe\n\tLJkEXwBmlffIwi30UQa9I1KaX3XamSOCtILSE=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1725943721; x=1726548521;\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=u898qJhf26WnkN+KdJDHerBl0GLRgYehB01hPG2JNFE=;\n\tb=khyynUcfMME2j6JPKekyOqAtE18NPdrpo2CH5zS0bmGqsfvIlcFrOf7ug9375Vbk+1\n\tzqvqSCzzuwOfn4LbuBrP3V75QJ0b6cdMEr3WlLkpJV/2trBiZ1OuOVO8hyoH/liwHwWF\n\tH/hix/tlS8QifYZKxFFKYirsRii8cUt/lodwLaKhhjCGXr0qgcsQ3mRB73TWrWkKH1/K\n\tViDLuxwgnIZQv332X4fu+zCLELTAv1n0tG7bwxG5rkUtAcS2USW8USutvys/cUoJ1HMJ\n\tR7aPtMPoYYRHWc7sLxTQDtSQSyyQVdrAcx9NfAwghke4EGN+7TpzLSn/rNgyKY6+E0/f\n\tPwig==", "X-Gm-Message-State": "AOJu0YwQjuJNWapy3mVcxLVi8VtlMrrgRWCHr2hHy6ptDKsVtFZvTJIE\n\ttXq0V6UtQuPEAPj/DWyxSaPugbmEnlzbmjhjCGa6YQEwFvrbMgBsd+7UDAVqUZYdE5akx4/59SA\n\t=", "X-Google-Smtp-Source": "AGHT+IF02Wybb9t2aP+Djh0fQx/oel03gbpuwsE+dw2eduLtPINGWb9UNMThw6BKs8UCWr/PZjgeVw==", "X-Received": "by 2002:a05:6a20:4389:b0:1ce:ce51:4405 with SMTP id\n\tadf61e73a8af0-1cf1d1ddf8emr12892643637.42.1725943720684; \n\tMon, 09 Sep 2024 21:48:40 -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>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH v12 1/7] libcamera: add DmaBufAllocator::exportBuffers()", "Date": "Tue, 10 Sep 2024 04:40:14 +0000", "Message-ID": "<20240910044834.2477701-2-chenghaoyang@google.com>", "X-Mailer": "git-send-email 2.46.0.598.g6f2099f65c-goog", "In-Reply-To": "<20240910044834.2477701-1-chenghaoyang@google.com>", "References": "<20240910044834.2477701-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 exportBuffers in DmaBufAllocator to make it easier\nto use.\n\nIt'll be used in Virtual Pipeline Handler and SoftwareIsp.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n .../libcamera/internal/dma_buf_allocator.h | 13 +++++\n src/libcamera/dma_buf_allocator.cpp | 58 +++++++++++++++++++\n 2 files changed, 71 insertions(+)", "diff": "diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h\nindex d2a0a0d1..66d3b419 100644\n--- a/include/libcamera/internal/dma_buf_allocator.h\n+++ b/include/libcamera/internal/dma_buf_allocator.h\n@@ -7,11 +7,17 @@\n \n #pragma once\n \n+#include <memory>\n+#include <string>\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+\n class DmaBufAllocator\n {\n public:\n@@ -28,7 +34,14 @@ public:\n \tbool isValid() const { return providerHandle_.isValid(); }\n \tUniqueFD alloc(const char *name, std::size_t size);\n \n+\tint exportBuffers(unsigned int count,\n+\t\t\t const std::vector<unsigned int> &frameSize,\n+\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n+\n private:\n+\tstd::unique_ptr<FrameBuffer> createBuffer(\n+\t\tstd::string name, const std::vector<unsigned int> &frameSizes);\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 be6efb89..a49d1c60 100644\n--- a/src/libcamera/dma_buf_allocator.cpp\n+++ b/src/libcamera/dma_buf_allocator.cpp\n@@ -23,6 +23,10 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/memfd.h>\n \n+#include <libcamera/framebuffer.h>\n+\n+#include \"libcamera/internal/formats.h\"\n+\n /**\n * \\file dma_buf_allocator.cpp\n * \\brief dma-buf allocator\n@@ -205,4 +209,58 @@ 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 from the DmaBufAllocator\n+ * \\param[in] count The number of requested FrameBuffers\n+ * \\param[in] frameSizes The sizes of planes in each FrameBuffer\n+ * \\param[out] buffers Array of buffers successfully allocated\n+ *\n+ * Planes in a FrameBuffer are allocated with a single dma buf.\n+ * \\todo Add the option to allocate each plane with a dma buf respectively.\n+ *\n+ * \\return The number of allocated buffers on success or a negative error code\n+ * otherwise\n+ */\n+int DmaBufAllocator::exportBuffers(unsigned int count,\n+\t\t\t\t const std::vector<unsigned int> &frameSizes,\n+\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+{\n+\tfor (unsigned int i = 0; i < count; ++i) {\n+\t\tstd::unique_ptr<FrameBuffer> buffer =\n+\t\t\tcreateBuffer(\"frame-\" + std::to_string(i), frameSizes);\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>\n+DmaBufAllocator::createBuffer(std::string name,\n+\t\t\t const std::vector<unsigned int> &frameSizes)\n+{\n+\tstd::vector<FrameBuffer::Plane> planes;\n+\n+\tunsigned int bufferSize = 0, offset = 0;\n+\tfor (auto frameSize : frameSizes)\n+\t\tbufferSize += frameSize;\n+\n+\tSharedFD fd(alloc(name.c_str(), bufferSize));\n+\tif (!fd.isValid())\n+\t\treturn nullptr;\n+\n+\tfor (auto frameSize : frameSizes) {\n+\t\tplanes.emplace_back(FrameBuffer::Plane{ fd, offset, frameSize });\n+\t\toffset += frameSize;\n+\t}\n+\n+\treturn std::make_unique<FrameBuffer>(planes);\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "v12", "1/7" ] }