[PATCH 7/8] libcamera: ipa_manager: createIPA: Allow passing an IPA name to match

Hans de Goede hdegoede at redhat.com
Sun Nov 3 16:22:04 CET 2024


Parts of the software ISP and the ipa_soft_simple.so IPA may be useful for
more then 1 pipeline handler.

Currently createIPA() / IPAManager::module() assume that there is a 1:1
relationship between pipeline handlers and IPAs and IPA matching is done
based on pipe->name().

Add an optional ipaName argument to createIPA() which when set overrides
pipe->name(), allowing pipeline handlers to request a different IPA.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 include/libcamera/internal/ipa_manager.h | 11 ++++++++---
 include/libcamera/internal/ipa_module.h  |  2 +-
 src/libcamera/ipa_manager.cpp            |  7 ++++---
 src/libcamera/ipa_module.cpp             |  6 +++---
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h
index 16dede0c..1bbb0011 100644
--- a/include/libcamera/internal/ipa_manager.h
+++ b/include/libcamera/internal/ipa_manager.h
@@ -33,11 +33,16 @@ public:
 	template<typename T>
 	static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
 					    uint32_t minVersion,
-					    uint32_t maxVersion)
+					    uint32_t maxVersion,
+					    const char *ipaName = NULL)
 	{
 		CameraManager *cm = pipe->cameraManager();
 		IPAManager *self = cm->_d()->ipaManager();
-		IPAModule *m = self->module(pipe, minVersion, maxVersion);
+
+		if (!ipaName)
+			ipaName = pipe->name();
+
+		IPAModule *m = self->module(ipaName, minVersion, maxVersion);
 		if (!m)
 			return nullptr;
 
@@ -62,7 +67,7 @@ private:
 		      std::vector<std::string> &files);
 	unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
 
-	IPAModule *module(PipelineHandler *pipe, uint32_t minVersion,
+	IPAModule *module(const char *pipelineName, 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 7c49d3f3..f732b0b0 100644
--- a/include/libcamera/internal/ipa_module.h
+++ b/include/libcamera/internal/ipa_module.h
@@ -36,7 +36,7 @@ public:
 
 	IPAInterface *createInterface();
 
-	bool match(PipelineHandler *pipe,
+	bool match(const char *pipelineName,
 		   uint32_t minVersion, uint32_t maxVersion) const;
 
 protected:
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp
index cfc24d38..a5427ef3 100644
--- a/src/libcamera/ipa_manager.cpp
+++ b/src/libcamera/ipa_manager.cpp
@@ -243,15 +243,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] pipelineName The pipeline handler name
  * \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 *pipelineName, uint32_t minVersion,
 			      uint32_t maxVersion)
 {
 	for (IPAModule *module : modules_) {
-		if (module->match(pipe, minVersion, maxVersion))
+		if (module->match(pipelineName, minVersion, maxVersion))
 			return module;
 	}
 
@@ -264,6 +264,7 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion,
  * \param[in] pipe The pipeline handler that wants a matching IPA proxy
  * \param[in] minVersion Minimum acceptable version of IPA module
  * \param[in] maxVersion Maximum acceptable version of IPA module
+ * \param[in] ipaName overrides pipe->name() for IPA module matching if set
  *
  * \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 9ca74be6..7392e356 100644
--- a/src/libcamera/ipa_module.cpp
+++ b/src/libcamera/ipa_module.cpp
@@ -463,7 +463,7 @@ IPAInterface *IPAModule::createInterface()
 
 /**
  * \brief Verify if the IPA module matches a given pipeline handler
- * \param[in] pipe Pipeline handler to match with
+ * \param[in] pipelineName Pipeline handler name to match with
  * \param[in] minVersion Minimum acceptable version of IPA module
  * \param[in] maxVersion Maximum acceptable version of IPA module
  *
@@ -472,12 +472,12 @@ IPAInterface *IPAModule::createInterface()
  *
  * \return True if the pipeline handler matches the IPA module, or false otherwise
  */
-bool IPAModule::match(PipelineHandler *pipe,
+bool IPAModule::match(const char *pipelineName,
 		      uint32_t minVersion, uint32_t maxVersion) const
 {
 	return info_.pipelineVersion >= minVersion &&
 	       info_.pipelineVersion <= maxVersion &&
-	       !strcmp(info_.pipelineName, pipe->name());
+	       !strcmp(info_.pipelineName, pipelineName);
 }
 
 std::string IPAModule::logPrefix() const
-- 
2.47.0



More information about the libcamera-devel mailing list