From patchwork Sat Nov 20 11:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 14671 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CB839BDB13 for ; Sat, 20 Nov 2021 11:12:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96DED60442; Sat, 20 Nov 2021 12:12:28 +0100 (CET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F5C960378 for ; Sat, 20 Nov 2021 12:12:24 +0100 (CET) Received: (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 05BC2100002; Sat, 20 Nov 2021 11:12:23 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Sat, 20 Nov 2021 12:13:04 +0100 Message-Id: <20211120111313.106621-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211120111313.106621-1-jacopo@jmondi.org> References: <20211120111313.106621-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 03/12] libcamera: framebuffer: private: Add Fence X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add to the FrameBuffer::Private class a uniquely owned Fence instance. The Fence will be used to signal the availability of the Framebuffer to incoming data transfer. Add a set of function to set, cancel and retrieve a refence to the Fence. Signed-off-by: Jacopo Mondi --- include/libcamera/framebuffer.h | 3 +++ include/libcamera/internal/framebuffer.h | 9 ++++++++ src/libcamera/framebuffer.cpp | 26 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 7f2f176af691..aa2a1f5193c7 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -19,6 +19,7 @@ namespace libcamera { +class Fence; class Request; struct FrameMetadata { @@ -66,6 +67,8 @@ public: unsigned int cookie() const { return cookie_; } void setCookie(unsigned int cookie) { cookie_ = cookie; } + Fence *fence() const; + void cancel() { metadata_.status = FrameMetadata::FrameCancelled; } private: diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h index cd33c295466e..9e1699a6875d 100644 --- a/include/libcamera/internal/framebuffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -7,10 +7,14 @@ #ifndef __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ #define __LIBCAMERA_INTERNAL_FRAMEBUFFER_H__ +#include + #include #include +#include + namespace libcamera { class FrameBuffer::Private : public Extensible::Private @@ -23,8 +27,13 @@ public: void setRequest(Request *request) { request_ = request; } bool isContiguous() const { return isContiguous_; } + void setFence(std::unique_ptr &&fence) { fence_ = std::move(fence); } + void closeFence() { fence_.reset(); } + Fence *fence() const { return fence_.get(); } + private: Request *request_; + std::unique_ptr fence_; bool isContiguous_; }; diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 337ea1155a38..63c4ce6ab450 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -126,6 +126,23 @@ FrameBuffer::Private::Private() * handlers, it is called by the pipeline handlers themselves. */ +/** + * \fn FrameBuffer::Private::setFence() + * \brief Set the synchronization fence for this buffer + * \param[in] fence The synchronization fence + */ + +/** + * \fn FrameBuffer::Private::closeFence() + * \brief Close the synchronization fence for this buffer + */ + +/** + * \fn FrameBuffer::Private::fence() + * \brief Retrieve a pointer to the synchronization fence of this buffer + * \return A pointer to the buffer fence, nullptr if the buffer has not fence + */ + /** * \fn FrameBuffer::Private::isContiguous() * \brief Check if the frame buffer stores planes contiguously in memory @@ -305,6 +322,15 @@ Request *FrameBuffer::request() const * libcamera core never modifies the buffer cookie. */ +/** + * \brief Retrieve a reference to the Fence associated with this Framebuffer + * \return A pointer to the Fence, if set, nullptr otherwise + */ +Fence *FrameBuffer::fence() const +{ + return _d()->fence(); +} + /** * \fn FrameBuffer::cancel() * \brief Marks the buffer as cancelled