From patchwork Fri Oct 3 16:16:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 24563 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 53F9EBF415 for ; Fri, 3 Oct 2025 16:16:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 94BAA6B5F8; Fri, 3 Oct 2025 18:16:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FBcTf5cD"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B2FB16B5C2 for ; Fri, 3 Oct 2025 18:16:43 +0200 (CEST) Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B8D761F16; Fri, 3 Oct 2025 18:15:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759508113; bh=lBO0uo2legv1RFpoVoJNs/0maL1XDu+CGupwbB9YZ8g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FBcTf5cDTbUs34p5W/NCXWkaVxNHUz6ZRirXPRWj3+s5YdvIzRzPYbSjP4xe85vRF JjEUONRxqvENlnRvz5U/FUjAi+CvOcQO4OkyJejNwD4nMN/w2OxrsM0hYGtvdcWizD 9DMVfLbwmHBQXEdKQubKcSbAULLA0JNVauq+MqnU= From: Jacopo Mondi Date: Fri, 03 Oct 2025 18:16:31 +0200 Subject: [PATCH v2 1/2] libcamera: ipa_manager: Create IPA by name MIME-Version: 1.0 Message-Id: <20251003-ipa-match-by-name-v2-1-54f3cd828ddd@ideasonboard.com> References: <20251003-ipa-match-by-name-v2-0-54f3cd828ddd@ideasonboard.com> In-Reply-To: <20251003-ipa-match-by-name-v2-0-54f3cd828ddd@ideasonboard.com> To: libcamera-devel@lists.libcamera.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Hans de Goede Cc: Jacopo Mondi , Kieran Bingham X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7914; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=qlnCgwYcVWfZj6RiMuGlvvd+UXFnC8YG+UkcFe7KCUI=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBo3/bpxEVpsSFpl3XAry3dqPmV3+zbbi+CYIklh Nux/z1CqLuJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaN/26QAKCRByNAaPFqFW PHZYD/45iwqNZ58xsBbik7D4VqOOJflC4hbNQhnl/pErqK1zpst5mHLQ6IACWvoHvETnJJzLSlF DbZ2ssKnzFvvQbOwninU+C14JD3ajx3JHrTwM8Jc0HwJpEJbwl4CTWum1ef/SxxHtw3fQXl5bbx tN/o00fHt0z2cd3CyTY0BEf+dGKlyGqbzR/j9SPa0GC71uba8lPM/7yTDimZm+uijZsSr7ZosGy BNB//KkxJ2QCvqW0in64z7QYBtSUz1Jz4gDBIWdIs9muN/vRXyISH8CQp7Unf3Qlt+jk5q9j3mD +sPLFUUntI6dJE2uSWV2A7InxaInNvrWB9IOrG6K07XXDZnR0h76aPyOArqDoJOia6ig24K91L2 YNAoFhr30/4Q33N/joXedzlcG99w7JZoDmfbDjOw8Fsqs6/zpwUroriUElm2CwfURRn6uoFqJS8 Q4JBz+q4ORnhZd0bcHAZybCjZxGIBbiVBcm5Tj7bJLZ4tRZVRNNy82XFXj0AY4yXFPRc12iZCqJ OAoSCG6iV9hI3Y/fO6be+rw1S9jM4DGr2SDhyCk4T83Fpb8ZPhwsKZMAy1Gfz5qVehP2mrWAGbH OJLrAR8A76tgiXE4tnid/17nS4q1qw7eW44S5NkEJyGJibrmB7KoCYTnTjRHkeTkG9yKfu49ZDP W8e0YUZcA6OlwGQ== 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 Reviewed-by: Barnabás Pőcze --- include/libcamera/internal/ipa_manager.h | 13 ++++++++++-- include/libcamera/internal/ipa_module.h | 4 ++-- src/libcamera/ipa_manager.cpp | 34 ++++++++++++++++++++++++++------ src/libcamera/ipa_module.cpp | 12 +++++------ 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index f8ce780169e617088557888d7c8dae2d3f10ec08..4c01e76f1800120f0baca25bc2e5e251f7cf80b5 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -34,12 +34,13 @@ public: template static std::unique_ptr createIPA(PipelineHandler *pipe, + const char *name, uint32_t minVersion, uint32_t maxVersion) { CameraManager *cm = pipe->cameraManager(); IPAManager *self = cm->_d()->ipaManager(); - IPAModule *m = self->module(pipe, minVersion, maxVersion); + IPAModule *m = self->module(name, minVersion, maxVersion); if (!m) return nullptr; @@ -60,6 +61,14 @@ public: return proxy; } + template + static std::unique_ptr createIPA(PipelineHandler *pipe, + uint32_t minVersion, + uint32_t maxVersion) + { + return createIPA(pipe, pipe->name(), minVersion, maxVersion); + } + #if HAVE_IPA_PUBKEY static const PubKey &pubKey() { @@ -72,7 +81,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 15f19492c3a027a0bc4f9572188d13af41fcd450..a0a53764e1394abed3bab92cdde9f33a86441c5f 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/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 35171d097136a6d85b8f518c099f8228f9eacd6f..f62a4ee5fd012d23ce178d59f84c6ab49513376b 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -247,15 +247,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(); } @@ -263,12 +263,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 e6ea61e4482983a83b4185c4309f2c514ed24fc2..0bd6f14626fe2038072f48b70ca4341b0eb8cef5 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