Patch Detail
Show a patch.
GET /api/patches/15129/?format=api
{ "id": 15129, "url": "https://patchwork.libcamera.org/api/patches/15129/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15129/", "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": "<20211210205239.354901-6-jacopo@jmondi.org>", "date": "2021-12-10T20:52:33", "name": "[libcamera-devel,v5,05/11] libcamera: request: Add Fence to Request::addBuffer()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "eb28e01aab94cacfc6f5cd0c5f4e39d53f7d3cfb", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15129/mbox/", "series": [ { "id": 2837, "url": "https://patchwork.libcamera.org/api/series/2837/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2837", "date": "2021-12-10T20:52:28", "name": "libcamera: Add fence", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2837/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15129/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15129/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 48C6DBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Dec 2021 20:52:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 097006088E;\n\tFri, 10 Dec 2021 21:52:03 +0100 (CET)", "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 38ACB6087E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Dec 2021 21:51:56 +0100 (CET)", "(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 8BE7F100007;\n\tFri, 10 Dec 2021 20:51:54 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 10 Dec 2021 21:52:33 +0100", "Message-Id": "<20211210205239.354901-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.33.1", "In-Reply-To": "<20211210205239.354901-1-jacopo@jmondi.org>", "References": "<20211210205239.354901-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v5 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 fence parameter to Request::addBuffer() to allow\nassociating a Fence with a FrameBuffer.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/request.h | 4 +++-\n src/libcamera/request.cpp | 35 ++++++++++++++++++++++++++++++++++-\n 2 files changed, 37 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..016db9d62340 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 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,30 @@ 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 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+ * 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+ * If the \\a fence associated with \\a buffer isn't signalled, the request will\n+ * fail after a timeout. The buffer will still contain the fence, which\n+ * applications must retrieve with FrameBuffer::releaseFence() before the buffer\n+ * can be reused in another request. Attempting to add a buffer that still\n+ * contains a fence to a request will result in this function returning -EEXIST.\n+ *\n+ * \\sa FrameBuffer::releaseFence()\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 +344,18 @@ 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+\tif (buffer->_d()->fence()) {\n+\t\tLOG(Request, Error) << \"Failed to add buffer with a valid fence\";\n+\t\treturn -EEXIST;\n+\t}\n+\n+\tif (fence && fence->isValid())\n+\t\tbuffer->_d()->setFence(std::move(fence));\n+\n \treturn 0;\n }\n \n", "prefixes": [ "libcamera-devel", "v5", "05/11" ] }