[v4,21/23] ipa: libipa: module: Add createSelfEnumeratingAlgorithm
diff mbox series

Message ID 20251120233347.5046-22-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Nov. 20, 2025, 11:33 p.m. UTC
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/ipa/libipa/module.h | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h
index 0fb51916f..d11e189bc 100644
--- a/src/ipa/libipa/module.h
+++ b/src/ipa/libipa/module.h
@@ -70,6 +70,47 @@  public:
 		factories().push_back(factory);
 	}
 
+	/**
+	 * \fn int Module::createSelfEnumeratingAlgorithm(Context &context, const std::string &name)
+	 * \brief Create and initialise a self-enumerating algorithm by name
+	 * 
+	 * This function creates an algorithm instance from the registered algorithm
+	 * factories using only the algorithm name, without requiring YAML configuration
+	 * data.
+	 * 
+	 * This is useful for algorithms that don't require external configuration
+	 * parameters and can self-configure or use default values.
+	 * 
+	 * \param[in] context The IPA context to pass to the algorithm's init function
+	 * \param[in] name The name of the algorithm to instantiate
+	 * 
+	 * \return 0 on success, negative errno value on failure:
+	 *         -EINVAL if the algorithm is not found in the factory registry
+	 *         Other negative values if algorithm initialisation fails
+	 */
+	int createSelfEnumeratingAlgorithm(Context &context, const std::string &name)
+	{
+		std::unique_ptr<Algorithm<Module>> algo = createAlgorithm(name);
+		if (!algo) {
+			LOG(IPAModuleAlgo, Error)
+				<< "Algorithm '" << name << "' not found";
+			return -EINVAL;
+		}
+
+		int ret = algo->init(context);
+		if (ret) {
+			LOG(IPAModuleAlgo, Error)
+				<< "Algorithm '" << name << "' failed to initialize";
+			return ret;
+		}
+
+		LOG(IPAModuleAlgo, Debug)
+			<< "Instantiated algorithm '" << name << "'";
+
+		algorithms_.push_back(std::move(algo));
+		return 0;
+	}
+
 private:
 	int createAlgorithm(Context &context, const YamlObject &data)
 	{