[libcamera-devel] [PATCH v4 04/12] ipa: libipa: algorithm: Add init() function to the Algorithm class

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Jun 20 03:42:57 CEST 2022


From: Florian Sylvestre <fsylvestre at baylibre.com>

Add the init() function that will be called during algorithm initialization
to provide each algorithm the list of algorithms tuning data.

Signed-off-by: Florian Sylvestre <fsylvestre at baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
Changes since v3:

- Hardcode YamlObject as the data type of tuning data
- Reword the Algorithm::init() documentation
- Pass the algorithm-specific data to the init() function instead of the
  global tuning data
---
 src/ipa/libipa/algorithm.cpp | 13 +++++++++++++
 src/ipa/libipa/algorithm.h   |  8 ++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index 6e0bba56ecb2..1b1fd80fb7b0 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -37,6 +37,19 @@ namespace ipa {
  * \brief The IPA module type for this class of algorithms
  */
 
+/**
+ * \fn Algorithm::init()
+ * \brief Initialize the Algorithm with tuning data
+ * \param[in] context The shared IPA context
+ * \param[in] tuningData The tuning data for the algorithm
+ *
+ * This function is called once, when the IPA module is initialized, to
+ * initialize the algorithm. The \a tuningData YamlObject contains the tuning
+ * data for algorithm.
+ *
+ * \return 0 if successful, an error code otherwise
+ */
+
 /**
  * \fn Algorithm::configure()
  * \brief Configure the Algorithm given an IPAConfigInfo
diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h
index 356c094976d4..47cb3c01d2ce 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -11,6 +11,8 @@
 
 namespace libcamera {
 
+class YamlObject;
+
 namespace ipa {
 
 template<typename _Module>
@@ -21,6 +23,12 @@ public:
 
 	virtual ~Algorithm() {}
 
+	virtual int init([[maybe_unused]] typename Module::Context &context,
+			 [[maybe_unused]] const YamlObject &tuningData)
+	{
+		return 0;
+	}
+
 	virtual int configure([[maybe_unused]] typename Module::Context &context,
 			      [[maybe_unused]] const typename Module::Config &configInfo)
 	{
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list