From patchwork Sun Jun 28 23:19:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8485 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 12AB6C2E66 for ; Sun, 28 Jun 2020 23:19:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C789660AF5; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jn3/8GdY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97CFD609C7 for ; Mon, 29 Jun 2020 01:19:41 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E80E556; Mon, 29 Jun 2020 01:19:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386381; bh=flOhzyMpDQg8Bjhw/dwaBl4oLmvP5c+29sCfnu0Z970=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jn3/8GdYN+NVkDuQOJ0fn5m/XLS7MfCu/bFUlpCnk/8m39TIdoNd7GdTSD67LaJjh fKwpcseIXihPGyDUZYEfJc5nIbFmZn687EWRe7IqpJvH5n/CddjlLlo+cMSv7ylJVK QgPYK2HkExPKXrL9vjBBblVqUcndGn5E8uGi97gI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:26 +0300 Message-Id: <20200628231934.29025-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/9] libcamera: ipa: Document the parameters of the IPA C configure function 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" The parameters to the configure() function part of the ipa_context_ops are not documented. Fix that. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/ipa_interface.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp index 69835e63ab46..ebe47e1233a5 100644 --- a/src/libcamera/ipa_interface.cpp +++ b/src/libcamera/ipa_interface.cpp @@ -340,6 +340,11 @@ * \var ipa_context_ops::configure * \brief Configure the IPA stream and sensor settings * \param[in] ctx The IPA context + * \param[in] sensor_info Camera sensor information + * \param[in] streams Configuration of all active streams + * \param[in] num_streams The number of entries in the \a streams array + * \param[in] maps Controls provided by the pipeline entities + * \param[in] num_maps The number of entries in the \a maps array * * \sa libcamera::IPAInterface::configure() */ From patchwork Sun Jun 28 23:19:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8486 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 153CFC2E66 for ; Sun, 28 Jun 2020 23:19:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8EB7860AF9; Mon, 29 Jun 2020 01:19:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="G19WYxzM"; 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 EE038609C7 for ; Mon, 29 Jun 2020 01:19:41 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 811D3734; Mon, 29 Jun 2020 01:19:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386381; bh=iMjnW9PuB+2IylFTj6/bTwFY8X3HaN2aU0IUsEoEZMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G19WYxzMNfeMpe/JOUcJDXCoV3enNh6tvqaE/i7siVQz1GzL+fhRKG73MEDjfVC/U 87EuaWNHJ1LtUq2FHkDJY/tZNNlH6CZhMCdXogKgYEl3U4cYXwNwBaf2hAn/7HsB2k rr0IAVbv4nX5kz1wlC5XH0APWw3cu+iGztPjbBjA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:27 +0300 Message-Id: <20200628231934.29025-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/9] libcamera: ipa_context_wrapper: Fix bad copy&paste in comment 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" A comment copied from the IPAInterfaceWrapper incorrectly mentions the IPAInterfaceWrapper class instead of the IPAContextWrapper class. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/ipa_context_wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp index 054aa6ba2089..471118f57cdc 100644 --- a/src/libcamera/ipa_context_wrapper.cpp +++ b/src/libcamera/ipa_context_wrapper.cpp @@ -283,7 +283,7 @@ void IPAContextWrapper::queue_frame_action(void *ctx, unsigned int frame, #ifndef __DOXYGEN__ /* * This construct confuses Doxygen and makes it believe that all members of the - * operations is a member of IPAInterfaceWrapper. It must thus be hidden. + * operations is a member of IPAContextWrapper. It must thus be hidden. */ const struct ipa_callback_ops IPAContextWrapper::callbacks_ = { .queue_frame_action = &IPAContextWrapper::queue_frame_action, From patchwork Sun Jun 28 23:19:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8487 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 C6CCEC2E66 for ; Sun, 28 Jun 2020 23:19:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4A50360B00; Mon, 29 Jun 2020 01:19:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RH5Yp4Ah"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6ABFD609C9 for ; Mon, 29 Jun 2020 01:19:42 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E2DAA9C5; Mon, 29 Jun 2020 01:19:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386382; bh=CTMUxzMR2EM111j84DGC1yyQxVhjO3lsoWawZsZPFLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RH5Yp4AhJ2O2/cGvWWXMdZx23HDu8EjT+q/mC4dvKz+3hJ3B2dftGvHHrZV386wN+ phJIsKZUkDHyZm9JadiWyo/iujZdBJ4Gp9nRoB59yytPwnxQ4COiXtWVGe2gB+6/IW v5IXccAhoal7NzvvM4bmN2Iz/LHALMGdeGiBp5U4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:28 +0300 Message-Id: <20200628231934.29025-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/9] libcamera: ipa_interface: Add support for custom IPA data to configure() 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 two new parameters, ipaConfig and result, to the IPAInterface::configure() function to allow pipeline handlers to pass custom data to their IPA, and receive data back. Wire this through the code base. The C API interface will be addressed separately, likely through automation of the C <-> C++ translation. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/internal/ipa_context_wrapper.h | 4 +++- include/libcamera/ipa/ipa_interface.h | 4 +++- src/ipa/libipa/ipa_interface_wrapper.cpp | 5 ++++- src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++++-- src/ipa/rkisp1/rkisp1.cpp | 8 ++++++-- src/ipa/vimc/vimc.cpp | 4 +++- src/libcamera/ipa_context_wrapper.cpp | 8 ++++++-- src/libcamera/ipa_interface.cpp | 7 +++++++ src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 4 +++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 +++- src/libcamera/proxy/ipa_proxy_linux.cpp | 4 +++- src/libcamera/proxy/ipa_proxy_thread.cpp | 11 ++++++++--- test/ipa/ipa_wrappers_test.cpp | 8 ++++++-- 13 files changed, 61 insertions(+), 18 deletions(-) diff --git a/include/libcamera/internal/ipa_context_wrapper.h b/include/libcamera/internal/ipa_context_wrapper.h index 4e6f791d18e6..8f767e844221 100644 --- a/include/libcamera/internal/ipa_context_wrapper.h +++ b/include/libcamera/internal/ipa_context_wrapper.h @@ -24,7 +24,9 @@ public: void stop() override; void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) override; + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index dc9fc714d564..5016ec25ea9c 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -158,7 +158,9 @@ public: virtual void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) = 0; + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) = 0; virtual void mapBuffers(const std::vector &buffers) = 0; virtual void unmapBuffers(const std::vector &ids) = 0; diff --git a/src/ipa/libipa/ipa_interface_wrapper.cpp b/src/ipa/libipa/ipa_interface_wrapper.cpp index 2a2e43abc708..47ce5a704851 100644 --- a/src/ipa/libipa/ipa_interface_wrapper.cpp +++ b/src/ipa/libipa/ipa_interface_wrapper.cpp @@ -166,7 +166,10 @@ void IPAInterfaceWrapper::configure(struct ipa_context *_ctx, entityControls.emplace(id, infoMaps[id]); } - ctx->ipa_->configure(sensorInfo, ipaStreams, entityControls); + /* \todo Translate the ipaConfig and reponse */ + IPAOperationData ipaConfig; + ctx->ipa_->configure(sensorInfo, ipaStreams, entityControls, ipaConfig, + nullptr); } void IPAInterfaceWrapper::map_buffers(struct ipa_context *_ctx, diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bc89ab58d03a..860be22ddb5d 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -78,7 +78,9 @@ public: void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) override; + const std::map &entityControls, + const IPAOperationData &data, + IPAOperationData *response) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; void processEvent(const IPAOperationData &event) override; @@ -186,7 +188,9 @@ void IPARPi::setMode(const CameraSensorInfo &sensorInfo) void IPARPi::configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) { if (entityControls.empty()) return; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index fbdc908fc816..34d6f63a7ff4 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -39,7 +39,9 @@ public: void configure(const CameraSensorInfo &info, const std::map &streamConfig, - const std::map &entityControls) override; + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *response) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; void processEvent(const IPAOperationData &event) override; @@ -76,7 +78,9 @@ private: */ void IPARkISP1::configure(const CameraSensorInfo &info, const std::map &streamConfig, - const std::map &entityControls) + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) { if (entityControls.empty()) return; diff --git a/src/ipa/vimc/vimc.cpp b/src/ipa/vimc/vimc.cpp index af278a482b8a..1593c92d80f3 100644 --- a/src/ipa/vimc/vimc.cpp +++ b/src/ipa/vimc/vimc.cpp @@ -39,7 +39,9 @@ public: void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) override {} + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) override {} void mapBuffers(const std::vector &buffers) override {} void unmapBuffers(const std::vector &ids) override {} void processEvent(const IPAOperationData &event) override {} diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp index 471118f57cdc..231300ce0bec 100644 --- a/src/libcamera/ipa_context_wrapper.cpp +++ b/src/libcamera/ipa_context_wrapper.cpp @@ -110,10 +110,13 @@ void IPAContextWrapper::stop() void IPAContextWrapper::configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) { if (intf_) - return intf_->configure(sensorInfo, streamConfig, entityControls); + return intf_->configure(sensorInfo, streamConfig, + entityControls, ipaConfig, result); if (!ctx_) return; @@ -174,6 +177,7 @@ void IPAContextWrapper::configure(const CameraSensorInfo &sensorInfo, ++i; } + /* \todo Translate the ipaConfig and reponse */ ctx_->ops->configure(ctx_, &sensor_info, c_streams, streamConfig.size(), c_info_maps, entityControls.size()); } diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp index ebe47e1233a5..23fc56d7d48e 100644 --- a/src/libcamera/ipa_interface.cpp +++ b/src/libcamera/ipa_interface.cpp @@ -557,6 +557,8 @@ namespace libcamera { * \param[in] sensorInfo Camera sensor information * \param[in] streamConfig Configuration of all active streams * \param[in] entityControls Controls provided by the pipeline entities + * \param[in] ipaConfig Pipeline-handler-specific configuration data + * \param[out] result Pipeline-handler-specific configuration result * * This method shall be called when the camera is started to inform the IPA of * the camera's streams and the sensor settings. The meaning of the numerical @@ -566,6 +568,11 @@ namespace libcamera { * The \a sensorInfo conveys information about the camera sensor settings that * the pipeline handler has selected for the configuration. The IPA may use * that information to tune its algorithms. + * + * The \a ipaConfig and \a result parameters carry custom data passed by the + * pipeline handler to the IPA and back. The pipeline handler may set the \a + * result parameter to null if the IPA protocol doesn't need to pass a result + * back through the configure() function. */ /** diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index dcd737a1d1a0..3b5cdf1e1849 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1017,7 +1017,9 @@ int PipelineHandlerRPi::configureIPA(Camera *camera) } /* Ready the IPA - it must know about the sensor resolution. */ - data->ipa_->configure(sensorInfo, streamConfig, entityControls); + IPAOperationData ipaConfig; + data->ipa_->configure(sensorInfo, streamConfig, entityControls, + ipaConfig, nullptr); return 0; } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 3c01821135f8..4fde5539e667 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -843,7 +843,9 @@ int PipelineHandlerRkISP1::start(Camera *camera) std::map entityControls; entityControls.emplace(0, data->sensor_->controls()); - data->ipa_->configure(sensorInfo, streamConfig, entityControls); + IPAOperationData ipaConfig; + data->ipa_->configure(sensorInfo, streamConfig, entityControls, + ipaConfig, nullptr); return ret; } diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp index be34f20aa857..68eafb307b2a 100644 --- a/src/libcamera/proxy/ipa_proxy_linux.cpp +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp @@ -31,7 +31,9 @@ public: void stop() override {} void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) override {} + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) override {} void mapBuffers(const std::vector &buffers) override {} void unmapBuffers(const std::vector &ids) override {} void processEvent(const IPAOperationData &event) override {} diff --git a/src/libcamera/proxy/ipa_proxy_thread.cpp b/src/libcamera/proxy/ipa_proxy_thread.cpp index 6fbebed2ba72..aa403e22f297 100644 --- a/src/libcamera/proxy/ipa_proxy_thread.cpp +++ b/src/libcamera/proxy/ipa_proxy_thread.cpp @@ -31,7 +31,9 @@ public: void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) override; + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; void processEvent(const IPAOperationData &event) override; @@ -129,9 +131,12 @@ void IPAProxyThread::stop() void IPAProxyThread::configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) { - ipa_->configure(sensorInfo, streamConfig, entityControls); + ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, + result); } void IPAProxyThread::mapBuffers(const std::vector &buffers) diff --git a/test/ipa/ipa_wrappers_test.cpp b/test/ipa/ipa_wrappers_test.cpp index aa7a9dcc6050..23c799da0663 100644 --- a/test/ipa/ipa_wrappers_test.cpp +++ b/test/ipa/ipa_wrappers_test.cpp @@ -69,7 +69,9 @@ public: void configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, - const std::map &entityControls) override + const std::map &entityControls, + const IPAOperationData &ipaConfig, + IPAOperationData *result) override { /* Verify sensorInfo. */ if (sensorInfo.outputSize.width != 2560 || @@ -317,7 +319,9 @@ protected: }; std::map controlInfo; controlInfo.emplace(42, subdev_->controls()); - ret = INVOKE(configure, sensorInfo, config, controlInfo); + IPAOperationData ipaConfig; + ret = INVOKE(configure, sensorInfo, config, controlInfo, + ipaConfig, nullptr); if (ret == TestFail) return TestFail; From patchwork Sun Jun 28 23:19:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8488 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 5DDE7C2E66 for ; Sun, 28 Jun 2020 23:19:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED3C260AF7; Mon, 29 Jun 2020 01:19:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aw4rzMni"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C11C0609C9 for ; Mon, 29 Jun 2020 01:19:42 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 53BD29DA; Mon, 29 Jun 2020 01:19:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386382; bh=tmEt+A7Se7qLan6i4z3XNJKVwbzk+X8q7l7tJ79gNgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aw4rzMniX5K+WDbTZSJlqaGRxZ7RvN18b8JLy3I6KnO2LAnWarSms7QNiqmKNvcqV kgDSfiEDLkiJnLF8C1Y4HAbgtusRy9Z0RRb7nNnmg8spEEzXb2Uz45QwoPXL/amSU8 bxEiJoTFtYkkqSUj3U+cTLtFL41qJMCTzvc4fMaA= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:29 +0300 Message-Id: <20200628231934.29025-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/9] libcamera: pipeline: raspberrypi: Constify parameter to StaggeredCtrl::set() 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" The controls parameter of StaggeredCtrl::set(), passed by reference, is not modified by the function. Make it const. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp | 2 +- src/libcamera/pipeline/raspberrypi/staggered_ctrl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp index 416cb9467147..0572acc93d63 100644 --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp +++ b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.cpp @@ -91,7 +91,7 @@ bool StaggeredCtrl::set(std::initializer_list return true; } -bool StaggeredCtrl::set(ControlList &controls) +bool StaggeredCtrl::set(const ControlList &controls) { std::lock_guard lock(lock_); diff --git a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h index 98994a6177e1..382fa31a6853 100644 --- a/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h +++ b/src/libcamera/pipeline/raspberrypi/staggered_ctrl.h @@ -41,7 +41,7 @@ public: bool set(uint32_t ctrl, int32_t value); bool set(std::initializer_list> ctrlList); - bool set(ControlList &controls); + bool set(const ControlList &controls); int write(); From patchwork Sun Jun 28 23:19:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8489 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 0589CC2E66 for ; Sun, 28 Jun 2020 23:19:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C949A60B00; Mon, 29 Jun 2020 01:19:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lDPeoNJm"; 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 5927560AF1 for ; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6D934FB; Mon, 29 Jun 2020 01:19:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386382; bh=dbBYdgdx2A9b3rVj18b78K4/NFH7Ho0429N8US51R2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDPeoNJmMGfOfHQbJAdYuvvcBET23E+YBs4PCLcM21iRyzuMxj+0EuhrZbGrRBle+ WDujxi2KlHePrFEncw5IdsEeHd6Vi8TMKtB2qjPNqMQc5M3CXDcomuIL9KD0Ei34uS w2V7o7rfO1B+Eqsacrb3kWZJIiNMS4q01t/Uks24= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:30 +0300 Message-Id: <20200628231934.29025-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/9] libcamera: pipeline: raspberrypi: Move configureIPA() to RPiCameraData 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" The PipelineHandlerRPi::configureIPA() function accesses plenty of member data from the RPiCameraData class and no member from the PipelineHandlerRPi class. Move it to RPiCameraData where it logically belongs. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- .../pipeline/raspberrypi/raspberrypi.cpp | 117 +++++++++--------- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 3b5cdf1e1849..0f9237a7f346 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -311,6 +311,8 @@ public: void frameStarted(uint32_t sequence); int loadIPA(); + int configureIPA(); + void queueFrameAction(unsigned int frame, const IPAOperationData &action); /* bufferComplete signal handlers. */ @@ -396,8 +398,6 @@ private: return static_cast(PipelineHandler::cameraData(camera)); } - int configureIPA(Camera *camera); - int queueAllBuffers(Camera *camera); int prepareBuffers(Camera *camera); void freeBuffers(Camera *camera); @@ -752,7 +752,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) crop.y = (sensorFormat.size.height - crop.height) >> 1; data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop); - ret = configureIPA(camera); + ret = data->configureIPA(); if (ret) LOG(RPI, Error) << "Failed to configure the IPA: " << ret; @@ -968,62 +968,6 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) return true; } -int PipelineHandlerRPi::configureIPA(Camera *camera) -{ - std::map streamConfig; - std::map entityControls; - RPiCameraData *data = cameraData(camera); - - /* Get the device format to pass to the IPA. */ - V4L2DeviceFormat sensorFormat; - data->unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); - /* Inform IPA of stream configuration and sensor controls. */ - unsigned int i = 0; - for (auto const &stream : data->isp_) { - if (stream.isExternal()) { - streamConfig[i] = { - .pixelFormat = stream.configuration().pixelFormat, - .size = stream.configuration().size - }; - } - } - entityControls.emplace(0, data->unicam_[Unicam::Image].dev()->controls()); - entityControls.emplace(1, data->isp_[Isp::Input].dev()->controls()); - - /* Allocate the lens shading table via vcsm and pass to the IPA. */ - if (!data->lsTable_) { - data->lsTable_ = data->vcsm_.alloc("ls_grid", MAX_LS_GRID_SIZE); - uintptr_t ptr = reinterpret_cast(data->lsTable_); - - if (!data->lsTable_) - return -ENOMEM; - - /* - * The vcsm allocation will always be in the memory region - * < 32-bits to allow Videocore to access the memory. - */ - IPAOperationData op; - op.operation = RPI_IPA_EVENT_LS_TABLE_ALLOCATION; - op.data = { static_cast(ptr & 0xffffffff), - data->vcsm_.getVCHandle(data->lsTable_) }; - data->ipa_->processEvent(op); - } - - CameraSensorInfo sensorInfo = {}; - int ret = data->sensor_->sensorInfo(&sensorInfo); - if (ret) { - LOG(RPI, Error) << "Failed to retrieve camera sensor info"; - return ret; - } - - /* Ready the IPA - it must know about the sensor resolution. */ - IPAOperationData ipaConfig; - data->ipa_->configure(sensorInfo, streamConfig, entityControls, - ipaConfig, nullptr); - - return 0; -} - int PipelineHandlerRPi::queueAllBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); @@ -1161,6 +1105,61 @@ int RPiCameraData::loadIPA() return ipa_->start(); } +int RPiCameraData::configureIPA() +{ + std::map streamConfig; + std::map entityControls; + + /* Get the device format to pass to the IPA. */ + V4L2DeviceFormat sensorFormat; + unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); + /* Inform IPA of stream configuration and sensor controls. */ + unsigned int i = 0; + for (auto const &stream : isp_) { + if (stream.isExternal()) { + streamConfig[i] = { + .pixelFormat = stream.configuration().pixelFormat, + .size = stream.configuration().size + }; + } + } + entityControls.emplace(0, unicam_[Unicam::Image].dev()->controls()); + entityControls.emplace(1, isp_[Isp::Input].dev()->controls()); + + /* Allocate the lens shading table via vcsm and pass to the IPA. */ + if (!lsTable_) { + lsTable_ = vcsm_.alloc("ls_grid", MAX_LS_GRID_SIZE); + uintptr_t ptr = reinterpret_cast(lsTable_); + + if (!lsTable_) + return -ENOMEM; + + /* + * The vcsm allocation will always be in the memory region + * < 32-bits to allow Videocore to access the memory. + */ + IPAOperationData op; + op.operation = RPI_IPA_EVENT_LS_TABLE_ALLOCATION; + op.data = { static_cast(ptr & 0xffffffff), + vcsm_.getVCHandle(lsTable_) }; + ipa_->processEvent(op); + } + + CameraSensorInfo sensorInfo = {}; + int ret = sensor_->sensorInfo(&sensorInfo); + if (ret) { + LOG(RPI, Error) << "Failed to retrieve camera sensor info"; + return ret; + } + + /* Ready the IPA - it must know about the sensor resolution. */ + IPAOperationData ipaConfig; + ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, + nullptr); + + return 0; +} + void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData &action) { /* From patchwork Sun Jun 28 23:19:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8490 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 5B461C2E6A for ; Sun, 28 Jun 2020 23:19:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 27AAF60B04; Mon, 29 Jun 2020 01:19:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="v/93Sohh"; 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 BC53960AF4 for ; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 26D55556; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386383; bh=Vp9FTQVBMiDAnjh64KKZnhd3tF+Qg5c+daVZqibcvb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/93SohhFTrMuKED7DBhlqejLHV2v9Zz1jhANiyXNspAy1woBpwHe5J6u4+XkZrki EyKM26uBvlcOH61Gx11P3s6cFMfUMTcRzAnhC320FVk4BxMQzp0HUEi/u55H2DaobR AF/tjUZiXo10KnSAUJfHGYBI9sOO+og8ynAHttck= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:31 +0300 Message-Id: <20200628231934.29025-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 6/9] ipa: raspberrypi: Pass lens shading table through configure() function 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" The IPAInterface now accepts custom configuration data. Use it to pass the lens shading table instead of using a custom IPA event. This will allow starting the IPA when starting the camera, instead of pre-starting it early in order to process the lens shading table allocation event. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Naushir Patuck --- include/libcamera/ipa/raspberrypi.h | 5 ++++- src/ipa/raspberrypi/raspberrypi.cpp | 12 ++++++------ src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index a18ce9a884b6..c335d0259549 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -10,6 +10,10 @@ #include #include +enum RPiConfigParameters { + RPI_IPA_CONFIG_LSTABLE = (1 << 0), +}; + enum RPiOperations { RPI_IPA_ACTION_V4L2_SET_STAGGERED = 1, RPI_IPA_ACTION_V4L2_SET_ISP, @@ -21,7 +25,6 @@ enum RPiOperations { RPI_IPA_EVENT_SIGNAL_STAT_READY, RPI_IPA_EVENT_SIGNAL_ISP_PREPARE, RPI_IPA_EVENT_QUEUE_REQUEST, - RPI_IPA_EVENT_LS_TABLE_ALLOCATION, }; enum RPiIpaMask { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 860be22ddb5d..c9f7dea375a5 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -277,6 +277,12 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, applyAGC(&agcStatus); lastMode_ = mode_; + + /* Store the lens shading table pointer and handle if available. */ + if (ipaConfig.operation & RPI_IPA_CONFIG_LSTABLE) { + lsTable_ = reinterpret_cast(ipaConfig.data[0]); + lsTableHandle_ = ipaConfig.data[1]; + } } void IPARPi::mapBuffers(const std::vector &buffers) @@ -358,12 +364,6 @@ void IPARPi::processEvent(const IPAOperationData &event) break; } - case RPI_IPA_EVENT_LS_TABLE_ALLOCATION: { - lsTable_ = reinterpret_cast(event.data[0]); - lsTableHandle_ = event.data[1]; - break; - } - default: LOG(IPARPI, Error) << "Unknown event " << event.operation; break; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0f9237a7f346..903796790f44 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1109,6 +1109,7 @@ int RPiCameraData::configureIPA() { std::map streamConfig; std::map entityControls; + IPAOperationData ipaConfig = {}; /* Get the device format to pass to the IPA. */ V4L2DeviceFormat sensorFormat; @@ -1138,11 +1139,9 @@ int RPiCameraData::configureIPA() * The vcsm allocation will always be in the memory region * < 32-bits to allow Videocore to access the memory. */ - IPAOperationData op; - op.operation = RPI_IPA_EVENT_LS_TABLE_ALLOCATION; - op.data = { static_cast(ptr & 0xffffffff), - vcsm_.getVCHandle(lsTable_) }; - ipa_->processEvent(op); + ipaConfig.operation = RPI_IPA_CONFIG_LSTABLE; + ipaConfig.data = { static_cast(ptr & 0xffffffff), + vcsm_.getVCHandle(lsTable_) }; } CameraSensorInfo sensorInfo = {}; @@ -1153,7 +1152,6 @@ int RPiCameraData::configureIPA() } /* Ready the IPA - it must know about the sensor resolution. */ - IPAOperationData ipaConfig; ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, nullptr); From patchwork Sun Jun 28 23:19:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8491 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 C1795C2E66 for ; Sun, 28 Jun 2020 23:19:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8F4E260B07; Mon, 29 Jun 2020 01:19:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZG1fxYi/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C1DD60AF7 for ; Mon, 29 Jun 2020 01:19:44 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 887AF734; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386383; bh=NgGKREy6lYlJjjhepbY3Yi1cgHIIqnWbSsjsdhpoEGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZG1fxYi/QyoSdR/jeKgVGgjGGqjHlgsuP1JISN4I7s8vBNx1/fJaS1C0+w8huCiDK rjcz8+miGU2kSrPOt9Bzso879ggLS5zhq1Hf2XPx0v7tP9arhdptnhzR4y8RzTPHJ+ MD6uHUv7gd+vc8qXBOvviGdXUIh2wbTJWB2/gr2w= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:32 +0300 Message-Id: <20200628231934.29025-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 7/9] ipa: raspberrypi: Pass sensor config back from configure() 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" The Raspberry Pi IPA uses a custom frame action, RPI_IPA_ACTION_SET_SENSOR_CONFIG, to send initial sensor configuration to the pipeline handler when the IPA is configured. Replace this ad-hoc mechanism by passing the corresponding data back from the IPA to the pipeline handler through the configure() response. This allows synchronous handling of the response on the pipeline handler side. Signed-off-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.h | 3 +- src/ipa/raspberrypi/raspberrypi.cpp | 44 ++++++++------ .../pipeline/raspberrypi/raspberrypi.cpp | 60 +++++++++++-------- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index c335d0259549..77a7e6d40a2f 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -12,6 +12,8 @@ enum RPiConfigParameters { RPI_IPA_CONFIG_LSTABLE = (1 << 0), + RPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1), + RPI_IPA_CONFIG_SENSOR = (1 << 2), }; enum RPiOperations { @@ -20,7 +22,6 @@ enum RPiOperations { RPI_IPA_ACTION_STATS_METADATA_COMPLETE, RPI_IPA_ACTION_RUN_ISP, RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME, - RPI_IPA_ACTION_SET_SENSOR_CONFIG, RPI_IPA_ACTION_EMBEDDED_COMPLETE, RPI_IPA_EVENT_SIGNAL_STAT_READY, RPI_IPA_EVENT_SIGNAL_ISP_PREPARE, diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index c9f7dea375a5..7da2ffdf84a1 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -93,7 +93,7 @@ private: void reportMetadata(); bool parseEmbeddedData(unsigned int bufferId, struct DeviceStatus &deviceStatus); void processStats(unsigned int bufferId); - void applyAGC(const struct AgcStatus *agcStatus); + void applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls); void applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls); void applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls); void applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls); @@ -195,6 +195,8 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, if (entityControls.empty()) return; + result->operation = 0; + unicam_ctrls_ = entityControls.at(0); isp_ctrls_ = entityControls.at(1); /* Setup a metadata ControlList to output metadata. */ @@ -217,18 +219,16 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, sensorMetadata = helper_->SensorEmbeddedDataPresent(); RPi::CamTransform orientation = helper_->GetOrientation(); - IPAOperationData op; - op.operation = RPI_IPA_ACTION_SET_SENSOR_CONFIG; - op.data.push_back(gainDelay); - op.data.push_back(exposureDelay); - op.data.push_back(sensorMetadata); + result->data.push_back(gainDelay); + result->data.push_back(exposureDelay); + result->data.push_back(sensorMetadata); ControlList ctrls(unicam_ctrls_); ctrls.set(V4L2_CID_HFLIP, (int32_t) !!(orientation & RPi::CamTransform_HFLIP)); ctrls.set(V4L2_CID_VFLIP, (int32_t) !!(orientation & RPi::CamTransform_VFLIP)); - op.controls.push_back(ctrls); + result->controls.push_back(ctrls); - queueFrameAction.emit(0, op); + result->operation |= RPI_IPA_CONFIG_STAGGERED_WRITE; } /* Re-assemble camera mode using the sensor info. */ @@ -273,8 +273,13 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, /* SwitchMode may supply updated exposure/gain values to use. */ metadata.Get("agc.status", agcStatus); - if (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) - applyAGC(&agcStatus); + if (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) { + ControlList ctrls(unicam_ctrls_); + applyAGC(&agcStatus, ctrls); + result->controls.push_back(ctrls); + + result->operation |= RPI_IPA_CONFIG_SENSOR; + } lastMode_ = mode_; @@ -781,8 +786,15 @@ void IPARPi::processStats(unsigned int bufferId) controller_.Process(statistics, &rpiMetadata_); struct AgcStatus agcStatus; - if (rpiMetadata_.Get("agc.status", agcStatus) == 0) - applyAGC(&agcStatus); + if (rpiMetadata_.Get("agc.status", agcStatus) == 0) { + ControlList ctrls(unicam_ctrls_); + applyAGC(&agcStatus, ctrls); + + IPAOperationData op; + op.operation = RPI_IPA_ACTION_V4L2_SET_STAGGERED; + op.controls.push_back(ctrls); + queueFrameAction.emit(0, op); + } } void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) @@ -808,11 +820,8 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) static_cast(awbStatus->gain_b * 1000)); } -void IPARPi::applyAGC(const struct AgcStatus *agcStatus) +void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) { - IPAOperationData op; - op.operation = RPI_IPA_ACTION_V4L2_SET_STAGGERED; - int32_t gain_code = helper_->GainCode(agcStatus->analogue_gain); int32_t exposure_lines = helper_->ExposureLines(agcStatus->shutter_time); @@ -831,11 +840,8 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus) << agcStatus->analogue_gain << " (Gain Code: " << gain_code << ")"; - ControlList ctrls(unicam_ctrls_); ctrls.set(V4L2_CID_ANALOGUE_GAIN, gain_code); ctrls.set(V4L2_CID_EXPOSURE, exposure_lines); - op.controls.push_back(ctrls); - queueFrameAction.emit(0, op); } void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 903796790f44..60b01484b329 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -806,7 +806,7 @@ int PipelineHandlerRPi::start(Camera *camera) /* * Write the last set of gain and exposure values to the camera before * starting. First check that the staggered ctrl has been initialised - * by the IPA action. + * by configure(). */ ASSERT(data->staggeredCtrl_); data->staggeredCtrl_.reset(); @@ -1152,44 +1152,45 @@ int RPiCameraData::configureIPA() } /* Ready the IPA - it must know about the sensor resolution. */ + IPAOperationData result; + ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, - nullptr); + &result); - return 0; -} - -void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData &action) -{ - /* - * The following actions can be handled when the pipeline handler is in - * a stopped state. - */ - switch (action.operation) { - case RPI_IPA_ACTION_V4L2_SET_STAGGERED: { - ControlList controls = action.controls[0]; - if (!staggeredCtrl_.set(controls)) - LOG(RPI, Error) << "V4L2 staggered set failed"; - goto done; - } - - case RPI_IPA_ACTION_SET_SENSOR_CONFIG: { + if (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) { /* * Setup our staggered control writer with the sensor default * gain and exposure delays. */ if (!staggeredCtrl_) { staggeredCtrl_.init(unicam_[Unicam::Image].dev(), - { { V4L2_CID_ANALOGUE_GAIN, action.data[0] }, - { V4L2_CID_EXPOSURE, action.data[1] } }); - sensorMetadata_ = action.data[2]; + { { V4L2_CID_ANALOGUE_GAIN, result.data[0] }, + { V4L2_CID_EXPOSURE, result.data[1] } }); + sensorMetadata_ = result.data[2]; } /* Set the sensor orientation here as well. */ - ControlList controls = action.controls[0]; - unicam_[Unicam::Image].dev()->setControls(&controls); - goto done; + unicam_[Unicam::Image].dev()->setControls(&result.controls[0]); } + if (result.operation & RPI_IPA_CONFIG_SENSOR) { + unsigned int idx = result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE + ? 1 : 0; + const ControlList &ctrls = result.controls[idx]; + if (!staggeredCtrl_.set(ctrls)) + LOG(RPI, Error) << "V4L2 staggered set failed"; + } + + return 0; +} + +void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData &action) +{ + /* + * The following actions can be handled when the pipeline handler is in + * a stopped state. + */ + switch (action.operation) { case RPI_IPA_ACTION_V4L2_SET_ISP: { ControlList controls = action.controls[0]; isp_[Isp::Input].dev()->setControls(&controls); @@ -1205,6 +1206,13 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData * is in a stopped state. */ switch (action.operation) { + case RPI_IPA_ACTION_V4L2_SET_STAGGERED: { + const ControlList &controls = action.controls[0]; + if (!staggeredCtrl_.set(controls)) + LOG(RPI, Error) << "V4L2 staggered set failed"; + break; + } + case RPI_IPA_ACTION_STATS_METADATA_COMPLETE: { unsigned int bufferId = action.data[0]; FrameBuffer *buffer = isp_[Isp::Stats].getBuffers()->at(bufferId).get(); From patchwork Sun Jun 28 23:19:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8492 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 32E59C2E66 for ; Sun, 28 Jun 2020 23:19:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EBFAC60AFF; Mon, 29 Jun 2020 01:19:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qwSeYUYv"; 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 6DBCB609DB for ; Mon, 29 Jun 2020 01:19:44 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E92559C5; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386384; bh=phr37Do1+a4jKTug4mfpVra4Cn063fKxPTCMZ0pTmHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qwSeYUYvZzDV2iU7k11PXu97vBJTX+nkd//mxo78NDmDF34eTunS2zrOdICbz/eag N34l+xpbmzEkkw7iUUSkexf+pTanyOnhXOXzdIO5sCOrlNPHLE6FgovusVBiCXJYbf OJIbFfnQKOe3qtL/lvuqfJ6mvSbM3fWM7i2zu0cY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:33 +0300 Message-Id: <20200628231934.29025-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 8/9] libcamera: pipeline: raspberrypi: Start IPA when starting camera 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" The IPA is meant to be started when starting the camera, and stopped when stopping it. It was so far start early in order to handle the IPAInterface::processEvent() call related to lens shading table allocation before IPAInterface::configure() to pass the table to the IPA. Now that the lens shading table is passed through configure(), starting the IPA early isn't needed anymore. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- .../pipeline/raspberrypi/raspberrypi.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 60b01484b329..137e07379cf5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -302,10 +302,6 @@ public: vcsm_.free(lsTable_); lsTable_ = nullptr; } - - /* Stop the IPA proxy thread. */ - if (ipa_) - ipa_->stop(); } void frameStarted(uint32_t sequence); @@ -787,6 +783,16 @@ int PipelineHandlerRPi::start(Camera *camera) ret = queueAllBuffers(camera); if (ret) { LOG(RPI, Error) << "Failed to queue buffers"; + stop(camera); + return ret; + } + + /* Start the IPA. */ + ret = data->ipa_->start(); + if (ret) { + LOG(RPI, Error) + << "Failed to start IPA for " << camera->name(); + stop(camera); return ret; } @@ -797,8 +803,10 @@ int PipelineHandlerRPi::start(Camera *camera) V4L2DeviceFormat sensorFormat; data->unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); ret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat); - if (ret) + if (ret) { + stop(camera); return ret; + } /* Enable SOF event generation. */ data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true); @@ -842,6 +850,9 @@ void PipelineHandlerRPi::stop(Camera *camera) data->bayerQueue_ = std::queue{}; data->embeddedQueue_ = std::queue{}; + /* Stop the IPA. */ + data->ipa_->stop(); + freeBuffers(camera); } @@ -1094,15 +1105,7 @@ int RPiCameraData::loadIPA() .configurationFile = ipa_->configurationFile(sensor_->model() + ".json") }; - ipa_->init(settings); - - /* - * Startup the IPA thread now. Without this call, none of the IPA API - * functions will run. - * - * It only gets stopped in the class destructor. - */ - return ipa_->start(); + return ipa_->init(settings); } int RPiCameraData::configureIPA() From patchwork Sun Jun 28 23:19:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8493 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 962D1C2E66 for ; Sun, 28 Jun 2020 23:19:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5EADD609DF; Mon, 29 Jun 2020 01:19:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DTAfhe3L"; 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 D6C9F609E1 for ; Mon, 29 Jun 2020 01:19:44 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5EEBD556; Mon, 29 Jun 2020 01:19:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386384; bh=mNlD8aOt+X77E88Mf8ShXjO4b3i+Jz5ItIjT+S1qv0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DTAfhe3LH7A40GgSWhszMiA2KX2VNO9G/qNBngReE+Wff7DGFq2vNJEWf5Q0ufo5B Hvjm+jsv0zFH/NpxJTJuJyYe0fR7Dw1wZvrhCDSp0BhkTqWBLeSnxrJD371kVLp/D8 wR2cJjNKrdtEMYLbZ/ivK59/cyt42XGu2TsDFm8E= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:34 +0300 Message-Id: <20200628231934.29025-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 9/9] libcamera: pipeline: raspberrypi: Don't handle any actions in stop state 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" The RPI_IPA_ACTION_V4L2_SET_ISP is handled regardless of the pipeline handler state, but is only generated by the IPA when the pipeline is running. Don't handle it in the stopped state, which simplifies the handling of actions. Additionally, handleState() is a no-op when the state is State::Stopped, so don't call it in that case. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- .../pipeline/raspberrypi/raspberrypi.cpp | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 137e07379cf5..2a5d27fefe0c 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1190,24 +1190,12 @@ int RPiCameraData::configureIPA() void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData &action) { /* - * The following actions can be handled when the pipeline handler is in - * a stopped state. + * Actions are only handled when the pipeline handler is not in a + * stopped state. */ - switch (action.operation) { - case RPI_IPA_ACTION_V4L2_SET_ISP: { - ControlList controls = action.controls[0]; - isp_[Isp::Input].dev()->setControls(&controls); - goto done; - } - } - if (state_ == State::Stopped) - goto done; + return; - /* - * The following actions must not be handled when the pipeline handler - * is in a stopped state. - */ switch (action.operation) { case RPI_IPA_ACTION_V4L2_SET_STAGGERED: { const ControlList &controls = action.controls[0]; @@ -1216,6 +1204,12 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData break; } + case RPI_IPA_ACTION_V4L2_SET_ISP: { + ControlList controls = action.controls[0]; + isp_[Isp::Input].dev()->setControls(&controls); + break; + } + case RPI_IPA_ACTION_STATS_METADATA_COMPLETE: { unsigned int bufferId = action.data[0]; FrameBuffer *buffer = isp_[Isp::Stats].getBuffers()->at(bufferId).get(); @@ -1253,7 +1247,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData break; } -done: handleState(); }