From patchwork Thu Jun 18 10:18:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26916 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 16C4CC328C for ; Thu, 18 Jun 2026 10:18:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E6F10629A1; Thu, 18 Jun 2026 12:18:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J5WakPjz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F3C361754 for ; Thu, 18 Jun 2026 12:18:53 +0200 (CEST) Received: from [192.168.125.177] (mob-109-113-4-199.net.vodafone.it [109.113.4.199]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 832B5DF3; Thu, 18 Jun 2026 12:18:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1781777898; bh=WwkJjfrF6uYuCHNyMbb4OBFHOUidZxlMMtRfcHXwSLM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=J5WakPjzxYmzs57OvZ0agjyd2yJTgNKkxAxEPVlxRCFJCp8VDHL4dYEKk1hnZq9LG 6vGt2wxVWVjb0RnpDwEz355010ar5gVxt5CPT/wrdujLBz8X6bR328J8gEgBDED1cK JuPNMoze4/YmbWL5lwXyg9d5zum2blfsRwsXfsww= From: Jacopo Mondi Date: Thu, 18 Jun 2026 12:18:40 +0200 Subject: [PATCH 01/14] libcamera: ipa_manager: Create IPA by name MIME-Version: 1.0 Message-Id: <20260618-rppx1-ipa-v1-1-32337264cfcd@ideasonboard.com> References: <20260618-rppx1-ipa-v1-0-32337264cfcd@ideasonboard.com> In-Reply-To: <20260618-rppx1-ipa-v1-0-32337264cfcd@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Hans de Goede , Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=8374; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=vuESyGRD9gC1WcSe588Ai3/ECLPgRNN9wbmW63B/y8U=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqM8YJ492R/nzPIuuD+HrJxEyHuf4ydkH6R0+ld ntefURsa9uJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCajPGCQAKCRByNAaPFqFW PBtlD/0WjS/gn5GpQrDn/rLmNWxPL2az+iWmgIEw74PosfcBJTk6w5hAbE9cI6fK14wgvBy/e+w 1K3KktK2BxC0ZWSIsHumLgSe036kX7/36rXex6WZuhnm9vop/e4XoOEYuaBOoWIeJCDNSq9A4sG 6jmj49oBUWinRJOpY1/L0h0yM/q2jyCi2RjGFqVjtkkZr61BwxEnx7/rsnbpoKPVzB6O47rUdFP 3zpJQo1tNGIKBHHZaEiVzmBMjMiq2bwYxmer0pokADqpm99esMw38FElNLtVYw4CJcqHMr0gLdT GhUAc3VRhB+8THXCnVj+I6tKeQNy68/wIHh5Sb884GRDJivM9c76axVafLkJXSusIFCPeu1uLmM tjVKWiuuSUmN8h2xyfMDK7OrXbNdWkxs556Ear7hXTL0CKiXpaVr1pnSb1z41J9KVAZ4S4WKZcc PkDNgMpDfh57UhBvS2Sc4W+iWmeszYCjEo9A/tgBbndzBVm92KTccIUpWfXwsWhj8fdC0IpCTIe Ra4sVkM+dB0jvAqlQ3qfSpYthvNWi7phJjySJFq1fs/e8H8PcZ+s5k0+tF6ROaGut7agCRmwvSQ vmlLNhjfxuS6Njpi5LTnnGEL9irP69apo3HBPT+tqcc0iAEeWtyLZyRBbolPPkbSPnJq8XAsGna Gck2cSGuIG6TL3g== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" From: Hans de Goede Currently createIPA() / IPAManager::module() assume that there is a 1:1 relationship between pipeline handlers and IPAs and IPA matching is done based on matching the pipe to ipaModuleInfo.pipelineName[]. One way to allow using a single IPA with multiple pipelines would be to allow the IPA to declare itself compatible with more than one pipeline, turning ipaModuleInfo.pipelineName[] into e.g. a vector. But the way ipaModuleInfo is loaded as an ELF symbol requires it to be a simple flat C-struct. Instead, move the IPA creation procedure to be name-based, introducing an overload to IPAManager::createIPA(pipe, name, minVer, maxVer) that allows to specify the name of the IPA module to match. Pipeline handlers that wants to use their name as matching criteria can continue doing so using the already existing createIPA(pipe, minVer, maxVer) overload. Signed-off-by: Hans de Goede Signed-off-by: Jacopo Mondi Reviewed-by: Hans de Goede Reviewed-by: Kieran Bingham Tested-by: Niklas Söderlund --- include/libcamera/internal/ipa_manager.h | 8 +++---- include/libcamera/internal/ipa_module.h | 4 ++-- include/libcamera/internal/pipeline_handler.h | 9 ++++++- src/libcamera/ipa_manager.cpp | 34 ++++++++++++++++++++++----- src/libcamera/ipa_module.cpp | 12 +++++----- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index aaa3ca37c493..b9825c38d34e 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -25,7 +25,6 @@ LOG_DECLARE_CATEGORY(IPAManager) class CameraManager; class GlobalConfiguration; class IPAModule; -class PipelineHandler; class IPAManager { @@ -34,10 +33,11 @@ public: ~IPAManager(); template - std::unique_ptr createIPA(PipelineHandler *pipe, uint32_t minVersion, + std::unique_ptr createIPA(const char *name, + uint32_t minVersion, uint32_t maxVersion) { - IPAModule *m = module(pipe, minVersion, maxVersion); + IPAModule *m = module(name, minVersion, maxVersion); if (!m) return nullptr; @@ -68,7 +68,7 @@ private: std::vector &files); unsigned int addDir(const char *libDir, unsigned int maxDepth = 0); - IPAModule *module(PipelineHandler *pipe, uint32_t minVersion, + IPAModule *module(const char *name, uint32_t minVersion, uint32_t maxVersion); bool isSignatureValid(IPAModule *ipa) const; diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h index 15f19492c3a0..a0a53764e139 100644 --- a/include/libcamera/internal/ipa_module.h +++ b/include/libcamera/internal/ipa_module.h @@ -36,8 +36,8 @@ public: IPAInterface *createInterface(); - bool match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const; + bool match(const char *name, uint32_t minVersion, + uint32_t maxVersion) const; protected: std::string logPrefix() const override; diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 6922ce18ec87..d255c149f2f3 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -76,7 +76,14 @@ public: std::unique_ptr createIPA(uint32_t minVersion, uint32_t maxVersion) { IPAManager *ipaManager = manager_->_d()->ipaManager(); - return ipaManager->createIPA(this, minVersion, maxVersion); + return ipaManager->createIPA(this->name(), minVersion, maxVersion); + } + + template + std::unique_ptr createIPA(const char *name, uint32_t minVersion, uint32_t maxVersion) + { + IPAManager *ipaManager = manager_->_d()->ipaManager(); + return ipaManager->createIPA(name, minVersion, maxVersion); } protected: diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 41918e4c2934..e60e947049d5 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -248,15 +248,15 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) /** * \brief Retrieve an IPA module that matches a given pipeline handler - * \param[in] pipe The pipeline handler + * \param[in] name The IPA module string identifier * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module */ -IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, +IPAModule *IPAManager::module(const char *name, uint32_t minVersion, uint32_t maxVersion) { for (const auto &module : modules_) { - if (module->match(pipe, minVersion, maxVersion)) + if (module->match(name, minVersion, maxVersion)) return module.get(); } @@ -264,12 +264,34 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, } /** - * \fn IPAManager::createIPA() - * \brief Create an IPA proxy that matches a given pipeline handler - * \param[in] pipe The pipeline handler that wants a matching IPA proxy + * \fn IPAManager::createIPA(PipelineHandler *pipe, const char *ipaName, uint32_t minVersion, uint32_t maxVersion) + * \brief Create an IPA proxy that matches the requested name and version + * \param[in] pipe The pipeline handler that wants to create the IPA module + * \param[in] ipaName The IPA module name * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module * + * Create an IPA module using \a name as the matching identifier. This overload + * allows pipeline handlers to create an IPA module by specifying its name + * instead of relying on the fact that the IPA module matches the pipeline + * handler's one. + * + * \return A newly created IPA proxy, or nullptr if no matching IPA module is + * found or if the IPA proxy fails to initialize + */ + +/** + * \fn IPAManager::createIPA(PipelineHandler *pipe, uint32_t minVersion, uint32_t maxVersion) + * \brief Create an IPA proxy that matches the pipeline handler name and the + * requested version + * \param[in] pipe The pipeline handler that wants to create the IPA module + * \param[in] minVersion Minimum acceptable version of IPA module + * \param[in] maxVersion Maximum acceptable version of IPA module + * + * Create an IPA module using the pipeline handler name as the matching + * identifier. This overload allows pipeline handler to create an IPA module + * whose name matches the pipeline handler one. + * * \return A newly created IPA proxy, or nullptr if no matching IPA module is * found or if the IPA proxy fails to initialize */ diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index e6ea61e44829..0bd6f14626fe 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -463,21 +463,21 @@ IPAInterface *IPAModule::createInterface() /** * \brief Verify if the IPA module matches a given pipeline handler - * \param[in] pipe Pipeline handler to match with + * \param[in] name The IPA module name * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module * - * This function checks if this IPA module matches the \a pipe pipeline handler, + * This function checks if this IPA module matches the requested \a name * and the input version range. * - * \return True if the pipeline handler matches the IPA module, or false otherwise + * \return True if the IPA module matches, or false otherwise */ -bool IPAModule::match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const +bool IPAModule::match(const char *name, uint32_t minVersion, + uint32_t maxVersion) const { return info_.pipelineVersion >= minVersion && info_.pipelineVersion <= maxVersion && - !strcmp(info_.pipelineName, pipe->name()); + !strcmp(info_.name, name); } std::string IPAModule::logPrefix() const