From patchwork Fri Dec 6 16:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22227 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 23B9FBE173 for ; Fri, 6 Dec 2024 16:08:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 665F467E27; Fri, 6 Dec 2024 17:07:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ts324LDQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 38FA566176 for ; Fri, 6 Dec 2024 17:07:55 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6D3AA9FC; Fri, 6 Dec 2024 17:07:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501245; bh=Scbv05dXlHumWo/CTfJGqq5LN8ueXb/PBHOBlNjYnw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ts324LDQbr52G/xMJ1LnBkPPyIsxyk3pz00jixFTaaFtwNE6dtQA308+bFN3xM4EP ptc+g5p6Ixw61pdgs5rSrBjoP7BhwUKymH4EPTGwAqpfz9STCnPCmMZSXciAOoqg8p ZgRL4gM3/vV3jnbpj8728phNum0UyJakmI3+9dQE= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 1/8] libcamera: camera: Introduce metadataAvailable signal Date: Fri, 6 Dec 2024 17:07:39 +0100 Message-ID: <20241206160747.97176-2-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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 a new signal to the Camera class that allows applications to receive notifications for early completion of metadata results. To avoid expensive copies of the metadata results the signal transports the ids of the metadata keys that are ready. Applications can use these ids to access the metadata results from Request::metadata(). The signal is an opt-in feature for applications and the sum of all metadata results notified through this signal is available in Request::metadata() at request completion time. Signed-off-by: Jacopo Mondi --- include/libcamera/camera.h | 2 ++ src/libcamera/camera.cpp | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 94cee7bd86bb..20d51c191ecd 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -122,6 +123,7 @@ public: const std::string &id() const; + Signal> metadataAvailable; Signal bufferCompleted; Signal requestCompleted; Signal<> disconnected; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 4c865a46af53..63e78b24e271 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -886,6 +886,48 @@ const std::string &Camera::id() const return _d()->id_; } +/** + * \var Camera::metadataAvailable + * \brief Signal emitted when metadata for a request are available + * + * The metadataAvailable signal notifies applications about the availability + * of metadata for a request before the request completes. + * + * As metadata results could be large in size, the signal transports the ids + * of the metadata that have just been made available, but the actual control + * values are stored in the Camera::metadata() list. + * + * Applications can access the value of the newly available metadata results + * with: + * + * \code + + void metadataAvailableHandler(Request *request, + std::unordered_set ids) + { + const ControlList &metadata = request->metadata(); + + for (const auto id : ids) { + ControlValue &value = metadata.get(id->id()); + + .... + } + } + \endcode + * + * This signal is emitted multiple times for the same request, it is in facts + * emitted by the framework every time a new metadata list is made available + * by the Camera to the application. + * + * The sum of all metadata lists reported through this signal is equal to + * Request::metadata() list when the Request completes. + * + * Application can opt-in to handle this signal to receive fast notifications + * of metadata availability or can equally access the full metadata list + * at Request complete time through Request::metadata() if they have no interest + * in early metadata notification. + */ + /** * \var Camera::bufferCompleted * \brief Signal emitted when a buffer for a request queued to the camera has From patchwork Fri Dec 6 16:07:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22228 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 65522BE173 for ; Fri, 6 Dec 2024 16:08:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A450367E1F; Fri, 6 Dec 2024 17:07:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZQn3tRkR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8902A67E12 for ; Fri, 6 Dec 2024 17:07:55 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D6944B2B; Fri, 6 Dec 2024 17:07:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501246; bh=ZQxSVQC7JkMBGUIxuY7w04owyYOBD5nSfjYjQQ69qEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQn3tRkRCBEqgzvR2GZffHsSdJOWk903xG78oZV+70beq/faH59tZr7Q55YbOHfFJ EdKno5Fwg7I21c0eYioabcITwnIjjQQxbLbgeKaOCd6QY4NxtIgFDhSrbScHEX2o8T hH9dTvuhRF2WY6njhN0ojOaWUXStYQfQZRjhM3ps= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 2/8] guides: application: Document Camera::metadataAvailable Date: Fri, 6 Dec 2024 17:07:40 +0100 Message-ID: <20241206160747.97176-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" Document the Camera::metadataAvailable signal in the application developer guide as an opt-in feature to receive early metadata notifications. Signed-off-by: Jacopo Mondi --- Documentation/guides/application-developer.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/guides/application-developer.rst b/Documentation/guides/application-developer.rst index 25beb55d99a3..560bb4464497 100644 --- a/Documentation/guides/application-developer.rst +++ b/Documentation/guides/application-developer.rst @@ -357,6 +357,14 @@ Signals and Slots`_) to connect events with callbacks to handle them. The ``Camera`` device emits two signals that applications can connect to in order to execute callbacks on frame completion events. +The ``Camera::metadataAvailable`` signal notifies applications of the +availability of metadata results before a request completes. Receiving +notification about metadata availability allows application to fast-track +handling of metadata results before all the image buffers in a request are +ready. The full list of metadata results associated with a Request is anyway +available at request complete time, and receiving notifications for early +metadata availability is an optional feature for applications. + The ``Camera::bufferCompleted`` signal notifies applications that a buffer with image data is available. Receiving notifications about the single buffer completion event allows applications to implement partial request completion From patchwork Fri Dec 6 16:07:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22229 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 88546BE173 for ; Fri, 6 Dec 2024 16:08:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4BC6967E2D; Fri, 6 Dec 2024 17:07:59 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mjsCbx0N"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC06E618B3 for ; Fri, 6 Dec 2024 17:07:55 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 475B2641; Fri, 6 Dec 2024 17:07:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501246; bh=UtKmjupIEL60xV2zJbciiaJq0pJuJPdySw2ZplSqTxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjsCbx0NsX2cevRuXiEnyiVYEeQHPHre18Wf35Sn8oRzvBSgYjpoZkEXg1J4oV8lb trq85eHXQJCliHu/HEHbC8xEeCUv6aW1XnHh1YGluLuLUktFelRZ3IkRMDELIX/t8D JSSadDQfxYTqWh2OU6gwGetPwQX00NX6O9xupInM= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 3/8] libcamera: pipeline_handler: Add metadataAvailable() function Date: Fri, 6 Dec 2024 17:07:41 +0100 Message-ID: <20241206160747.97176-4-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" Currently the way pipeline handlers have to store metadata results for a Request is to access the Request::metadata_ list directly and either merge a ControlList or set a single control value there. Direct access to Request::metadata_ is however problematic as even if metadata would be available earlier, pipeline handlers can only accumulate the results in Request::metadata_ and they're only available for applications at Request complete time. Instead of letting pipeline handlers access Request::metadata_ directly provide two helper functions, similar in spirit to PipelineHandler::completeBuffer() and PipelineHandler::completeRequest(), to allow pipeline handlers to notify early availability of metadata. Provide two overloads, one that accepts a ControlList and merges it into Request::metadata_ and one that allows to set a single metadata result there without going through an intermediate copy. The newly provided helpers trigger the Camera::availableMetadata signal from where applications can retrieve the list of ControlIds that have just been made available by the pipeline handler. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/pipeline_handler.h | 41 ++++++++++ src/libcamera/pipeline_handler.cpp | 74 +++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index fb28a18d0f46..3ca6a0290b2b 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -11,13 +11,17 @@ #include #include #include +#include #include #include +#include #include #include +#include "libcamera/internal/request.h" + namespace libcamera { class Camera; @@ -58,6 +62,43 @@ public: void registerRequest(Request *request); void queueRequest(Request *request); + void metadataAvailable(Request *request, const ControlList &metadata); + + template + void metadataAvailable(Request *request, const Control &ctrl, + const T &value) + { + if (request->metadata().contains(ctrl.id())) + return; + + std::unordered_set ids; + ids.insert(&ctrl); + + request->metadata().set(ctrl, value); + + Camera *camera = request->_d()->camera(); + camera->metadataAvailable.emit(request, ids); + } + +#ifndef __DOXYGEN__ + template + void metadataAvailable(Request *request, + const Control> &ctrl, + const Span &value) + { + if (request->metadata().contains(ctrl.id())) + return; + + std::unordered_set ids; + ids.insert(&ctrl); + + request->metadata().set(ctrl, value); + + Camera *camera = request->_d()->camera(); + camera->metadataAvailable.emit(request, ids); + } +#endif + bool completeBuffer(Request *request, FrameBuffer *buffer); void completeRequest(Request *request); void cancelRequest(Request *request); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index caa5c20e7483..a69d789116ad 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -507,6 +507,80 @@ void PipelineHandler::doQueueRequests() * \return 0 on success or a negative error code otherwise */ +/** + * \brief Notify the availability of a list of metadata for \a request + * \param[in] request The request the metadata belongs to + * \param[in] metadata The metadata list + * + * This function should be called multiple times by pipeline handlers to signal + * the availability of a list of metadata results. It notifies applications + * by triggering the Camera::availableMetadata signal and accumulates the + * metadata results in Request::metadata(). + * + * Early metadata completion allows pipeline handlers to fast track delivery of + * metadata results as soon as they are available before the completion of \a + * request. The full list of metadata results of a Request is available at + * Request completion time in Request::metadata(). + * + * A metadata key is expected to be notified at most once. Metadata keys + * notified multiple times are ignored. + * + * This overload allows to signal the availability of a list of metadata and + * merges them in the Request::metadata() list. This operations is expensive + * as controls are copied from \a metadata to Request::metadata(). + * + * \context This function shall be called from the CameraManager thread. + */ +void PipelineHandler::metadataAvailable(Request *request, const ControlList &metadata) +{ + std::unordered_set ids; + const ControlIdMap *idmap = request->metadata().idMap(); + + for (const auto &ctrl : metadata) { + if (request->metadata().contains(ctrl.first)) + continue; + + ASSERT(idmap->count(ctrl.first)); + + ids.insert(idmap->at(ctrl.first)); + } + + if (ids.empty()) + return; + + request->metadata().merge(metadata); + + Camera *camera = request->_d()->camera(); + camera->metadataAvailable.emit(request, ids); +} + +/** + * \fn void PipelineHandler::metadataAvailable(Request *request, const Control &ctrl, const T &value) + * \brief Notify the availability of a metadata result for \a request + * \param[in] request The request the metadata belongs to + * \param[in] ctrl The control id to notify + * \param[in] value the control value + * + * This function should be called multiple times by pipeline handlers to signal + * the availability of a metadata result. It notifies applications + * by triggering the Camera::availableMetadata signal and accumulates the + * metadata result in Request::metadata(). + * + * Early metadata completion allows pipeline handlers to fast track delivery of + * metadata results as soon as they are available before the completion of \a + * request. The full list of metadata results of a Request is available at + * Request completion time in Request::metadata(). + * + * A metadata key is expected to be notified at most once. Metadata keys + * notified multiple times are ignored. + * + * This overload allows to signal the availability of a single metadata and + * merge \a value in the Request::metadata() list. This operations copies \a + * value in the Request::metadata() list without creating intermediate copies. + * + * \context This function shall be called from the CameraManager thread. + */ + /** * \brief Complete a buffer for a request * \param[in] request The request the buffer belongs to From patchwork Fri Dec 6 16:07:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22230 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 4DD8ABE173 for ; Fri, 6 Dec 2024 16:08:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 323BB67E30; Fri, 6 Dec 2024 17:08:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NnkUB2s0"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5CF2C67E1C for ; Fri, 6 Dec 2024 17:07:56 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ADC009FC; Fri, 6 Dec 2024 17:07:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501246; bh=7Y0HjASJaq70ru03BO0gmDiDRiK9/i3qxwgjLsFrHJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NnkUB2s0WQ9UyH0XwXbZMRZEbLNAhE4hBIKfOnGT9BiMpTCfr5d4HeSrgtPQChjfX UpLRvn26w9sh+JGuopyDIpoiS6nkUt6r2498BuhAwt3SuHgD/v6G2TkN65zC66euH+ 35VWkKTKcLckYWGTTDNCOvDL73pcN86NGPBH3ozg= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 4/8] guides: pipeline_handler: Document PipelineHandler::metadataAvailable Date: Fri, 6 Dec 2024 17:07:42 +0100 Message-ID: <20241206160747.97176-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" Document the new available helpers to accumulate metadata results in Request::metadata and notify applications about metadata availability. Signed-off-by: Jacopo Mondi --- Documentation/guides/pipeline-handler.rst | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 69e832a5587e..5a1b402fcc62 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -1431,18 +1431,28 @@ classes documentation. .. _libcamera Signal and Slot: https://libcamera.org/api-html/classlibcamera_1_1Signal.html#details In order to notify applications about the availability of new frames and data, -the ``Camera`` device exposes two ``Signals`` to which applications can connect -to be notified of frame completion events. The ``bufferComplete`` signal serves -to report to applications the completion event of a single ``Stream`` part of a -``Request``, while the ``requestComplete`` signal notifies the completion of all -the ``Streams`` and data submitted as part of a request. This mechanism allows +the ``Camera`` device exposes three ``Signals`` to which applications can +connect to be notified of frame completion and metadata availability events. + +The ``metadataAvailable`` signal serves to notify about the availability of +metadata and accumulates metadata results in the list of metadata associated +with a ``Request``. The ``bufferComplete`` signal serves to report to +applications the completion event of a single ``Stream`` part of a ``Request``, +while the ``requestComplete`` signal notifies the completion of all the +``Streams`` and data submitted as part of a request. This mechanism allows implementation of partial request completion, which allows an application to inspect completed buffers associated with the single streams without waiting for all of them to be ready. -The ``bufferComplete`` and ``requestComplete`` signals are emitted by the -``Camera`` device upon notifications received from the pipeline handler, which -tracks the buffers and request completion status. +The ``metadataAvailable``, ``bufferComplete`` and ``requestComplete`` signals +are emitted by the ``Camera`` device upon notifications received from the +pipeline handler, which tracks the metadata, buffers and request completion +status. + +Metadata availability is signalled by the pipeline handlers by calling the +PipelineHandler base class ``metadataAvailable`` function. This function +notifies applications about metadata availability and accumulates metadata +results in the ``Request::metadata()`` list. The single buffer completion notification is implemented by pipeline handlers by `connecting`_ the ``bufferReady`` signal of the capture devices they have queued From patchwork Fri Dec 6 16:07:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22231 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 5AA5DBE173 for ; Fri, 6 Dec 2024 16:08:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5DAC467E32; Fri, 6 Dec 2024 17:08:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l4t4zwog"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C0A2B67E23 for ; Fri, 6 Dec 2024 17:07:56 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 20B9CB2B; Fri, 6 Dec 2024 17:07:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501247; bh=0JI3J9rPo6b0oNYB/P6YFJNiSKC94wj9/MyHeBre318=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4t4zwog3VDxY628BcnWb7A5DfAs2+XPeB3aWwHVDl8GDZWtwEnZ//fOV4QQTHq5D JOxdySRpDw6whOI+0fId9w4BlRfxOK1fUp/UDkbFo30Y6PphyVVeA2WjJAfpw3n1GF 4ii3JUXWstGu75j/RAu7m228P9yfJXR2UM/N88R4= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 5/8] libcamera: request: Add function to reset metadata Date: Fri, 6 Dec 2024 17:07:43 +0100 Message-ID: <20241206160747.97176-6-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" In order to prepare to restrict access to the metadata list stored in a request, provide a function that allows pipeline handlers to reset the metadata pack. The only user is at the moment the vc4 pipeline handler. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/request.h | 5 +++++ src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h index 4e7d05b1e028..98b7c6d6dfdf 100644 --- a/include/libcamera/internal/request.h +++ b/include/libcamera/internal/request.h @@ -40,6 +40,11 @@ public: void cancel(); void reset(); + void resetMetadata() + { + _o()->metadata().clear(); + } + void prepare(std::chrono::milliseconds timeout = 0ms); Signal<> prepared; diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index fd8d84b14f15..bddc8a87d9e1 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -945,7 +945,7 @@ void Vc4CameraData::tryRunPipeline() * related controls. We clear it first because the request metadata * may have been populated if we have dropped the previous frame. */ - request->metadata().clear(); + request->_d()->resetMetadata(); fillRequestMetadata(bayerFrame.controls, request); /* Set our state to say the pipeline is active. */ From patchwork Fri Dec 6 16:07:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22232 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 C650BBE173 for ; Fri, 6 Dec 2024 16:08:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 750B367E29; Fri, 6 Dec 2024 17:08:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jBU05jmS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 39DFA67E26 for ; Fri, 6 Dec 2024 17:07:57 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 88C2E641; Fri, 6 Dec 2024 17:07:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501247; bh=GsXDkO6QzTsxYoOVvulLLbpd/cOv5xJXwg2bazdYSs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jBU05jmSwB2ofhf2Hnu3rUrww7BnJOamT/8PgZvp5CxiLNJr7VSBc5C4fB3BMhwpY Fm+WOE1JV4vM8v04FPfJOUjeYpTz/X1aD+BP+GPzcwPsRMQZCdZuV2RQ77I3rGlG6Z 4Z4QBpClhYw8Y7+RWAvQO1B8C8c7ZvwXsurcxbMk= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 6/8] libcamera: pipelines: Use the metadataAvailable() function Date: Fri, 6 Dec 2024 17:07:44 +0100 Message-ID: <20241206160747.97176-7-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" In order to prepare to restrict access to the Request::metadata_ list, use the new PipelineHandler::metadataAvailable() function to notify the availability of metadata and accumulate them in the Request::metadata_ list. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 6 ++---- src/libcamera/pipeline/ipu3/ipu3.cpp | 14 +++++++------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 8 ++++---- .../pipeline/rpi/common/pipeline_base.cpp | 12 ++++++------ src/libcamera/pipeline/simple/simple.cpp | 4 ++-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 4 ++-- src/libcamera/pipeline/vimc/vimc.cpp | 4 ++-- src/libcamera/pipeline/virtual/virtual.cpp | 3 ++- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 4e66b3368d5a..5588f4a05446 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -1099,10 +1099,8 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer) Request *request = buffer->request(); /* Record the sensor's timestamp in the request metadata. */ - ControlList &metadata = request->metadata(); - if (!metadata.contains(controls::SensorTimestamp.id())) - metadata.set(controls::SensorTimestamp, - buffer->metadata().timestamp); + metadataAvailable(request, controls::SensorTimestamp, + static_cast(buffer->metadata().timestamp)); completeBuffer(request, buffer); if (request->hasPendingBuffers()) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index e31e3879dcc9..bf1119bea567 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1245,7 +1245,7 @@ void IPU3CameraData::metadataReady(unsigned int id, const ControlList &metadata) return; Request *request = info->request; - request->metadata().merge(metadata); + pipe()->metadataAvailable(request, metadata); info->metadataProcessed = true; if (frameInfos_.tryComplete(info)) @@ -1272,12 +1272,12 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer) pipe()->completeBuffer(request, buffer); - request->metadata().set(controls::draft::PipelineDepth, 3); + pipe()->metadataAvailable(request, controls::draft::PipelineDepth, 3); /* \todo Actually apply the scaler crop region to the ImgU. */ const auto &scalerCrop = request->controls().get(controls::ScalerCrop); if (scalerCrop) cropRegion_ = *scalerCrop; - request->metadata().set(controls::ScalerCrop, cropRegion_); + pipe()->metadataAvailable(request, controls::ScalerCrop, cropRegion_); if (frameInfos_.tryComplete(info)) pipe()->completeRequest(request); @@ -1317,8 +1317,8 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) * \todo The sensor timestamp should be better estimated by connecting * to the V4L2Device::frameStart signal. */ - request->metadata().set(controls::SensorTimestamp, - buffer->metadata().timestamp); + pipe()->metadataAvailable(request, controls::SensorTimestamp, + static_cast(buffer->metadata().timestamp)); info->effectiveSensorControls = delayedCtrls_->get(buffer->metadata().sequence); @@ -1412,8 +1412,8 @@ void IPU3CameraData::frameStart(uint32_t sequence) return; } - request->metadata().set(controls::draft::TestPatternMode, - *testPatternMode); + pipe()->metadataAvailable(request, controls::draft::TestPatternMode, + *testPatternMode); } REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3, "ipu3") diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 908724e20975..8c66f0fc11b4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -431,7 +431,7 @@ void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &meta if (!info) return; - info->request->metadata().merge(metadata); + pipe()->metadataAvailable(info->request, metadata); info->metadataProcessed = true; pipe()->tryCompleteRequest(info); @@ -1414,8 +1414,8 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) * \todo The sensor timestamp should be better estimated by connecting * to the V4L2Device::frameStart signal. */ - request->metadata().set(controls::SensorTimestamp, - metadata.timestamp); + metadataAvailable(request, controls::SensorTimestamp, + static_cast(metadata.timestamp)); if (isRaw_) { const ControlList &ctrls = @@ -1487,7 +1487,7 @@ void PipelineHandlerRkISP1::imageBufferReady(FrameBuffer *buffer) LOG(RkISP1, Error) << "Cannot queue buffers to dewarper: " << strerror(-ret); - request->metadata().set(controls::ScalerCrop, activeCrop_.value()); + metadataAvailable(request, controls::ScalerCrop, activeCrop_.value()); } void PipelineHandlerRkISP1::dewarpBufferReady(FrameBuffer *buffer) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 6f278b29331a..8bfca6d2890d 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1234,7 +1234,7 @@ void CameraData::metadataReady(const ControlList &metadata) /* Add to the Request metadata buffer what the IPA has provided. */ /* Last thing to do is to fill up the request metadata. */ Request *request = requestQueue_.front(); - request->metadata().merge(metadata); + pipe()->metadataAvailable(request, metadata); /* * Inform the sensor of the latest colour gains if it has the @@ -1507,8 +1507,8 @@ void CameraData::checkRequestCompleted() void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request *request) { - request->metadata().set(controls::SensorTimestamp, - bufferControls.get(controls::SensorTimestamp).value_or(0)); + pipe()->metadataAvailable(request, controls::SensorTimestamp, + static_cast(bufferControls.get(controls::SensorTimestamp).value_or(0))); if (cropParams_.size()) { std::vector crops; @@ -1516,10 +1516,10 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request for (auto const &[k, v] : cropParams_) crops.push_back(scaleIspCrop(v.ispCrop)); - request->metadata().set(controls::ScalerCrop, crops[0]); + pipe()->metadataAvailable(request, controls::ScalerCrop, crops[0]); if (crops.size() > 1) { - request->metadata().set(controls::rpi::ScalerCrops, - Span(crops.data(), crops.size())); + pipe()->metadataAvailable(request, controls::rpi::ScalerCrops, + Span(crops.data(), crops.size())); } } } diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 8ac24e6e3423..0a68e454b3e4 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -844,8 +844,8 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) } if (request) - request->metadata().set(controls::SensorTimestamp, - buffer->metadata().timestamp); + pipe->metadataAvailable(request, controls::SensorTimestamp, + static_cast(buffer->metadata().timestamp)); /* * Queue the captured and the request buffer to the converter or Software diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 8c2c6baf3575..7fe607972a73 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -752,8 +752,8 @@ void UVCCameraData::imageBufferReady(FrameBuffer *buffer) Request *request = buffer->request(); /* \todo Use the UVC metadata to calculate a more precise timestamp */ - request->metadata().set(controls::SensorTimestamp, - buffer->metadata().timestamp); + pipe()->metadataAvailable(request, controls::SensorTimestamp, + static_cast(buffer->metadata().timestamp)); pipe()->completeBuffer(request, buffer); pipe()->completeRequest(request); diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 07273bd2b6c3..56b9d3c1ed69 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -615,8 +615,8 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) } /* Record the sensor's timestamp in the request metadata. */ - request->metadata().set(controls::SensorTimestamp, - buffer->metadata().timestamp); + pipe->metadataAvailable(request, controls::SensorTimestamp, + static_cast(buffer->metadata().timestamp)); pipe->completeBuffer(request, buffer); pipe->completeRequest(request); diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index cec8a85bf22c..695e2650e10f 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -317,7 +317,8 @@ int PipelineHandlerVirtual::queueRequestDevice([[maybe_unused]] Camera *camera, ASSERT(found); } - request->metadata().set(controls::SensorTimestamp, currentTimestamp()); + metadataAvailable(request, controls::SensorTimestamp, + static_cast(currentTimestamp())); completeRequest(request); return 0; From patchwork Fri Dec 6 16:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22233 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 E32C0BE173 for ; Fri, 6 Dec 2024 16:08:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9635867E39; Fri, 6 Dec 2024 17:08:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BRtquDjr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A305E67E28 for ; Fri, 6 Dec 2024 17:07:57 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EFDDF9FC; Fri, 6 Dec 2024 17:07:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501248; bh=hcQCGlN1mpUvkybpuZx7ht1VfpPoOAeR0rAg/6KGvW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRtquDjrSx2t0Jzj8d47i7i23/UUNO/C+m5AU6IVLC1BuPaKFPgSCtQlcEtwOfpLp WOAzNlUZpRC+731jpW2CXyGZ315pDCU2v0HGi5MEdeqFyQ/OBRwIijKcne6xUJlYXh DA9fO963s8eDRZqm8VbyeMtKb/UCTA8BKSq02jp8= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 7/8] libcamera: request: Make access to metadata() const Date: Fri, 6 Dec 2024 17:07:45 +0100 Message-ID: <20241206160747.97176-8-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" Restict access to the metadata list to return a const reference. Provide a Request::Private::metadata() function for the pipeline handler base class to access the metadata list in RW mode. All other users, of the public and internal API alike, can only access metadata through a const reference. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/pipeline_handler.h | 4 ++-- include/libcamera/internal/request.h | 5 ++++- include/libcamera/request.h | 4 +++- src/libcamera/pipeline_handler.cpp | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 3ca6a0290b2b..b84e5a06d77b 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -74,7 +74,7 @@ public: std::unordered_set ids; ids.insert(&ctrl); - request->metadata().set(ctrl, value); + request->_d()->metadata().set(ctrl, value); Camera *camera = request->_d()->camera(); camera->metadataAvailable.emit(request, ids); @@ -92,7 +92,7 @@ public: std::unordered_set ids; ids.insert(&ctrl); - request->metadata().set(ctrl, value); + request->_d()->metadata().set(ctrl, value); Camera *camera = request->_d()->camera(); camera->metadataAvailable.emit(request, ids); diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h index 98b7c6d6dfdf..1a7128b4259a 100644 --- a/include/libcamera/internal/request.h +++ b/include/libcamera/internal/request.h @@ -42,7 +42,8 @@ public: void resetMetadata() { - _o()->metadata().clear(); + ControlList &data = metadata(); + data.clear(); } void prepare(std::chrono::milliseconds timeout = 0ms); @@ -52,6 +53,8 @@ private: friend class PipelineHandler; friend std::ostream &operator<<(std::ostream &out, const Request &r); + ControlList &metadata() { return _o()->metadataRW(); } + void doCancelRequest(); void emitPrepareCompleted(); void notifierActivated(FrameBuffer *buffer); diff --git a/include/libcamera/request.h b/include/libcamera/request.h index e214a9d13c37..7791080976c2 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -50,7 +50,7 @@ public: void reuse(ReuseFlag flags = Default); ControlList &controls() { return *controls_; } - ControlList &metadata() { return *metadata_; } + const ControlList &metadata() { return *metadata_; } const BufferMap &buffers() const { return bufferMap_; } int addBuffer(const Stream *stream, FrameBuffer *buffer, std::unique_ptr fence = nullptr); @@ -67,6 +67,8 @@ public: private: LIBCAMERA_DISABLE_COPY(Request) + ControlList &metadataRW() { return *metadata_; } + ControlList *controls_; ControlList *metadata_; BufferMap bufferMap_; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index a69d789116ad..831ac6c87463 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -548,7 +548,7 @@ void PipelineHandler::metadataAvailable(Request *request, const ControlList &met if (ids.empty()) return; - request->metadata().merge(metadata); + request->_d()->metadata().merge(metadata); Camera *camera = request->_d()->camera(); camera->metadataAvailable.emit(request, ids); From patchwork Fri Dec 6 16:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22234 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 E9EDBBE173 for ; Fri, 6 Dec 2024 16:08:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F1CED67E30; Fri, 6 Dec 2024 17:08:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JP+oIAMH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 18E9F67E29 for ; Fri, 6 Dec 2024 17:07:58 +0100 (CET) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 633D1B2B; Fri, 6 Dec 2024 17:07:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733501248; bh=IpztqRtWVNDKpC+2Hj1pd4wRUpF3AsCDrijqdSYA3X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JP+oIAMHh3GLvU4UkZunLxuyMg2Dl/nmj+0sCPjOgNXDUlJn1NhB5PzarJgJHNHgp 74cZDBN/S2K0ZJG465P5ikjqid+jeBupON8Go6G6B6aBdJfpH1SlvNsr4rFRd9brTG 32xGdt3HVva/K6A27/UEcp3YlY32KRNd3NoKCYIU= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Harvey Yang , Han-Lin Chen Subject: [PATCH 8/8] [DNI] apps: cam: Use Camera::metadataAvailable signal Date: Fri, 6 Dec 2024 17:07:46 +0100 Message-ID: <20241206160747.97176-9-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> References: <20241206160747.97176-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" Handle the Camera::metadataAvailable signal and print the metadata list. Use the --metadata option of cam to validate that the metadata list in Request::metadata() matches the accumulated results. Signed-off-by: Jacopo Mondi --- src/apps/cam/camera_session.cpp | 17 +++++++++++++++++ src/apps/cam/camera_session.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 6e9890ccfda1..422874ae74ea 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -246,6 +246,7 @@ int CameraSession::start() + "-stream" + std::to_string(index); } + camera_->metadataAvailable.connect(this, &CameraSession::metadataAvailable); camera_->requestCompleted.connect(this, &CameraSession::requestComplete); #ifdef HAVE_KMS @@ -407,6 +408,22 @@ int CameraSession::queueRequest(Request *request) return camera_->queueRequest(request); } +void CameraSession::metadataAvailable(Request *request, + std::unordered_set ids) +{ + const ControlList &metadata = request->metadata(); + + std::cerr << "EARLY METADATA COMPLETION FOR REQUEST: " + << request->sequence() << std::endl; + + for (const auto id : ids) { + const ControlValue &value = metadata.get(id->id()); + + std::cout << "\t" << id->name() << " = " + << value.toString() << std::endl; + } +} + void CameraSession::requestComplete(Request *request) { if (request->status() == Request::RequestCancelled) diff --git a/src/apps/cam/camera_session.h b/src/apps/cam/camera_session.h index 4442fd9b1a6a..0539f759a65a 100644 --- a/src/apps/cam/camera_session.h +++ b/src/apps/cam/camera_session.h @@ -53,6 +53,8 @@ private: int startCapture(); int queueRequest(libcamera::Request *request); + void metadataAvailable(libcamera::Request *request, + std::unordered_set ids); void requestComplete(libcamera::Request *request); void processRequest(libcamera::Request *request); void sinkRelease(libcamera::Request *request);