Patch Detail
Show a patch.
GET /api/1.1/patches/14964/?format=api
{ "id": 14964, "url": "https://patchwork.libcamera.org/api/1.1/patches/14964/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14964/", "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-5-jacopo@jmondi.org>", "date": "2021-12-01T14:29:29", "name": "[libcamera-devel,v4,04/11] libcamera: framebuffer: Add Fence to FrameBuffer", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4a5736dcd826e03e7a97f9c7075964cac8b844ab", "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/14964/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/14964/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14964/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 5066FBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 1 Dec 2021 14:28:55 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8B85F607BD;\n\tWed, 1 Dec 2021 15:28:54 +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 570C360740\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 1 Dec 2021 15:28:53 +0100 (CET)", "(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id AFB77C000D;\n\tWed, 1 Dec 2021 14:28:52 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 1 Dec 2021 15:29:29 +0100", "Message-Id": "<20211201142936.107405-5-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 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 | 8 ++++\n src/libcamera/framebuffer.cpp | 58 ++++++++++++++++++++++++\n 3 files changed, 70 insertions(+)", "diff": "diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h\nindex 357bbe189551..39ebbdaebf47 100644\n--- a/include/libcamera/framebuffer.h\n+++ b/include/libcamera/framebuffer.h\n@@ -9,6 +9,7 @@\n \n #include <assert.h>\n #include <limits>\n+#include <memory>\n #include <stdint.h>\n #include <vector>\n \n@@ -18,6 +19,7 @@\n \n namespace libcamera {\n \n+class Fence;\n class Request;\n \n struct FrameMetadata {\n@@ -65,6 +67,8 @@ public:\n \tunsigned int cookie() const { return cookie_; }\n \tvoid setCookie(unsigned int cookie) { cookie_ = cookie; }\n \n+\tstd::unique_ptr<Fence> releaseFence();\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..fc9f4a2fc768 100644\n--- a/include/libcamera/internal/framebuffer.h\n+++ b/include/libcamera/internal/framebuffer.h\n@@ -7,8 +7,12 @@\n \n #pragma once\n \n+#include <memory>\n+#include <utility>\n+\n #include <libcamera/base/class.h>\n \n+#include <libcamera/fence.h>\n #include <libcamera/framebuffer.h>\n \n namespace libcamera {\n@@ -23,7 +27,11 @@ public:\n \tvoid setRequest(Request *request) { request_ = request; }\n \tbool isContiguous() const { return isContiguous_; }\n \n+\tFence *fence() const { return fence_.get(); }\n+\tvoid setFence(std::unique_ptr<Fence> fence) { fence_ = std::move(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..a2cb0486e14d 100644\n--- a/src/libcamera/framebuffer.cpp\n+++ b/src/libcamera/framebuffer.cpp\n@@ -140,6 +140,45 @@ FrameBuffer::Private::Private()\n * \\return True if the planes are stored contiguously in memory, false otherwise\n */\n \n+/**\n+ * \\fn FrameBuffer::Private::fence()\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::releaseFence() 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 releasing 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+\n+/**\n+ * \\fn FrameBuffer::Private::setFence()\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 releases 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 release the fence and handle\n+ * it opportunely before using the buffer again.\n+ */\n+\n /**\n * \\class FrameBuffer\n * \\brief Frame buffer data and its associated dynamic metadata\n@@ -329,6 +368,25 @@ Request *FrameBuffer::request() const\n * libcamera core never modifies the buffer cookie.\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 released, 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 releasing 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 released already\n+ */\n+std::unique_ptr<Fence> FrameBuffer::releaseFence()\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", "v4", "04/11" ] }