Show a patch.

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

{
    "id": 14965,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14965/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14965/",
    "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": "<20211201142936.107405-6-jacopo@jmondi.org>",
    "date": "2021-12-01T14:29:30",
    "name": "[libcamera-devel,v4,05/11] libcamera: request: Add Fence to Request::addBuffer()",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "467f455cd3a79b162f5bbcce6e8fec877eeb844e",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/14965/mbox/",
    "series": [
        {
            "id": 2795,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2795/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2795",
            "date": "2021-12-01T14:29:25",
            "name": "libcamera: Add support for Fence",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2795/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14965/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14965/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 EFBAAC3250\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 14:28:56 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B361F607C7;\n\tWed,  1 Dec 2021 15:28:56 +0100 (CET)",
            "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B89E6073F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 15:28:54 +0100 (CET)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 8D972C0002;\n\tWed,  1 Dec 2021 14:28:53 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  1 Dec 2021 15:29:30 +0100",
        "Message-Id": "<20211201142936.107405-6-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.33.1",
        "In-Reply-To": "<20211201142936.107405-1-jacopo@jmondi.org>",
        "References": "<20211201142936.107405-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 05/11] libcamera: request: Add Fence to\n\tRequest::addBuffer()",
        "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 fence to Request::addBuffer() to allow\nassociating a Fence with a FrameBuffer part of a Request.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/request.h |  4 +++-\n src/libcamera/request.cpp   | 26 +++++++++++++++++++++++++-\n 2 files changed, 28 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/include/libcamera/request.h b/include/libcamera/request.h\nindex 8c78970d88ab..1eb537e9b09b 100644\n--- a/include/libcamera/request.h\n+++ b/include/libcamera/request.h\n@@ -17,6 +17,7 @@\n #include <libcamera/base/signal.h>\n \n #include <libcamera/controls.h>\n+#include <libcamera/fence.h>\n \n namespace libcamera {\n \n@@ -51,7 +52,8 @@ public:\n \tControlList &controls() { return *controls_; }\n \tControlList &metadata() { return *metadata_; }\n \tconst BufferMap &buffers() const { return bufferMap_; }\n-\tint addBuffer(const Stream *stream, FrameBuffer *buffer);\n+\tint addBuffer(const Stream *stream, FrameBuffer *buffer,\n+\t\t      std::unique_ptr<Fence> fence = nullptr);\n \tFrameBuffer *findBuffer(const Stream *stream) const;\n \n \tuint32_t sequence() const;\ndiff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\nindex 692202473360..5ddb4b0592b3 100644\n--- a/src/libcamera/request.cpp\n+++ b/src/libcamera/request.cpp\n@@ -14,6 +14,7 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/control_ids.h>\n+#include <libcamera/fence.h>\n #include <libcamera/framebuffer.h>\n #include <libcamera/stream.h>\n \n@@ -294,6 +295,7 @@ void Request::reuse(ReuseFlag flags)\n  * \\brief Add a FrameBuffer with its associated Stream to the Request\n  * \\param[in] stream The stream the buffer belongs to\n  * \\param[in] buffer The FrameBuffer to add to the request\n+ * \\param[in] fence The optional synchronization Fence\n  *\n  * A reference to the buffer is stored in the request. The caller is responsible\n  * for ensuring that the buffer will remain valid until the request complete\n@@ -302,11 +304,24 @@ void Request::reuse(ReuseFlag flags)\n  * A request can only contain one buffer per stream. If a buffer has already\n  * been added to the request for the same stream, this function returns -EEXIST.\n  *\n+ * A synchronization Fence can be optionally associated with the \\a buffer.\n+ *\n+ * When a valid fence is provided to this function, \\a fence is moved to \\a\n+ * buffer and this Request will only be queued to the device once the\n+ * synchronization fences of all its buffers have been correctly signalled.\n+ *\n+ * If the \\a fence associated with \\a buffer fails, the application is\n+ * responsible for resetting it before associating this buffer with a new\n+ * Request by calling this function again.\n+ *\n+ * \\sa FrameBuffer::resetFence()\n+ *\n  * \\return 0 on success or a negative error code otherwise\n  * \\retval -EEXIST The request already contains a buffer for the stream\n  * \\retval -EINVAL The buffer does not reference a valid Stream\n  */\n-int Request::addBuffer(const Stream *stream, FrameBuffer *buffer)\n+int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,\n+\t\t       std::unique_ptr<Fence> fence)\n {\n \tif (!stream) {\n \t\tLOG(Request, Error) << \"Invalid stream reference\";\n@@ -323,6 +338,15 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer)\n \t_d()->pending_.insert(buffer);\n \tbufferMap_[stream] = buffer;\n \n+\t/*\n+\t * Make sure the fence has been extracted from the buffer\n+\t * to avoid waiting on a stale fence.\n+\t */\n+\tASSERT(!buffer->_d()->fence());\n+\n+\tif (fence && fence->isValid())\n+\t\tbuffer->_d()->setFence(std::move(fence));\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "05/11"
    ]
}