Show a patch.

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

{
    "id": 18283,
    "url": "https://patchwork.libcamera.org/api/patches/18283/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18283/",
    "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": "<20230214093736.4067033-4-chenghaoyang@google.com>",
    "date": "2023-02-14T09:37:36",
    "name": "[libcamera-devel,v2,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/18283/mbox/",
    "series": [
        {
            "id": 3754,
            "url": "https://patchwork.libcamera.org/api/series/3754/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3754",
            "date": "2023-02-14T09:37:33",
            "name": "Add HeapAllocator",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3754/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18283/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18283/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 4D614C324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Feb 2023 09:37:50 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC854625E3;\n\tTue, 14 Feb 2023 10:37:49 +0100 (CET)",
            "from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com\n\t[IPv6:2607:f8b0:4864:20::52a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 483D5625FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Feb 2023 10:37:46 +0100 (CET)",
            "by mail-pg1-x52a.google.com with SMTP id x31so9859380pgl.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Feb 2023 01:37:46 -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\tz9-20020aa791c9000000b0059416691b64sm9696172pfa.19.2023.02.14.01.37.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 14 Feb 2023 01:37:44 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1676367469;\n\tbh=crF47FA90nPFDW1PTQ1EIWr0ELfwIeXg28krgyX/O2k=;\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=akqZd28cUoGmz6AxSfh5LVZBVeuCoKgYWiCm3CqNwQHERRIrWd8wmuXczBodvA4Bd\n\tsdaXLjAysogi0/lViqKr+pauvaJ7j59VTQw2C/3J5dOG3uQSGXGE0bFfILu0OGHM2S\n\tM9rgnJleEI0dQci08zqgFKMF1N5DF69wuWd7EdfSqFyiv+1+4Qk1yZ6u/9PNQlGDWu\n\t6HPbAdQGd1fbt9y51sbFg1U0gvLu8Blt3b4LsSA6mCmnKbSjZDEQAYusERrLsThNJp\n\t16QHdUk03zU1h/peVLi5sIFME/4+uqx4SP92NmG3abuPDISFYRvu//69fIeEImePFP\n\tL7jyZAHh4J7YA==",
            "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=5ed0e0o/PIWFeUY6+86mpSLl+MQcwNx1H9NaiJxqlCY=;\n\tb=N3I7xe66b7KQtpJ9MtLKmySf+wCvNanvQYSDfwIMk1naHoe3d5PONflV1Wz0tbj/+5\n\tjzy61OBQBU1GBB8TFbCKmzcEhvGta/5KA2Py2okixFlFr1SZS13QK+0FqFVM6ePSypOD\n\t8YvvOeJSdOHzhYKi9g96IV4epw84jd4D7BlMY="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"N3I7xe66\"; \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=5ed0e0o/PIWFeUY6+86mpSLl+MQcwNx1H9NaiJxqlCY=;\n\tb=eCP9bHB0zViE/4MoAQzr6JhI5MIJCTUECgLnXJFiY3ApnUXkvxVSKHnptPdN426EW9\n\t5Ek+KsirKReTtI0grp1LZj5jxwD9YIUsvtJ4QC1muoaFG/vSHDLb72i3LrUBt7OC2MmZ\n\t6eTb+A28zFWwbE2q0iWF53nx8DSiBUVz9qJtpTbf/BPnUXplJ3zlG/IW9BcZLqTRUDWi\n\tNul2zadTw1vtXPyxFuhpXLW2KoMnPdRQZf560DCZxZSXGDJe5StbJgoSalekYHqPowdm\n\ty6tbOQC7+1S5EoeLKzxRQiVlpZYt/tc0e4bhCXvCWcaFhAC4DTo79ro20q0OYknpdTkO\n\tpXsQ==",
        "X-Gm-Message-State": "AO0yUKW/UkeCGfiZDwu1OfODZt0ReqeYjafbCtBOfY9lkbLS0laMUFjE\n\tMDOEiKbJhmx7CguqW4QSNFqYnL7HYH4nwBV7",
        "X-Google-Smtp-Source": "AK7set9qEFc04dS2yPGmwulwmsCzVusXo0AqIb2Ys9peTGMwRkYG3LAEvyF9t0592/Xma8DF/XcSYQ==",
        "X-Received": "by 2002:aa7:9ad8:0:b0:5a8:808a:d3ce with SMTP id\n\tx24-20020aa79ad8000000b005a8808ad3cemr1677167pfp.8.1676367464676; \n\tTue, 14 Feb 2023 01:37:44 -0800 (PST)",
        "X-Google-Original-From": "Harvey Yang <chenghaoyang@google.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 14 Feb 2023 09:37:36 +0000",
        "Message-Id": "<20230214093736.4067033-4-chenghaoyang@google.com>",
        "X-Mailer": "git-send-email 2.39.1.581.gbfd45094c4-goog",
        "In-Reply-To": "<20230214093736.4067033-1-chenghaoyang@google.com>",
        "References": "<20230214093736.4067033-1-chenghaoyang@google.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 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",
        "v2",
        "3/3"
    ]
}