From patchwork Sat Jul 4 00:52:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8605 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 69CCDBE905 for ; Sat, 4 Jul 2020 00:52:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 80BE860D5E; Sat, 4 Jul 2020 02:52:38 +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="vFbl1E80"; 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 E95E2603BB for ; Sat, 4 Jul 2020 02:52:36 +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 76CD651B; Sat, 4 Jul 2020 02:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823956; bh=2Sh7+X5LCJDZltS7YrZ3EDHVkTSTl+Mg+eJQ2BRTK7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vFbl1E80hojsdBs9TfgZ6db21D16u0DJTEf4nR3ZxqqfaRATcKxGfLny5vl8+23+4 anGdnTF8hOtl4lL4v16Lv8iTJqJ/+m/d3SX7pkKP8rIIUyljsQR3uk/pec7i5DXp0y qIQOhIGpOIfiJ5H7/gLt0quf7iKEkBqvasT6fJ0Q= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:16 +0300 Message-Id: <20200704005227.21782-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 01/12] 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 Sat Jul 4 00:52:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8606 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 2A8EEBE905 for ; Sat, 4 Jul 2020 00:52:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EBC3F60DC7; Sat, 4 Jul 2020 02:52:40 +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="H8Hf42rj"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 67F8D60C59 for ; Sat, 4 Jul 2020 02:52:37 +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 DEB60814; Sat, 4 Jul 2020 02:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823957; bh=yMuCEyeMQ9oHgs15If4sGQMQU1bv/CtTFXhIWI8nu9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H8Hf42rj7C+OV/1ih+s+acBHIoigi31iaAM5kZ5eTQXPwFVUhkZvW4WjTwjZo2wDC Aa7zMpeVvNelv9SuQYFe3cj7LHj/TZ2DgTssPkmGBPtr3utMQE99jSP9a+73Jiqu3f lV1wFuiTpWuJ2DPQpvJBk41q0oX5UHhjoUHb4Z8w= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:17 +0300 Message-Id: <20200704005227.21782-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/12] 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 Sat Jul 4 00:52:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8607 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 D08AFBE905 for ; Sat, 4 Jul 2020 00:52:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85EFC60CBA; Sat, 4 Jul 2020 02:52:41 +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="R1Ra25wb"; 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 CC0B060C59 for ; Sat, 4 Jul 2020 02:52:37 +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 540D929E; Sat, 4 Jul 2020 02:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823957; bh=nTrVu5SlDCIuam0ldFXNawK9SVHnMOKEWEBicC6HVZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R1Ra25wb/fktIFTACx8Be/4lk+qHutkB1NEHnS3KZ2g8lFQB0XfNcUR5zaXrT6WZG 2ctqVeBOa8hF9s1S38bl3sxKfAcOiXEXkGv8Rp3ypzZHmG3qR3YectwxnZ1YE/SYoe cv7/ATVYw7dEULOaC3VuGhDAyrVGZDGa3jjSUfYg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:18 +0300 Message-Id: <20200704005227.21782-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 03/12] 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 Reviewed-by: Jacopo Mondi Reported-by: Coverity CID=294428 --- Changes since v1: - Replace 'response' with 'result' in a comment --- 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..cee532e3a747 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 result. */ + 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 bfd76cff75a4..4bb1627342fd 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 f4966f8628ee..ab4b915156e1 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1035,7 +1035,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 3c3f3f3a8049..3a0195e05824 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 Sat Jul 4 00:52:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8608 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 61B78BE905 for ; Sat, 4 Jul 2020 00:52:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 22EFD60DD1; Sat, 4 Jul 2020 02:52:42 +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="NCp6SMuQ"; 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 6FDA5603BB for ; Sat, 4 Jul 2020 02:52:38 +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 C184F51B; Sat, 4 Jul 2020 02:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823958; bh=vY2MV8vzspMBj7psJvwf3IL25t5Gw12nrd5H7AULwa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NCp6SMuQq2fbbfmTyv+DFSu51d0298NnHeJgO7xDYPVElmyNpFUfysYOOvEsIVu65 qAPaOrPsMI1CmYu1NMmXdHI4jmlhpeQpeBFzfqJezQv2NJ7QRWmLnmUQDvoOdkvLJ0 BiVzG12Do1kJ5IAvDf4w6etKGZbmjqrfPMzGfDIM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:19 +0300 Message-Id: <20200704005227.21782-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 04/12] libcamera: pipeline: raspberrypi: Drop unused local variable 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 variable in PipelineHandlerRPi::start() is unused. Drop it. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ab4b915156e1..db0b20135318 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -787,7 +787,6 @@ int PipelineHandlerRPi::exportFrameBuffers(Camera *camera, Stream *stream, int PipelineHandlerRPi::start(Camera *camera) { RPiCameraData *data = cameraData(camera); - ControlList controls(data->sensor_->controls()); int ret; /* Allocate buffers for internal pipeline usage. */ From patchwork Sat Jul 4 00:52:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8609 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 BB0A8C2E69 for ; Sat, 4 Jul 2020 00:52:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6B2E960D57; Sat, 4 Jul 2020 02:52:42 +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="jtj6Nn5r"; 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 D6DB460D66 for ; Sat, 4 Jul 2020 02:52:38 +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 5E5EB29E; Sat, 4 Jul 2020 02:52:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823958; bh=qbP3Ynsxr47ZYu9MyxvHqqqNPrmmQsz7MkKRtiJD8O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtj6Nn5roIhQF/AbJPH1NKTAK3UaJ1qgDiQKLJoTFadk0uNltN2qWBEKSHzjlJSdZ JXqsp6c7RE5DOkRU5hRpkeZoZe7/2dWx5qjtRrJhfgsa/qfbPBwoWAVSTKl+l2zBED QsrFCIk0yWeXjoDdh7OmvuNoOXV/vOM48+e2CoJs= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:20 +0300 Message-Id: <20200704005227.21782-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 05/12] 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 Sat Jul 4 00:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8610 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 316BBBE905 for ; Sat, 4 Jul 2020 00:52:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C954060DCB; Sat, 4 Jul 2020 02:52:42 +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="MtUOqPvs"; 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 4297B60C59 for ; Sat, 4 Jul 2020 02:52:39 +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 C3EBE51B; Sat, 4 Jul 2020 02:52:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823959; bh=w7VqzKTs46LNXSj6Ac9DsZLU+UyV7pdmQJrUwv0RSwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MtUOqPvsyW7zmq1Gw/Y3iabGKC2R7ksMVW/9la4cvXNOtYdpNixAVjMrHkSbjWELL FTWu1/2C3WHD/nt6in6M6uY0j6XyKiKB0hLskc6HVN7TR2+8HNsoOfGsX77Dz8+7Hw XsVXNfcuJ0nwb4BmtdfhnWlPfwB/Hv1zwiayhmFE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:21 +0300 Message-Id: <20200704005227.21782-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 06/12] 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 | 127 +++++++++--------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index db0b20135318..a05fc68b98fa 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); @@ -765,7 +765,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; @@ -980,67 +980,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. - * - * \todo Sending a pointer to the IPA is a workaround for - * vc_sm_cma not yet supporting dmabuf. This will not work with - * IPA module isolation and should be reworked when vc_sma_cma - * will permit. - */ - 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); @@ -1178,6 +1117,66 @@ 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. + * + * \todo Sending a pointer to the IPA is a workaround for + * vc_sm_cma not yet supporting dmabuf. This will not work with + * IPA module isolation and should be reworked when vc_sma_cma + * will permit. + */ + 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 Sat Jul 4 00:52:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8611 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com 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 905CDC2E69 for ; Sat, 4 Jul 2020 00:52:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 38E2860DC0; Sat, 4 Jul 2020 02:52: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="ESxXZUR6"; 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 A9F6460CAE for ; Sat, 4 Jul 2020 02:52:39 +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 36D2B29E; Sat, 4 Jul 2020 02:52:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823959; bh=cTovLdMVwGYNRuXjbNnWeuW8EJtG+I2TzsX1lrbb+mY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ESxXZUR6cn9M6W5bWLrTk2gZqs5uwQ6jFHfWeJGY20STGVleus6IW7+K3JUY2FPVZ wm5URMbJOzzLDduC61sGH6ddxkbub9VGEwy33j+BWgTtXumIwUjbjlZiWRHUc9w8LO eUMQPsJcneWm1YyCIVlCbrYFkz/9NeEranDo69NE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:22 +0300 Message-Id: <20200704005227.21782-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/12] libcamera: pipeline: raspberrypi: Don't call handleState() 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 handleState() function is a no-op when the state is State::Stopped. Don't call it in that case, which simplifies the caller. Signed-off-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index a05fc68b98fa..74bee6895dcd 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1188,7 +1188,7 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData ControlList controls = action.controls[0]; if (!staggeredCtrl_.set(controls)) LOG(RPI, Error) << "V4L2 staggered set failed"; - goto done; + return; } case RPI_IPA_ACTION_SET_SENSOR_CONFIG: { @@ -1206,18 +1206,18 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData /* Set the sensor orientation here as well. */ ControlList controls = action.controls[0]; unicam_[Unicam::Image].dev()->setControls(&controls); - goto done; + return; } case RPI_IPA_ACTION_V4L2_SET_ISP: { ControlList controls = action.controls[0]; isp_[Isp::Input].dev()->setControls(&controls); - goto done; + return; } } if (state_ == State::Stopped) - goto done; + return; /* * The following actions must not be handled when the pipeline handler @@ -1261,7 +1261,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData break; } -done: handleState(); } From patchwork Sat Jul 4 00:52:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8612 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 53EABBE905 for ; Sat, 4 Jul 2020 00:52:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0650E60DC9; Sat, 4 Jul 2020 02:52: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="Kws3mbSC"; 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 260B660DD5 for ; Sat, 4 Jul 2020 02:52:40 +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 A03B551B; Sat, 4 Jul 2020 02:52:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823959; bh=tZYYYN9GGqLxNhRtKTABpQS2zLJTgxUqy6Y4dv2qgyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kws3mbSC3Jfi6SrNyEot8+KJHMI1KRnJNwYzIMGOKIsj+QSdaxeADZtn45S1yCgtV TRhgWaioS16bnDKExKI7acU52jDkHjUTA5Kl11Qs+Ztrr4ksE118UInG8p/Cegv10A D1v96jlyT6450zhqLIhdw4zrr0KEraEXP8jBkEBw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:23 +0300 Message-Id: <20200704005227.21782-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 08/12] libcamera: pipeline: raspberrypi: Set sensor flip based on rotation 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" Instead of receiving sensor orientation configuration from the IPA, retrieve it from the CameraSensor Rotation property, and configure the HFLIP and VFLIP controls accordingly. Signed-off-by: Laurent Pinchart Reviewed-by: Naushir Patuck --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 74bee6895dcd..fda6831e6a7e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -1174,6 +1175,13 @@ int RPiCameraData::configureIPA() ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, nullptr); + /* Configure the H/V flip controls based on the sensor rotation. */ + ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); + int32_t rotation = sensor_->properties().get(properties::Rotation); + ctrls.set(V4L2_CID_HFLIP, static_cast(!!rotation)); + ctrls.set(V4L2_CID_VFLIP, static_cast(!!rotation)); + unicam_[Unicam::Image].dev()->setControls(&ctrls); + return 0; } @@ -1202,10 +1210,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData { V4L2_CID_EXPOSURE, action.data[1] } }); sensorMetadata_ = action.data[2]; } - - /* Set the sensor orientation here as well. */ - ControlList controls = action.controls[0]; - unicam_[Unicam::Image].dev()->setControls(&controls); return; } From patchwork Sat Jul 4 00:52:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8613 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 B0382C2E69 for ; Sat, 4 Jul 2020 00:52:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 79E1C60DD7; Sat, 4 Jul 2020 02:52: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="mMB/UJi3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81B2A60DD5 for ; Sat, 4 Jul 2020 02:52:40 +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 123BB29E; Sat, 4 Jul 2020 02:52:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823960; bh=jY8vG4dyLHvHcEtgAxUiSJRn+TA/2dEmMNXPVbuI9lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mMB/UJi3EoX16I0wCqHBLo8o78GSYM802lxnHM1CH3Ho6enncOWLgnNetDyb3P19D gCmuXTTd5Q8GBJ/hGe61Ia6xf8gsAJ4f1hcLrsRlrG3/6Z+AgCO4HWfDJIf1uclqe5 NwpGASCI2EtKcmEZk0ixWBtf6F06U9WL4/OXFgZ0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:24 +0300 Message-Id: <20200704005227.21782-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 09/12] ipa: raspberrypi: Drop CameraHelper::GetOrientation() 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 camera sensor orientation is now handled by the pipeline handler. Drop hardcoded per-sensor orientations from the IPA. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.cpp | 6 ------ src/ipa/raspberrypi/cam_helper.hpp | 7 ------- src/ipa/raspberrypi/cam_helper_imx219.cpp | 7 ------- src/ipa/raspberrypi/cam_helper_imx477.cpp | 7 ------- src/ipa/raspberrypi/raspberrypi.cpp | 6 ------ 5 files changed, 33 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index a0c73f99390f..b1343eb2cf4e 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -106,12 +106,6 @@ unsigned int CamHelper::MistrustFramesModeSwitch() const return 0; } -CamTransform CamHelper::GetOrientation() const -{ - /* Most sensors will be mounted the "right" way up? */ - return CamTransform_IDENTITY; -} - RegisterCamHelper::RegisterCamHelper(char const *cam_name, CamHelperCreateFunc create_func) { diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 6877f4735031..97ce3e92ac2f 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -58,12 +58,6 @@ namespace RPi { // (other than start-up), for which control algorithms should not run // (for example, metadata may be unreliable). -// Bitfield to represent the default orientation of the camera. -typedef int CamTransform; -static constexpr CamTransform CamTransform_IDENTITY = 0; -static constexpr CamTransform CamTransform_HFLIP = 1; -static constexpr CamTransform CamTransform_VFLIP = 2; - class CamHelper { public: @@ -82,7 +76,6 @@ public: virtual unsigned int HideFramesModeSwitch() const; virtual unsigned int MistrustFramesStartup() const; virtual unsigned int MistrustFramesModeSwitch() const; - virtual CamTransform GetOrientation() const; protected: MdParser *parser_; CameraMode mode_; diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 35c6597c2016..1b9ce382f330 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -49,7 +49,6 @@ public: double Gain(uint32_t gain_code) const override; unsigned int MistrustFramesModeSwitch() const override; bool SensorEmbeddedDataPresent() const override; - CamTransform GetOrientation() const override; }; CamHelperImx219::CamHelperImx219() @@ -86,12 +85,6 @@ bool CamHelperImx219::SensorEmbeddedDataPresent() const return ENABLE_EMBEDDED_DATA; } -CamTransform CamHelperImx219::GetOrientation() const -{ - /* Camera is "upside down" on this board. */ - return CamTransform_HFLIP | CamTransform_VFLIP; -} - static CamHelper *Create() { return new CamHelperImx219(); diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 695444567bb2..a53b47c013cb 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -38,7 +38,6 @@ public: uint32_t GainCode(double gain) const override; double Gain(uint32_t gain_code) const override; bool SensorEmbeddedDataPresent() const override; - CamTransform GetOrientation() const override; }; CamHelperImx477::CamHelperImx477() @@ -61,12 +60,6 @@ bool CamHelperImx477::SensorEmbeddedDataPresent() const return true; } -CamTransform CamHelperImx477::GetOrientation() const -{ - /* Camera is "upside down" on this board. */ - return CamTransform_HFLIP | CamTransform_VFLIP; -} - static CamHelper *Create() { return new CamHelperImx477(); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 860be22ddb5d..b40ca9e44776 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -215,7 +215,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, int gainDelay, exposureDelay, sensorMetadata; helper_->GetDelays(exposureDelay, gainDelay); sensorMetadata = helper_->SensorEmbeddedDataPresent(); - RPi::CamTransform orientation = helper_->GetOrientation(); IPAOperationData op; op.operation = RPI_IPA_ACTION_SET_SENSOR_CONFIG; @@ -223,11 +222,6 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, op.data.push_back(exposureDelay); op.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); - queueFrameAction.emit(0, op); } From patchwork Sat Jul 4 00:52:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8614 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 17F7BBE905 for ; Sat, 4 Jul 2020 00:52:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D07FF60D4D; Sat, 4 Jul 2020 02:52: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="Vyl7heUS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F3C9460DE2 for ; Sat, 4 Jul 2020 02:52:40 +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 7741C814; Sat, 4 Jul 2020 02:52:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823960; bh=VPCmnQ4YuricgbO9cwtAVoaM5klyPxzflzhZGXoJrbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vyl7heUSsFB88JELOi6J6ZpSdYE6ACK7meIR8f643XSEX095HHcoHU5zSGzyfH9st LNquqb4BP9YLH2XCncjo0NVgapf/ljsZ/LN8uSeEFoDFoSUPKu1H3aU5MJewo57eMb xSi1YR6kzdPk4fV1WU+QrhnMfZ+51prk+SomjaPM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:25 +0300 Message-Id: <20200704005227.21782-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/12] 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::configure() function 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 --- Changes since v1: - Update the commit message - Rename RPI_IPA_CONFIG_LSTABLE to RPI_IPA_CONFIG_LS_TABLE --- 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..46ce7c286b20 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -10,6 +10,10 @@ #include #include +enum RPiConfigParameters { + RPI_IPA_CONFIG_LS_TABLE = (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 b40ca9e44776..0e39a1137cd0 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -271,6 +271,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_LS_TABLE) { + lsTable_ = reinterpret_cast(ipaConfig.data[0]); + lsTableHandle_ = ipaConfig.data[1]; + } } void IPARPi::mapBuffers(const std::vector &buffers) @@ -352,12 +358,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 fda6831e6a7e..57602349cab2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1122,6 +1122,7 @@ int RPiCameraData::configureIPA() { std::map streamConfig; std::map entityControls; + IPAOperationData ipaConfig = {}; /* Get the device format to pass to the IPA. */ V4L2DeviceFormat sensorFormat; @@ -1156,11 +1157,9 @@ int RPiCameraData::configureIPA() * IPA module isolation and should be reworked when vc_sma_cma * will permit. */ - 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_LS_TABLE; + ipaConfig.data = { static_cast(ptr & 0xffffffff), + vcsm_.getVCHandle(lsTable_) }; } CameraSensorInfo sensorInfo = {}; @@ -1171,7 +1170,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 Sat Jul 4 00:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8615 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 66127C2E69 for ; Sat, 4 Jul 2020 00:52:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F7DF60DF2; Sat, 4 Jul 2020 02:52:45 +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="OMQvYHoD"; 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 E502760DC9 for ; Sat, 4 Jul 2020 02:52: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 EA70D29E; Sat, 4 Jul 2020 02:52:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823961; bh=b1MAJ6i5kiwK5ibfTdH4Sb02HljK5Xih1Dq2N9FPuZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OMQvYHoDSzZPOpdFQY3Qk4XngWvpJhEgl5/Vs3hD/HI+xYRDu+AGtDOCAihYhL3vL pGAdi0gJy2sLczwrws6+2BOHT3+aqL4I7Am8TGu6poH77Kgy/ejvHDgbsmCq8dj0vN uzJKIBfT8d6flPf2Db3nexxSyPeNkR7RXvp7D2Jk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:26 +0300 Message-Id: <20200704005227.21782-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 11/12] 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 the custom RPI_IPA_ACTION_SET_SENSOR_CONFIG frame action to send the sensor staggered write 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 Reviewed-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- Changes since v1: - Restore RPI_IPA_ACTION_V4L2_SET_ISP handling in stop state - Drop sensor orientation handling based on IPA result --- include/libcamera/ipa/raspberrypi.h | 3 +- src/ipa/raspberrypi/raspberrypi.cpp | 42 ++++++++------- .../pipeline/raspberrypi/raspberrypi.cpp | 53 +++++++++++-------- 3 files changed, 56 insertions(+), 42 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 46ce7c286b20..a49377695f22 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -12,6 +12,8 @@ enum RPiConfigParameters { RPI_IPA_CONFIG_LS_TABLE = (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 0e39a1137cd0..378ea309fa81 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. */ @@ -216,13 +218,11 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, helper_->GetDelays(exposureDelay, gainDelay); sensorMetadata = helper_->SensorEmbeddedDataPresent(); - 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); - queueFrameAction.emit(0, op); + result->operation |= RPI_IPA_CONFIG_STAGGERED_WRITE; } /* Re-assemble camera mode using the sensor info. */ @@ -267,8 +267,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_; @@ -775,8 +780,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) @@ -802,11 +814,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); @@ -825,11 +834,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 57602349cab2..9babf9f4a19c 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -819,7 +819,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(); @@ -1170,15 +1170,36 @@ int RPiCameraData::configureIPA() } /* Ready the IPA - it must know about the sensor resolution. */ + IPAOperationData result; + ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, - nullptr); + &result); - /* Configure the H/V flip controls based on the sensor rotation. */ - ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); - int32_t rotation = sensor_->properties().get(properties::Rotation); - ctrls.set(V4L2_CID_HFLIP, static_cast(!!rotation)); - ctrls.set(V4L2_CID_VFLIP, static_cast(!!rotation)); - unicam_[Unicam::Image].dev()->setControls(&ctrls); + 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, result.data[0] }, + { V4L2_CID_EXPOSURE, result.data[1] } }); + sensorMetadata_ = result.data[2]; + } + + /* Configure the H/V flip controls based on the sensor rotation. */ + ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); + int32_t rotation = sensor_->properties().get(properties::Rotation); + ctrls.set(V4L2_CID_HFLIP, static_cast(!!rotation)); + ctrls.set(V4L2_CID_VFLIP, static_cast(!!rotation)); + unicam_[Unicam::Image].dev()->setControls(&ctrls); + } + + if (result.operation & RPI_IPA_CONFIG_SENSOR) { + const ControlList &ctrls = result.controls[0]; + if (!staggeredCtrl_.set(ctrls)) + LOG(RPI, Error) << "V4L2 staggered set failed"; + } return 0; } @@ -1191,26 +1212,12 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData */ switch (action.operation) { case RPI_IPA_ACTION_V4L2_SET_STAGGERED: { - ControlList controls = action.controls[0]; + const ControlList &controls = action.controls[0]; if (!staggeredCtrl_.set(controls)) LOG(RPI, Error) << "V4L2 staggered set failed"; return; } - case RPI_IPA_ACTION_SET_SENSOR_CONFIG: { - /* - * 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]; - } - return; - } - case RPI_IPA_ACTION_V4L2_SET_ISP: { ControlList controls = action.controls[0]; isp_[Isp::Input].dev()->setControls(&controls); From patchwork Sat Jul 4 00:52: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: 8616 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 C21ECBE905 for ; Sat, 4 Jul 2020 00:52:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8ABAC60DF3; Sat, 4 Jul 2020 02:52:45 +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="PcC8wWHm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 723E460DE4 for ; Sat, 4 Jul 2020 02:52: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 EC771814; Sat, 4 Jul 2020 02:52:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823962; bh=KyOfb9eDOXqb+ehjjLEXoRYfLNnQuSMh6/4DDgSR4lA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcC8wWHmDDTMGVbceQRv5IR7CaZWSiRz3TzDPW2SFGyRljL9aCXMzf/bdZeGVAWNS CEVQwTVQ64yX+dIHBlAQBEsc3tTHj22eL83+En4AOFzp7JWlT8FIkFUTxU2PHhGBpE dhdMWulRkB9cNFAA8FL2lS2iHymdWHPRnzC939I0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:27 +0300 Message-Id: <20200704005227.21782-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 12/12] 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 Reviewed-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- .../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 9babf9f4a19c..c877820a6e1e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -303,10 +303,6 @@ public: vcsm_.free(lsTable_); lsTable_ = nullptr; } - - /* Stop the IPA proxy thread. */ - if (ipa_) - ipa_->stop(); } void frameStarted(uint32_t sequence); @@ -800,6 +796,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; } @@ -810,8 +816,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); @@ -855,6 +863,9 @@ void PipelineHandlerRPi::stop(Camera *camera) data->bayerQueue_ = std::queue{}; data->embeddedQueue_ = std::queue{}; + /* Stop the IPA. */ + data->ipa_->stop(); + freeBuffers(camera); } @@ -1107,15 +1118,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()