Show a patch.

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

{
    "id": 14401,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14401/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14401/",
    "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": "<20211028111520.256612-7-jacopo@jmondi.org>",
    "date": "2021-10-28T11:15:16",
    "name": "[libcamera-devel,06/10] libcamera: framebuffer: Add synchronization Fence",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9b21290a67cef42e55e316de5126e8cf34f084ca",
    "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/14401/mbox/",
    "series": [
        {
            "id": 2674,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2674/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2674",
            "date": "2021-10-28T11:15:10",
            "name": "libcamera: Introduce Fence support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2674/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14401/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14401/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 3D2FEC324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Oct 2021 11:14:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 92AF660156;\n\tThu, 28 Oct 2021 13:14:48 +0200 (CEST)",
            "from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AAFE4600C8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 13:14:40 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 350B3FF802;\n\tThu, 28 Oct 2021 11:14:40 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 28 Oct 2021 13:15:16 +0200",
        "Message-Id": "<20211028111520.256612-7-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.33.1",
        "In-Reply-To": "<20211028111520.256612-1-jacopo@jmondi.org>",
        "References": "<20211028111520.256612-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 06/10] libcamera: framebuffer: Add\n\tsynchronization Fence",
        "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 an optional synchronization file descriptor to the FrameBuffer constuctor.\n\nThe fence is handled by the FrameBuffer::Private class by constructing\na Fence class instance to wrap the file descriptor. Once the Request the\nFrameBuffer is part of has completed, the fence file descriptor will read\nas -1 if successfully handled by the library; otherwise the file\ndescriptor value is kept and applications are responsible for closing\nit.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/framebuffer.h          |  5 ++-\n include/libcamera/internal/framebuffer.h |  7 +++-\n src/libcamera/framebuffer.cpp            | 46 +++++++++++++++++++++---\n 3 files changed, 52 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h\nindex 7f2f176af691..ac96790b76c0 100644\n--- a/include/libcamera/framebuffer.h\n+++ b/include/libcamera/framebuffer.h\n@@ -57,7 +57,8 @@ public:\n \t\tunsigned int length;\n \t};\n \n-\tFrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);\n+\tFrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0,\n+\t\t    int fence = -1);\n \n \tconst std::vector<Plane> &planes() const { return planes_; }\n \tRequest *request() const;\n@@ -66,6 +67,8 @@ public:\n \tunsigned int cookie() const { return cookie_; }\n \tvoid setCookie(unsigned int cookie) { cookie_ = cookie; }\n \n+\tint fence() const;\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 cd33c295466e..db1a4bd72354 100644\n--- a/include/libcamera/internal/framebuffer.h\n+++ b/include/libcamera/internal/framebuffer.h\n@@ -11,6 +11,8 @@\n \n #include <libcamera/framebuffer.h>\n \n+#include <libcamera/internal/fence.h>\n+\n namespace libcamera {\n \n class FrameBuffer::Private : public Extensible::Private\n@@ -18,14 +20,17 @@ class FrameBuffer::Private : public Extensible::Private\n \tLIBCAMERA_DECLARE_PUBLIC(FrameBuffer)\n \n public:\n-\tPrivate();\n+\tPrivate(int fence);\n \n \tvoid setRequest(Request *request) { request_ = request; }\n \tbool isContiguous() const { return isContiguous_; }\n+\tconst Fence &fence() const { return fence_; }\n+\tFence &fence() { return fence_; }\n \n private:\n \tRequest *request_;\n \tbool isContiguous_;\n+\tFence fence_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\nindex d44a98babd05..c3e03896b184 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -111,8 +111,12 @@ LOG_DEFINE_CATEGORY(Buffer)\n  * pipeline handlers.\n  */\n \n-FrameBuffer::Private::Private()\n-\t: request_(nullptr), isContiguous_(true)\n+/**\n+ * \\brief Construct a FrameBuffer::Private instance\n+ * \\param[in] fence The synchronization fence file descriptor\n+ */\n+FrameBuffer::Private::Private(int fence)\n+\t: request_(nullptr), isContiguous_(true), fence_(fence)\n {\n }\n \n@@ -137,6 +141,18 @@ FrameBuffer::Private::Private()\n  * \\return True if the planes are stored contiguously in memory, false otherwise\n  */\n \n+/**\n+ * \\fn const FrameBuffer::Private::fence() const\n+ * \\brief Return a const reference to the Fence\n+ * \\return A const reference to the frame buffer fence\n+ */\n+\n+/**\n+ * \\fn FrameBuffer::Private::fence()\n+ * \\brief Return a reference to the Fence\n+ * \\return A reference to the frame buffer fence\n+ */\n+\n /**\n  * \\class FrameBuffer\n  * \\brief Frame buffer data and its associated dynamic metadata\n@@ -211,9 +227,11 @@ FrameBuffer::Private::Private()\n  * \\brief Construct a FrameBuffer with an array of planes\n  * \\param[in] planes The frame memory planes\n  * \\param[in] cookie Cookie\n+ * \\param[in] fence Synchronization fence\n  */\n-FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n-\t: Extensible(std::make_unique<Private>()), planes_(planes),\n+FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie,\n+\t\t\t int fence)\n+\t: Extensible(std::make_unique<Private>(fence)), planes_(planes),\n \t  cookie_(cookie)\n {\n \tmetadata_.planes_.resize(planes_.size());\n@@ -305,6 +323,26 @@ Request *FrameBuffer::request() const\n  * libcamera core never modifies the buffer cookie.\n  */\n \n+/**\n+ * \\fn FrameBuffer::fence()\n+ * \\brief Return the synchronization fence file descriptor\n+ *\n+ * The fence file descriptor is set by applications at construction time.\n+ *\n+ * Once the Request is queued to the Camera the fence is handled by the\n+ * library and if successfully notified the fence will read as -1 after the\n+ * Request has completed.\n+ *\n+ * If waiting for fence fails, the fence is instead kept in the FrameBuffer\n+ * after the Request has completed and it is responsibility of the\n+ * application to correctly close it.\n+ */\n+int FrameBuffer::fence() const\n+{\n+\tconst Fence &fence = _d()->fence();\n+\treturn fence.fd();\n+}\n+\n /**\n  * \\fn FrameBuffer::cancel()\n  * \\brief Marks the buffer as cancelled\n",
    "prefixes": [
        "libcamera-devel",
        "06/10"
    ]
}