Show a patch.

GET /api/1.1/patches/18270/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18270,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18270/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18270/",
    "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": "<20230208095922.1471175-4-chenghaoyang@google.com>",
    "date": "2023-02-08T09:59:22",
    "name": "[libcamera-devel,v1,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/1.1/people/117/?format=api",
        "name": "Cheng-Hao Yang",
        "email": "chenghaoyang@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18270/mbox/",
    "series": [
        {
            "id": 3744,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3744/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3744",
            "date": "2023-02-08T09:59:19",
            "name": "Add HeapAllocator",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3744/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18270/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18270/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 A7A69C324D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Feb 2023 09:59:36 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5B28D62601;\n\tWed,  8 Feb 2023 10:59:36 +0100 (CET)",
            "from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com\n\t[IPv6:2607:f8b0:4864:20::102a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CEE2D625F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Feb 2023 10:59:33 +0100 (CET)",
            "by mail-pj1-x102a.google.com with SMTP id\n\tc10-20020a17090a1d0a00b0022e63a94799so1863003pjd.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Feb 2023 01:59:33 -0800 (PST)",
            "from chenghaoyang-low.c.googlers.com.com\n\t(46.165.189.35.bc.googleusercontent.com. [35.189.165.46])\n\tby smtp.gmail.com with ESMTPSA id\n\tm2-20020a17090a4d8200b00230b8402760sm1077773pjh.38.2023.02.08.01.59.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 08 Feb 2023 01:59:31 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675850376;\n\tbh=HbRSjQ39da2Lgx0fziaXvG6iGKLteMFYspzo4RV1DgM=;\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=MktP4IWHnzUJg2IFF1shtxWVE3R9r4FtNXcHTUMgsLVccUuHRACLdLJj7RSqiInbj\n\tL/D7uYXzclWSponHeLPCk76oON5hK+6S1WwaMl5gIFSFKLr85pf9vmdpU/uAYTDfV6\n\tjGoNBDz+epaPITxszmJMd1s+9rK/kSRzUH4kaJvMMNBjp5hLpW52XDnzf+Qsw2hCFx\n\tHNztDMvWztvxhcj33n8iK1AR8Au4Y6T0MOKfBDe16C2wmRqPA0WftwyiTGaq33NpKD\n\tSlpDC1aYV0JdTG8AGhlbA+6sYYfzbfcOppJ66cyhvK9HIEysulUhD3RoWD3UGbwem4\n\tCXGXuiCPa3Ecw==",
            "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=72Bs66NZMpVyTD6wUic29MKfkfKk43ErfuKBDYJ1n2I=;\n\tb=R8nQ306nRNqUxDooZMdPxTDhUiTWaCJqdCX93xiD+2GI793fB4kaJufPudkJ8e57n7\n\tFYvBRD/Y54qw/c1xmNMIO4ChU6kt7swNGYtkM+N+OTwZJn2Gcvnmloq9HIY/4rSbSTgO\n\tx1q246nKpl5YwukkNJ+a8SQ3Ar+z/Lxr5Lthg="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"R8nQ306n\"; \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=72Bs66NZMpVyTD6wUic29MKfkfKk43ErfuKBDYJ1n2I=;\n\tb=ns9VKc+IWdqjgVY7qsa+uYXsWTUOiq7xQvhvaBBkQEUnBrGaLMsr0fN6hKIZEcL728\n\tqm/3q3wOGJ1YeQzL8FA3OKFXvbFwwYKZie26kVclJMeO2wLMHktXAcddxt95uKosrSFK\n\tNwxddW+rlqfX6JScaOc04s06UlialHVR4cWv9Z+j/i5+EPzeKXv2kHtAc66r3oJyLsrJ\n\th2Hbd2YRZ5jLIbbEN12ezk+i1WD8GXSBDiAp/EhgnCQNn9NdHeg8+QhvpMyVSJD8PQp+\n\tlr4PoU3yKQ7MvuVFT/f6DmaTDuDmtalLHcg1x067I19J89JH5OszLN/yka2d3T5e/oxk\n\tlaBg==",
        "X-Gm-Message-State": "AO0yUKU5h9oirSSzKQF/bGp7StIntXl7s0aypp74hhpJJ+hEBPwpKpfn\n\tG+cEgA6jYhP65q6zGvp9QDHiaBKycY6HLitH",
        "X-Google-Smtp-Source": "AK7set+ChTKXoN1BUUyo/IF1H536ZKJXpWIlTVmuYZhROSazcGWk6y09jz44wBnJ89f6SdAxRdVoJw==",
        "X-Received": "by 2002:a17:90b:3508:b0:230:ac45:b4a with SMTP id\n\tls8-20020a17090b350800b00230ac450b4amr7860986pjb.21.1675850371909; \n\tWed, 08 Feb 2023 01:59:31 -0800 (PST)",
        "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  8 Feb 2023 09:59:22 +0000",
        "Message-Id": "<20230208095922.1471175-4-chenghaoyang@google.com>",
        "X-Mailer": "git-send-email 2.39.1.519.gcb327c4b5f-goog",
        "In-Reply-To": "<20230208095922.1471175-1-chenghaoyang@google.com>",
        "References": "<20230208095922.1471175-1-chenghaoyang@google.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1 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",
        "v1",
        "3/3"
    ]
}