Show a patch.

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

{
    "id": 14918,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14918/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14918/",
    "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": "<20211130233634.34173-5-jacopo@jmondi.org>",
    "date": "2021-11-30T23:36:27",
    "name": "[libcamera-devel,v3,04/11] libcamera: framebuffer: Add Fence to FrameBuffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "27f66fb17e06c48ca95cefbeaac146a97e541b0c",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14918/mbox/",
    "series": [
        {
            "id": 2788,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2788/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2788",
            "date": "2021-11-30T23:36:23",
            "name": "libcamera: Add support for Fence",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2788/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14918/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14918/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 81F77BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 23:35:54 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 44C6460718;\n\tWed,  1 Dec 2021 00:35:54 +0100 (CET)",
            "from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 22AC760710\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 00:35:52 +0100 (CET)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 3B5A31BF206;\n\tTue, 30 Nov 2021 23:35:51 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  1 Dec 2021 00:36:27 +0100",
        "Message-Id": "<20211130233634.34173-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.33.1",
        "In-Reply-To": "<20211130233634.34173-1-jacopo@jmondi.org>",
        "References": "<20211130233634.34173-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 04/11] libcamera: framebuffer: Add\n\tFence to FrameBuffer",
        "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 to the FrameBuffer::Private class a unique pointer to a\nsynchronization Fence.\n\nThe Fence will be used to signal the availability of the Framebuffer for\nincoming data transfer.\n\nThe Fence will be associated to a FrameBuffer at Request::addBuffer()\ntime, and if correctly signalled, reset by the core at Request queue\ntime.\n\nIf a FrameBuffer completes with errors, due to a Fence wait failure, the\nFence will still be owned by the FrameBuffer and it is application\nresponsibility to correctly reset it before reusing the buffer.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/framebuffer.h          |  4 ++\n include/libcamera/internal/framebuffer.h |  7 +++\n src/libcamera/framebuffer.cpp            | 66 ++++++++++++++++++++++++\n 3 files changed, 77 insertions(+)",
    "diff": "diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h\nindex 357bbe189551..2f2ecbda6cb4 100644\n--- a/include/libcamera/framebuffer.h\n+++ b/include/libcamera/framebuffer.h\n@@ -18,6 +18,7 @@\n \n namespace libcamera {\n \n+class Fence;\n class Request;\n \n struct FrameMetadata {\n@@ -65,6 +66,9 @@ public:\n \tunsigned int cookie() const { return cookie_; }\n \tvoid setCookie(unsigned int cookie) { cookie_ = cookie; }\n \n+\tFence *fence() const;\n+\tstd::unique_ptr<Fence> resetFence();\n+\n \tvoid cancel() { metadata_.status = FrameMetadata::FrameCancelled; }\n \n private:\ndiff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h\nindex 908b478985e7..e2609300d209 100644\n--- a/include/libcamera/internal/framebuffer.h\n+++ b/include/libcamera/internal/framebuffer.h\n@@ -7,12 +7,16 @@\n \n #pragma once\n \n+#include <memory>\n+\n #include <libcamera/base/class.h>\n \n #include <libcamera/framebuffer.h>\n \n namespace libcamera {\n \n+class Fence;\n+\n class FrameBuffer::Private : public Extensible::Private\n {\n \tLIBCAMERA_DECLARE_PUBLIC(FrameBuffer)\n@@ -23,7 +27,10 @@ public:\n \tvoid setRequest(Request *request) { request_ = request; }\n \tbool isContiguous() const { return isContiguous_; }\n \n+\tvoid setFence(std::unique_ptr<Fence> fence);\n+\n private:\n+\tstd::unique_ptr<Fence> fence_;\n \tRequest *request_;\n \tbool isContiguous_;\n };\ndiff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex 701212f3ae21..2e6f07fb0e56 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -13,6 +13,8 @@\n #include <libcamera/base/file.h>\n #include <libcamera/base/log.h>\n \n+#include <libcamera/fence.h>\n+\n /**\n  * \\file libcamera/framebuffer.h\n  * \\brief Frame buffer handling\n@@ -129,6 +131,30 @@ FrameBuffer::Private::Private()\n  * handlers, it is called by the pipeline handlers themselves.\n  */\n \n+/**\n+ * \\brief Move a \\a fence in this buffer\n+ * \\param[in] fence The synchronization fence\n+ *\n+ * This function associates a Fence with this Framebuffer. The intended caller\n+ * is the Request::addBuffer() function.\n+ *\n+ * Once a FrameBuffer is associated with a Fence, the FrameBuffer will only be\n+ * made available to the hardware device once the synchronization Fence has been\n+ * correctly signalled.\n+ *\n+ * \\sa Request::prepare()\n+ *\n+ * If the FrameBuffer completes successfully the core resets the Fence and the\n+ * Buffer can be reused immediately. If handling of the Fence fails during the\n+ * request preparation, the Fence is not reset and is left in the FrameBuffer.\n+ * It is applications responsibility to correctly reset the fence and handle it\n+ * opportunely before using the buffer again.\n+ */\n+void FrameBuffer::Private::setFence(std::unique_ptr<Fence> fence)\n+{\n+\tfence_ = std::move(fence);\n+}\n+\n /**\n  * \\fn FrameBuffer::Private::isContiguous()\n  * \\brief Check if the frame buffer stores planes contiguously in memory\n@@ -329,6 +355,46 @@ Request *FrameBuffer::request() const\n  * libcamera core never modifies the buffer cookie.\n  */\n \n+/**\n+ * \\brief Retrieve a const pointer to the Fence\n+ *\n+ * This function does only return a reference to the the fence and does not\n+ * change its ownership. The fence is stored in the FrameBuffer and can only be\n+ * reset with FrameBuffer::resetFence() in case the buffer has completed with\n+ * error due to a Fence wait failure.\n+ *\n+ * If buffer with a Fence completes with errors due to a failure in handling\n+ * the fence, applications are responsible for resetting the Fence before\n+ * calling Request::addBuffer() again.\n+ *\n+ * \\sa Request::addBuffer()\n+ *\n+ * \\return A const pointer to the Fence if any, nullptr otherwise\n+ */\n+Fence *FrameBuffer::fence() const\n+{\n+\treturn _d()->fence_.get();\n+}\n+\n+/**\n+ * \\brief Extract the Fence associated with this Framebuffer\n+ *\n+ * This function moves the buffer's fence ownership to the caller.\n+ * After the fence has been reset, calling this function always return\n+ * nullptr.\n+ *\n+ * If buffer with a Fence completes with errors due to a failure in handling\n+ * the fence, applications are responsible for resetting the Fence before\n+ * calling Request::addBuffer() again.\n+ *\n+ * \\return A unique pointer to the Fence if set, or nullptr if the fence has\n+ * been reset already\n+ */\n+std::unique_ptr<Fence> FrameBuffer::resetFence()\n+{\n+\treturn std::move(_d()->fence_);\n+}\n+\n /**\n  * \\fn FrameBuffer::cancel()\n  * \\brief Marks the buffer as cancelled\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "04/11"
    ]
}