[libcamera-devel,v3,06/10] libcamera: ipa_module: match IPA module with pipeline handler

Message ID 20190605005316.4835-7-paul.elder@ideasonboard.com
State Accepted
Headers show
Series
  • Add IPAManager and IPAInterface
Related show

Commit Message

Paul Elder June 5, 2019, 12:53 a.m. UTC
Add a method to IPAModule to check if it matches with a given pipeline
handler and pipeline version range.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes in v3:
- match() now takes a version range from the caller to match against,
  instead of getting a version number from the pipeline handler input

v2: New patch, but this IPAModule::match method used to be IPAManager::match

 src/libcamera/include/ipa_module.h |  5 +++++
 src/libcamera/ipa_module.cpp       | 20 ++++++++++++++++++++
 2 files changed, 25 insertions(+)

Patch

diff --git a/src/libcamera/include/ipa_module.h b/src/libcamera/include/ipa_module.h
index 7ac5cad..fec4237 100644
--- a/src/libcamera/include/ipa_module.h
+++ b/src/libcamera/include/ipa_module.h
@@ -13,6 +13,8 @@ 
 #include <libcamera/ipa/ipa_interface.h>
 #include <libcamera/ipa/ipa_module_info.h>
 
+#include "pipeline_handler.h"
+
 namespace libcamera {
 
 class IPAModule
@@ -29,6 +31,9 @@  public:
 
 	std::unique_ptr<IPAInterface> createInstance();
 
+	bool match(PipelineHandler *pipe,
+		   uint32_t minVersion, uint32_t maxVersion) const;
+
 private:
 	struct IPAModuleInfo info_;
 
diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp
index 8ec4e5a..09e96b4 100644
--- a/src/libcamera/ipa_module.cpp
+++ b/src/libcamera/ipa_module.cpp
@@ -18,6 +18,7 @@ 
 #include <unistd.h>
 
 #include "log.h"
+#include "pipeline_handler.h"
 
 /**
  * \file ipa_module.h
@@ -389,4 +390,23 @@  std::unique_ptr<IPAInterface> IPAModule::createInstance()
 	return std::unique_ptr<IPAInterface>(ipaCreate_());
 }
 
+/**
+ * \brief Verify if the IPA module maches a given pipeline handler
+ * \param[in] pipe Pipeline handler to match with
+ * \param[in] minVersion Minimum acceptable version of IPA module
+ * \param[in] maxVersion Maximum acceptable version of IPA module
+ *
+ * This method checks if this IPA module matches the \a pipe pipeline handler,
+ * and the input version range.
+ *
+ * \return True if the pipeline handler matches the IPA module, or false otherwise
+ */
+bool IPAModule::match(PipelineHandler *pipe,
+		      uint32_t minVersion, uint32_t maxVersion) const
+{
+	return info_.pipelineVersion >= minVersion &&
+	       info_.pipelineVersion <= maxVersion &&
+	       !strcmp(info_.pipelineName, pipe->name());
+}
+
 } /* namespace libcamera */