[libcamera-devel] [RFC PATCH 06/10] libcamera: ipa_manager: add shims

Paul Elder paul.elder at ideasonboard.com
Thu Jun 6 00:18:13 CEST 2019


Make IPAManager load shim shared objects in addition to IPA module
shared objects, and keep them in a shims list. When requested for an
IPA, if the IPA requires isolation, wrap the IPA in the first shim that
is available.

Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
 src/libcamera/include/ipa_manager.h |  1 +
 src/libcamera/ipa_manager.cpp       | 34 +++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h
index 310ce7c..a0fb8ad 100644
--- a/src/libcamera/include/ipa_manager.h
+++ b/src/libcamera/include/ipa_manager.h
@@ -28,6 +28,7 @@ public:
 
 private:
 	std::vector<IPAModule *> modules_;
+	std::vector<IPAModule *> shims_;
 
 	IPAManager();
 	~IPAManager();
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp
index f689aa6..3648ea6 100644
--- a/src/libcamera/ipa_manager.cpp
+++ b/src/libcamera/ipa_manager.cpp
@@ -110,7 +110,10 @@ int IPAManager::addDir(const char *libDir)
 			continue;
 		}
 
-		modules_.push_back(ipaModule);
+		if (!strncmp(ipaModule->info().pipelineName, "Shim", 4))
+			shims_.push_back(ipaModule);
+		else
+			modules_.push_back(ipaModule);
 		count++;
 	}
 
@@ -132,6 +135,7 @@ std::unique_ptr<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe,
 						    uint32_t minVersion)
 {
 	IPAModule *m = nullptr;
+	IPAModule *shim = nullptr;
 
 	for (IPAModule *module : modules_) {
 		if (module->match(pipe, minVersion, maxVersion)) {
@@ -140,7 +144,33 @@ std::unique_ptr<IPAInterface> IPAManager::createIPA(PipelineHandler *pipe,
 		}
 	}
 
-	if (!m || !m->load())
+	if (!m)
+		return nullptr;
+
+	if (m->info().isolate) {
+		if (shims_.empty()) {
+			LOG(IPAManager, Error) << "No shims available";
+			return nullptr;
+		}
+
+		shim = shims_.front();
+		if (!shim || !shim->load()) {
+			LOG(IPAManager, Error) << "Failed to obtain shim";
+			return nullptr;
+		}
+
+		auto shimIPAIntf = shim->createInstance();
+		if (!shimIPAIntf) {
+			LOG(IPAManager, Error) << "Failed to load shim";
+			return nullptr;
+		}
+
+		shimIPAIntf->init(m->path());
+
+		return shimIPAIntf;
+	}
+
+	if (!m->load())
 		return nullptr;
 
 	return m->createInstance();
-- 
2.20.1



More information about the libcamera-devel mailing list