From patchwork Fri Jun 5 09:01:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 3937 Return-Path: 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 5AAFB61375 for ; Fri, 5 Jun 2020 11:01:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AqUswxUR"; dkim-atps=neutral Received: from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp [118.238.243.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2480327C; Fri, 5 Jun 2020 11:01:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591347679; bh=yylEpV+peh6zKRxo/3lJOgX0clLhFV5SY/1JmZdufnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AqUswxURYp9Z0Cj3ZVOmUOItzZjuLwoMCBnY06mKWrGX+WI3EIbunzmwrd1gwU6TY /5QSR3mr7EnfXk8DSppGANU0AWLnaG8wkgje2GqIlcvWGr5AVtGxoRNFYOZPLHHXYT P4pXZByPmb8riHQxu/8GTUegS3Bmsm8V3ti34cH4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 5 Jun 2020 18:01:01 +0900 Message-Id: <20200605090106.15424-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200605090106.15424-1-paul.elder@ideasonboard.com> References: <20200605090106.15424-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/7] IPAManager: remove instance() and make createIPA() static 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: , X-List-Received-Date: Fri, 05 Jun 2020 09:01:19 -0000 As the only usage of IPAManager::instance() is by the pipeline handlers to call IPAManager::createIPA(), remove the former and make the latter static. Update the pipeline handlers and tests accordingly. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- New in v2 --- include/libcamera/internal/ipa_manager.h | 8 +++----- src/libcamera/ipa_manager.cpp | 18 ++---------------- .../pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- test/ipa/ipa_interface_test.cpp | 2 +- 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index 43f700d3..05643e5e 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -25,11 +25,9 @@ public: IPAManager(); ~IPAManager(); - static IPAManager *instance(); - - std::unique_ptr createIPA(PipelineHandler *pipe, - uint32_t maxVersion, - uint32_t minVersion); + static std::unique_ptr createIPA(PipelineHandler *pipe, + uint32_t maxVersion, + uint32_t minVersion); private: static IPAManager *self_; diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index abb681a3..9d0c2069 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -159,20 +159,6 @@ IPAManager::~IPAManager() self_ = nullptr; } -/** - * \brief Retrieve the IPA manager instance - * - * The IPAManager is a singleton and can't be constructed manually. This - * function shall instead be used to retrieve the single global instance of the - * manager. - * - * \return The IPA manager instance - */ -IPAManager *IPAManager::instance() -{ - return self_; -} - /** * \brief Identify shared library objects within a directory * \param[in] libDir The directory to search for shared objects @@ -274,7 +260,7 @@ std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, { IPAModule *m = nullptr; - for (IPAModule *module : modules_) { + for (IPAModule *module : self_->modules_) { if (module->match(pipe, minVersion, maxVersion)) { m = module; break; @@ -290,7 +276,7 @@ std::unique_ptr IPAManager::createIPA(PipelineHandler *pipe, * * \todo Implement a better proxy selection */ - const char *proxyName = isSignatureValid(m) + const char *proxyName = self_->isSignatureValid(m) ? "IPAProxyThread" : "IPAProxyLinux"; IPAProxyFactory *pf = nullptr; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index e16a9c7f..b9b88506 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1118,7 +1118,7 @@ void RPiCameraData::frameStarted(uint32_t sequence) int RPiCameraData::loadIPA() { - ipa_ = IPAManager::instance()->createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe_, 1, 1); if (!ipa_) return -ENOENT; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index d807fc2c..900f873a 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -395,7 +395,7 @@ private: int RkISP1CameraData::loadIPA() { - ipa_ = IPAManager::instance()->createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe_, 1, 1); if (!ipa_) return -ENOENT; diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index ba9fca50..3881545b 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -410,7 +410,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) std::unique_ptr data = std::make_unique(this, media); - data->ipa_ = IPAManager::instance()->createIPA(this, 0, 0); + data->ipa_ = IPAManager::createIPA(this, 0, 0); if (data->ipa_ != nullptr) { std::string conf = data->ipa_->configurationFile("vimc.conf"); data->ipa_->init(IPASettings{ conf }); diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 153493ba..1bc93a63 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -95,7 +95,7 @@ protected: EventDispatcher *dispatcher = thread()->eventDispatcher(); Timer timer; - ipa_ = IPAManager::instance()->createIPA(pipe_.get(), 0, 0); + ipa_ = IPAManager::createIPA(pipe_.get(), 0, 0); if (!ipa_) { cerr << "Failed to create VIMC IPA interface" << endl; return TestFail;