[v6,17/24] ipa: Add a new Algorithm::init() to support self-initalising algorithms
diff mbox series

Message ID 20251202134544.662446-18-bryan.odonoghue@linaro.org
State Superseded
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Dec. 2, 2025, 1:45 p.m. UTC
Add in an algorithm init() routine which can be called in the absence of a
Yaml input. Do this to allow an algorithm to set up a default set of
parameters.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/ipa/libipa/algorithm.cpp | 13 ++++++++++++-
 src/ipa/libipa/algorithm.h   |  5 +++++
 2 files changed, 17 insertions(+), 1 deletion(-)

Comments

Milan Zamazal Dec. 3, 2025, 9:10 p.m. UTC | #1
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> Add in an algorithm init() routine which can be called in the absence of a
> Yaml input. Do this to allow an algorithm to set up a default set of
> parameters.

This requires more explanation.  I can see in 21/24 "Call
createSelfEnumeratingAlgorithm() to statically instantiate CCM algo"
that the selection between the two versions is based on examining a
condition.  Why not to put the condition value as a flag to context_ and
then examine that context_ flag in the original init(), without the need
to add the overloaded method?

> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  src/ipa/libipa/algorithm.cpp | 13 ++++++++++++-
>  src/ipa/libipa/algorithm.h   |  5 +++++
>  2 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
> index 201efdfdb..da44c77ca 100644
> --- a/src/ipa/libipa/algorithm.cpp
> +++ b/src/ipa/libipa/algorithm.cpp
> @@ -38,7 +38,7 @@ namespace ipa {
>   */
>  
>  /**
> - * \fn Algorithm::init()
> + * \fn Algorithm::init(typename Module::Context &context, const YamlObject &tuningData)
>   * \brief Initialize the Algorithm with tuning data
>   * \param[in] context The shared IPA context
>   * \param[in] tuningData The tuning data for the algorithm
> @@ -50,6 +50,17 @@ namespace ipa {
>   * \return 0 if successful, an error code otherwise
>   */
>  
> +/**
> + * \fn Algorithm::init(typename Module::Context &context)
> + * \brief Initialize the algorithm with default parameters
> + *
> + * This method is called when no tuning data is available. The algorithm
> + * should initialize with sensible default values.
> + *
> + * \param context The IPA context containing algorithm state
> + * \return 0 on success, negative error code on failure
> + */
> +
>  /**
>   * \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 9a19dbd61..9fcbe23a9 100644
> --- a/src/ipa/libipa/algorithm.h
> +++ b/src/ipa/libipa/algorithm.h
> @@ -32,6 +32,11 @@ public:
>  		return 0;
>  	}
>  
> +	virtual int init([[maybe_unused]] typename Module::Context &context)
> +	{
> +		return 0;
> +	}
> +
>  	virtual int configure([[maybe_unused]] typename Module::Context &context,
>  			      [[maybe_unused]] const typename Module::Config &configInfo)
>  	{

Patch
diff mbox series

diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index 201efdfdb..da44c77ca 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -38,7 +38,7 @@  namespace ipa {
  */
 
 /**
- * \fn Algorithm::init()
+ * \fn Algorithm::init(typename Module::Context &context, const YamlObject &tuningData)
  * \brief Initialize the Algorithm with tuning data
  * \param[in] context The shared IPA context
  * \param[in] tuningData The tuning data for the algorithm
@@ -50,6 +50,17 @@  namespace ipa {
  * \return 0 if successful, an error code otherwise
  */
 
+/**
+ * \fn Algorithm::init(typename Module::Context &context)
+ * \brief Initialize the algorithm with default parameters
+ *
+ * This method is called when no tuning data is available. The algorithm
+ * should initialize with sensible default values.
+ *
+ * \param context The IPA context containing algorithm state
+ * \return 0 on success, negative error code on failure
+ */
+
 /**
  * \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 9a19dbd61..9fcbe23a9 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -32,6 +32,11 @@  public:
 		return 0;
 	}
 
+	virtual int init([[maybe_unused]] typename Module::Context &context)
+	{
+		return 0;
+	}
+
 	virtual int configure([[maybe_unused]] typename Module::Context &context,
 			      [[maybe_unused]] const typename Module::Config &configInfo)
 	{