Patch Detail
Show a patch.
GET /api/1.1/patches/18638/?format=api
{ "id": 18638, "url": "https://patchwork.libcamera.org/api/1.1/patches/18638/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18638/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230516080459.711347-4-chenghaoyang@google.com>", "date": "2023-05-16T08:03:19", "name": "[libcamera-devel,v5,3/3] libcamera: Add exportFrameBuffers in HeapAllocator", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "e48bfa7914f9599f373e02b29262cf9bc04f0519", "submitter": { "id": 117, "url": "https://patchwork.libcamera.org/api/1.1/people/117/?format=api", "name": "Cheng-Hao Yang", "email": "chenghaoyang@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18638/mbox/", "series": [ { "id": 3879, "url": "https://patchwork.libcamera.org/api/1.1/series/3879/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3879", "date": "2023-05-16T08:03:16", "name": "Add HeapAllocator", "version": 5, "mbox": "https://patchwork.libcamera.org/series/3879/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18638/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18638/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 B53C6C3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 May 2023 08:05:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A8A8D6286E;\n\tTue, 16 May 2023 10:05:11 +0200 (CEST)", "from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com\n\t[IPv6:2607:f8b0:4864:20::62c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 37EAB62861\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 May 2023 10:05:10 +0200 (CEST)", "by mail-pl1-x62c.google.com with SMTP id\n\td9443c01a7336-1aaea3909d1so128993285ad.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 May 2023 01:05:10 -0700 (PDT)", "from chenghaoyang-low.c.googlers.com.com\n\t(27.247.221.35.bc.googleusercontent.com. [35.221.247.27])\n\tby smtp.gmail.com with ESMTPSA id\n\tkd14-20020a17090b348e00b00252df595c01sm996881pjb.52.2023.05.16.01.05.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 16 May 2023 01:05:08 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1684224311;\n\tbh=txUIkZ3u9xSb2SNYvo9IkUSeGXC5nQtPTUZA9q/8tfI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=CFIT9I6PtnZC3jIBvKk7rxHACrD+/GuLQOw/Jj0L7iueu2h+/e9dDv7Cggp588NkY\n\tDpnRpMaz5Rhx6OsH0QeCRMqG2l2ra8oao8p7cZ7s98VYaMpGBxOYgV6GtrusR65S+P\n\te6TDlcf822uJ0LNBAzmty7QS/CwSU/o+J3eymX5JcRE6x0ATbAfnQO2v6xSOx0EZQx\n\txsXXmRONNZutGQPTDI4e3y6HYsGQGzLvJ2LxLescSxR+GOyYibsbNdJX9xMxt7H6qn\n\tXmFY4rHj6WyjlzXe6nJazTSx5v+l0tfCxfj6iLTZHafOnQ4CoZ/MTK0AvoZQCjfwka\n\tJ4UY5NmSRgI+A==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1684224308; x=1686816308;\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=ApWxcQmz7KVlqjwqFr0G5ziyjKDyN2vbRBPSrxD8FOk=;\n\tb=P1WUp9z18A4UXqUTxw3ZE98c7BtHVNb7F/sVqJYUsE+lo+BggN+PkalO08aOl7Mn7+\n\tkiPlvnUni+5cXNT2WlmhnRE9J5puCS1G0XMQVDf2W/mDbnNXoudkWsJXSdqWMY45jwzt\n\thojZ2KQtxmX+/A9o8siOgXgrqWEaROqnUK0nA=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"P1WUp9z1\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1684224308; x=1686816308;\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=ApWxcQmz7KVlqjwqFr0G5ziyjKDyN2vbRBPSrxD8FOk=;\n\tb=UKh44KyuriSVCPN1SCzl85EVF5JHd1lmKR/jV4jKzIIYnYZd3OOKA4O4VQiqsGfPry\n\tFNM6odGJPbRPtv7xbuYBtWQb22KlSBuXDZPm978E5LZiZg2meEzCi9UIDN1H2t31zs2o\n\tr38kXOZpL28vljiB/U85Q+EHHp+wNRxLfjU0GQPcpjN1uisPybXJ2A2OC7diUuL0ygpe\n\tYXhq6rVcZp5SS0ggle+s/H68mKdE+Gx0lTUy6g+2KTXMqjJjGQ5lp7MCZ+7wql2EMMle\n\t7kPdgChu5JoTbxqckGNn+OxoN+7tHryfKobg+QP2WM+BCzOHHyXFlsuLxp71lQJmQcO0\n\tr9gw==", "X-Gm-Message-State": "AC+VfDweRA9QXKwkzFjgWuzy0YW7P3odTo0f5pWCJiG/kWRv6HaMn6mP\n\tyEnFM02daAIuHgEvD3uG1MA/52hxsTrf9CSx38oYTQ==", "X-Google-Smtp-Source": "ACHHUZ7+ZsXKe4OzadC7O6u390DSP/aHvVlwNvAbndQGjgYDTL8aTcMtQC1RxUlDtUNioymZIkMZcg==", "X-Received": "by 2002:a17:902:f548:b0:1ad:cb4b:1d50 with SMTP id\n\th8-20020a170902f54800b001adcb4b1d50mr22055162plf.43.1684224308636; \n\tTue, 16 May 2023 01:05:08 -0700 (PDT)", "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 16 May 2023 08:03:19 +0000", "Message-ID": "<20230516080459.711347-4-chenghaoyang@google.com>", "X-Mailer": "git-send-email 2.40.1.606.ga4b1b128d6-goog", "In-Reply-To": "<20230516080459.711347-1-chenghaoyang@google.com>", "References": "<20230516080459.711347-1-chenghaoyang@google.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 3/3] libcamera: Add exportFrameBuffers\n\tin HeapAllocator", "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": "Harvey Yang via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Harvey Yang <chenghaoyang@chromium.org>", "Cc": "Cheng-Hao Yang <chenghaoyang@chromium.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Cheng-Hao Yang <chenghaoyang@chromium.org>\n\nAdd a helper function exportFrameBuffers in HeapAllocator to make it\neasier to use.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n include/libcamera/internal/heap_allocator.h | 9 +++\n src/libcamera/heap_allocator.cpp | 61 +++++++++++++++++++++\n 2 files changed, 70 insertions(+)", "diff": "diff --git a/include/libcamera/internal/heap_allocator.h b/include/libcamera/internal/heap_allocator.h\nindex d061fdce..b6488fbc 100644\n--- a/include/libcamera/internal/heap_allocator.h\n+++ b/include/libcamera/internal/heap_allocator.h\n@@ -8,12 +8,16 @@\n #pragma once\n \n #include <stddef.h>\n+#include <vector>\n \n #include <libcamera/base/unique_fd.h>\n \n namespace libcamera {\n \n+class Camera;\n+class FrameBuffer;\n class Heap;\n+class Stream;\n \n class HeapAllocator\n {\n@@ -23,7 +27,12 @@ public:\n \tbool isValid() const;\n \tUniqueFD alloc(const char *name, std::size_t size);\n \n+\tint exportFrameBuffers(Camera *camera, Stream *stream,\n+\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n+\n private:\n+\tstd::unique_ptr<FrameBuffer> createBuffer(Stream *stream);\n+\n \tstd::unique_ptr<Heap> heap_;\n };\n \ndiff --git a/src/libcamera/heap_allocator.cpp b/src/libcamera/heap_allocator.cpp\nindex 682a7e01..ce3a815d 100644\n--- a/src/libcamera/heap_allocator.cpp\n+++ b/src/libcamera/heap_allocator.cpp\n@@ -21,6 +21,12 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/camera.h>\n+#include <libcamera/framebuffer.h>\n+#include <libcamera/stream.h>\n+\n+#include \"libcamera/internal/formats.h\"\n+\n namespace libcamera {\n \n /*\n@@ -231,4 +237,59 @@ UniqueFD HeapAllocator::alloc(const char *name, std::size_t size)\n \treturn heap_->alloc(name, size);\n }\n \n+int HeapAllocator::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream,\n+\t\t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers)\n+{\n+\tunsigned int count = stream->configuration().bufferCount;\n+\n+\t/** \\todo Support multiplanar allocations */\n+\n+\tfor (unsigned i = 0; i < count; ++i) {\n+\t\tstd::unique_ptr<FrameBuffer> buffer = createBuffer(stream);\n+\t\tif (!buffer) {\n+\t\t\tLOG(HeapAllocator, 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> HeapAllocator::createBuffer(Stream *stream)\n+{\n+\tstd::vector<FrameBuffer::Plane> planes;\n+\n+\tunsigned int frameSize = stream->configuration().frameSize;\n+\tint pageSize = getpagesize();\n+\t// Allocation size need to be a direct multiple of |pageSize|.\n+\tunsigned int numPage = (frameSize + pageSize - 1) / pageSize;\n+\n+\tUniqueFD fd = alloc(\"FrameBuffer\", numPage * pageSize);\n+\tif (!fd.isValid())\n+\t\treturn nullptr;\n+\n+\tauto info = PixelFormatInfo::info(stream->configuration().pixelFormat);\n+\tSharedFD shared_fd(std::move(fd));\n+\tunsigned int offset = 0;\n+\tfor (size_t i = 0; i < info.planes.size(); ++i) {\n+\t\tunsigned int planeSize = info.planeSize(stream->configuration().size, i);\n+\t\tif (planeSize == 0)\n+\t\t\tcontinue;\n+\n+\t\tFrameBuffer::Plane plane;\n+\t\tplane.fd = shared_fd;\n+\t\tplane.offset = offset;\n+\t\tplane.length = planeSize;\n+\t\tplanes.push_back(std::move(plane));\n+\n+\t\toffset += planeSize;\n+\t}\n+\n+\treturn std::make_unique<FrameBuffer>(planes);\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v5", "3/3" ] }