[libcamera-devel] [PATCH v3 2/5] ipa: libipa: Add init() function to the Algorithm class

Florian Sylvestre fsylvestre at baylibre.com
Fri Jun 17 11:23:12 CEST 2022


Add the init() function that will be called during algorithm initialization
to provide each algorithm the list of algorithms tuning data.
Each algorithm will be responsible to grab their corresponding parameters.

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>
---
 src/ipa/ipu3/algorithms/algorithm.h   |  8 +++++---
 src/ipa/libipa/algorithm.cpp          | 14 ++++++++++++++
 src/ipa/libipa/algorithm.h            | 11 +++++++++--
 src/ipa/rkisp1/algorithms/algorithm.h |  8 +++++---
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h
index 234b2bd7..8b562e5b 100644
--- a/src/ipa/ipu3/algorithms/algorithm.h
+++ b/src/ipa/ipu3/algorithms/algorithm.h
@@ -15,11 +15,13 @@
 
 namespace libcamera {
 
+class YamlObject;
+
 namespace ipa::ipu3 {
 
-using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAFrameContext,
-					    IPAConfigInfo, ipu3_uapi_params,
-					    ipu3_uapi_stats_3a>;
+using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject,
+					    IPAFrameContext, IPAConfigInfo,
+					    ipu3_uapi_params, ipu3_uapi_stats_3a>;
 
 } /* namespace ipa::ipu3 */
 
diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index cce2ed62..f1b04160 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -29,6 +29,20 @@ namespace ipa {
  * to manage algorithms regardless of their specific type.
  */
 
+/**
+ * \fn Algorithm::init()
+ * \brief Configure the Algorithm with default parameters
+ * \param[in] context The shared IPA context
+ * \param[in] params The initial parameters used to tune algorithms
+ *
+ * This function is called once, when the IPA module is initialized, to
+ * initialize the algorithm. The \a params YamlObject contains IPA module
+ * parameters, typically tuning data for all algorithms. The Algorithm is
+ * responsible for reading the parameters relevant to its configuration.
+ *
+ * \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 032a05b5..2945719e 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -10,13 +10,20 @@ namespace libcamera {
 
 namespace ipa {
 
-template<typename Context, typename FrameContext, typename Config,
-	 typename Params, typename Stats>
+template<typename Context, typename TuningData, typename FrameContext,
+	 typename Config, typename Params, typename Stats>
+
 class Algorithm
 {
 public:
 	virtual ~Algorithm() {}
 
+	virtual int init([[maybe_unused]] Context &context,
+			 [[maybe_unused]] const TuningData &params)
+	{
+		return 0;
+	}
+
 	virtual int configure([[maybe_unused]] Context &context,
 			      [[maybe_unused]] const Config &configInfo)
 	{
diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h
index 68e3a44e..e813756d 100644
--- a/src/ipa/rkisp1/algorithms/algorithm.h
+++ b/src/ipa/rkisp1/algorithms/algorithm.h
@@ -17,11 +17,13 @@
 
 namespace libcamera {
 
+class YamlObject;
+
 namespace ipa::rkisp1 {
 
-using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAFrameContext,
-					    IPACameraSensorInfo, rkisp1_params_cfg,
-					    rkisp1_stat_buffer>;
+using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject,
+					    IPAFrameContext, IPACameraSensorInfo,
+					    rkisp1_params_cfg, rkisp1_stat_buffer>;
 
 } /* namespace ipa::rkisp1 */
 
-- 
2.34.1



More information about the libcamera-devel mailing list