Patch Detail
Show a patch.
GET /api/patches/18326/?format=api
{ "id": 18326, "url": "https://patchwork.libcamera.org/api/patches/18326/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18326/", "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": "<20230302081349.3334290-4-chenghaoyang@google.com>", "date": "2023-03-02T08:13:49", "name": "[libcamera-devel,v3,3/3] libcamera: Add exportFrameBuffers in HeapAllocator", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "534a5043ce14efaaaaf76209949ea98414541659", "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/18326/mbox/", "series": [ { "id": 3780, "url": "https://patchwork.libcamera.org/api/series/3780/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3780", "date": "2023-03-02T08:13:46", "name": "Add HeapAllocator", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3780/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18326/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18326/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 5F009BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 2 Mar 2023 08:14:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0F3A2626C1;\n\tThu, 2 Mar 2023 09:14:03 +0100 (CET)", "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 98300626CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 2 Mar 2023 09:14:00 +0100 (CET)", "by mail-pl1-x62c.google.com with SMTP id a9so6610453plh.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Mar 2023 00:14:00 -0800 (PST)", "from chenghaoyang-low.c.googlers.com.com\n\t(112.157.221.35.bc.googleusercontent.com. [35.221.157.112])\n\tby smtp.gmail.com with ESMTPSA id\n\tp9-20020aa78609000000b005a8bdc18453sm9179755pfn.35.2023.03.02.00.13.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 02 Mar 2023 00:13:58 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677744843;\n\tbh=jCT2KScZi8M2XeTWcjx/iXTqRwnAWGbb85nr7/PM9qQ=;\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=Sppshb7rv5PkdkNOVw2cfq7Qhea86owt3BxzWFmpRGq41B2R4mkkwjDlA6sQdauqc\n\t4BZZFINV2e3y8yd9142TYJiT13ELI9et5lIuTVZNna+YfV3MMmxg+ZVEhskWGuOTT8\n\tzrlyRyQUecqQ6cv6YVNRngSvMbgtlv0hCMdmQ4DIBdgbPubCBd3DZgm7JtUtq2CZDB\n\tNn7iuzjXjiJdcsFO9rWY7z7TDPNNeMPwSyu7u3k0SI5EAjrBtNKfAnDgM93cZHopzP\n\tCfZrFP8vw95P0jgTW1LJZ7OHKc/mlDGFduHCUptQ7Q1OGrTHP0peCSXqX9COA9PPlI\n\tE96vTR1R6/w5Q==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \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=XXgeleZza/lqecvBHGW2tNMDFrYD9w7jlc3eZUNxb4M=;\n\tb=X6tEmFvb+RtuR9bEWdyV9wPffL6InSDJ637kr3lfgVLbVun5ASPopFVI+dtwTr9GwJ\n\tH2Zl6M6nsNmRe2sT/+4dLzUTSLH01/lRy5CbKD4KLxZyKJKlgJaIaJo2QKRQyiDYneUa\n\tQJY3TOzACzYWK2nnQbQRX0d58TCYaq5+qdnhg=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"X6tEmFvb\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=XXgeleZza/lqecvBHGW2tNMDFrYD9w7jlc3eZUNxb4M=;\n\tb=5qeJK8uXm2GIQ7JJhP/jC7F/+ITvBktYs17gYbAhBKnlxxebmevsFhMOGGKGMkb82P\n\toSThVvC4nVFbDkygAre5QFYxWynEeOP2CozmAz15IYZsNoJybU3jEUlL0ZZ04diGOLA2\n\tSdFhwXuWVT7H4marhcSe6kuxPVTNbXr5rjVHs4QmwbcHj5/9cZgG9U/GBFv3Tibs2zPa\n\tXo7Ff78B7ebV6WlPMDHP+OKRnIVGw/ylEgsu5WCvh8In3UBp5zduRd2NVGeRRDyjDpVk\n\tYBxPzcuW5aD5v0rHobk7CQ+TNBn1aZmIulp3zWmgpHgebfdtva+Tgh7zC3w6T/gWxvU0\n\tCTOg==", "X-Gm-Message-State": "AO0yUKUyt95FfsuOcx1Eae9cKHCR+T6fskitdQWJZYOMDO5OuP7OzXLw\n\tKd1KDTjkxNipz4WQT5ls6+gn+Dbn0tZ2jZuX3Ss=", "X-Google-Smtp-Source": "AK7set8RpU+BIuurIpLtTKRwMZ++S7YmXwyJsyppXcdb6AHdQeVWorDRxkURVnvAlhhe0/JQVW88ZA==", "X-Received": "by 2002:a05:6a20:549e:b0:bc:a257:5b2a with SMTP id\n\ti30-20020a056a20549e00b000bca2575b2amr10408486pzk.31.1677744838867; \n\tThu, 02 Mar 2023 00:13:58 -0800 (PST)", "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 2 Mar 2023 08:13:49 +0000", "Message-Id": "<20230302081349.3334290-4-chenghaoyang@google.com>", "X-Mailer": "git-send-email 2.39.2.722.g9855ee24e9-goog", "In-Reply-To": "<20230302081349.3334290-1-chenghaoyang@google.com>", "References": "<20230302081349.3334290-1-chenghaoyang@google.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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": "Harvey Yang <chenghaoyang@google.com>,\n\tHarvey Yang <chenghaoyang@chromium.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add 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/heap_allocator.h | 10 +++++++\n src/libcamera/heap_allocator.cpp | 44 ++++++++++++++++++++++++++++++\n 2 files changed, 54 insertions(+)", "diff": "diff --git a/include/libcamera/heap_allocator.h b/include/libcamera/heap_allocator.h\nindex cd7ed1a3..138596de 100644\n--- a/include/libcamera/heap_allocator.h\n+++ b/include/libcamera/heap_allocator.h\n@@ -8,6 +8,7 @@\n #pragma once\n \n #include <stddef.h>\n+#include <vector>\n \n #include <libcamera/base/unique_fd.h>\n \n@@ -15,6 +16,10 @@\n \n namespace libcamera {\n \n+class Camera;\n+class Stream;\n+class FrameBuffer;\n+\n class HeapAllocator\n {\n public:\n@@ -23,7 +28,12 @@ public:\n \tbool isValid() const { return heap_->isValid(); }\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(std::size_t size);\n+\n \tstd::unique_ptr<Heap> heap_;\n };\n \ndiff --git a/src/libcamera/heap_allocator.cpp b/src/libcamera/heap_allocator.cpp\nindex 179c2c21..1faa5585 100644\n--- a/src/libcamera/heap_allocator.cpp\n+++ b/src/libcamera/heap_allocator.cpp\n@@ -17,7 +17,10 @@\n \n #include <libcamera/base/log.h>\n \n+#include <libcamera/camera.h>\n #include <libcamera/dma_heap.h>\n+#include <libcamera/framebuffer.h>\n+#include <libcamera/stream.h>\n #include <libcamera/udma_heap.h>\n \n namespace libcamera {\n@@ -43,4 +46,45 @@ 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+\tsize_t size = stream->configuration().frameSize;\n+\n+\tfor (unsigned i = 0; i < count; ++i) {\n+\t\tstd::unique_ptr<FrameBuffer> buffer = createBuffer(size);\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(std::size_t size)\n+{\n+\tstd::vector<FrameBuffer::Plane> planes;\n+\n+\tUniqueFD fd = alloc(\"Buffer\", size);\n+\tif (!fd.isValid())\n+\t\treturn nullptr;\n+\n+\tFrameBuffer::Plane plane;\n+\tplane.fd = SharedFD(std::move(fd));\n+\tplane.offset = 0;\n+\tplane.length = size;\n+\n+\tplanes.push_back(std::move(plane));\n+\n+\treturn std::make_unique<FrameBuffer>(planes);\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v3", "3/3" ] }