[libcamera-devel] [PATCH 2/5] libcamera: ipa_manager: Split path handling

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Feb 5 14:04:17 CET 2020


Move the iteration of a colon separated path to it's own function.
This prepares for parsing extra path variables.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/libcamera/include/ipa_manager.h |  1 +
 src/libcamera/ipa_manager.cpp       | 52 +++++++++++++++++++----------
 2 files changed, 36 insertions(+), 17 deletions(-)

diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h
index 126f8babbc8f..94d35d9062e4 100644
--- a/src/libcamera/include/ipa_manager.h
+++ b/src/libcamera/include/ipa_manager.h
@@ -33,6 +33,7 @@ private:
 	~IPAManager();
 
 	int addDir(const char *libDir);
+	int addPath(const char *path);
 };
 
 } /* namespace libcamera */
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp
index 92adc6c45015..048465c37772 100644
--- a/src/libcamera/ipa_manager.cpp
+++ b/src/libcamera/ipa_manager.cpp
@@ -110,23 +110,7 @@ IPAManager::IPAManager()
 		return;
 	}
 
-	const char *paths = modulePaths;
-	while (1) {
-		const char *delim = strchrnul(paths, ':');
-		size_t count = delim - paths;
-
-		if (count) {
-			std::string path(paths, count);
-			ret = addDir(path.c_str());
-			if (ret > 0)
-				ipaCount += ret;
-		}
-
-		if (*delim == '\0')
-			break;
-
-		paths += count + 1;
-	}
+	ipaCount += addPath(modulePaths);
 
 	if (!ipaCount)
 		LOG(IPAManager, Warning)
@@ -206,6 +190,40 @@ int IPAManager::addDir(const char *libDir)
 	return count;
 }
 
+/**
+ * \brief Load IPA modules from a colon separated PATH variable
+ * \param[in] path string to split to search for IPA modules
+ *
+ * This method tries to create an IPAModule instance for every shared object
+ * found in the directories described by \a paths.
+ *
+ * \return Number of modules loaded by this call, or a negative error code
+ * otherwise
+ */
+int IPAManager::addPath(const char *paths)
+{
+	int ipaCount = 0;
+
+	while (1) {
+		const char *delim = strchrnul(paths, ':');
+		size_t count = delim - paths;
+
+		if (count) {
+			std::string path(paths, count);
+			int ret = addDir(path.c_str());
+			if (ret > 0)
+				ipaCount += ret;
+		}
+
+		if (*delim == '\0')
+			break;
+
+		paths += count + 1;
+	}
+
+	return ipaCount;
+}
+
 /**
  * \brief Create an IPA interface that matches a given pipeline handler
  * \param[in] pipe The pipeline handler that wants a matching IPA interface
-- 
2.20.1



More information about the libcamera-devel mailing list