Message ID | 20220616080744.548995-3-fsylvestre@baylibre.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Florian, Thank you for the patch. On Thu, Jun 16, 2022 at 10:07:41AM +0200, Florian Sylvestre via libcamera-devel wrote: > 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@baylibre.com> > --- > src/ipa/ipu3/algorithms/algorithm.h | 4 +++- > src/ipa/libipa/algorithm.cpp | 16 ++++++++++++++++ > src/ipa/libipa/algorithm.h | 10 +++++++++- > 3 files changed, 28 insertions(+), 2 deletions(-) > > diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h > index d2eecc78..32cdfe52 100644 > --- a/src/ipa/ipu3/algorithms/algorithm.h > +++ b/src/ipa/ipu3/algorithms/algorithm.h > @@ -15,9 +15,11 @@ > > namespace libcamera { > > +class YamlObject; > + > namespace ipa::ipu3 { > > -using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAConfigInfo, ipu3_uapi_params, ipu3_uapi_stats_3a>; > +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPAConfigInfo, ipu3_uapi_params, ipu3_uapi_stats_3a>; This is getting long, I'd wrap it as using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, 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 398d5372..3424610b 100644 > --- a/src/ipa/libipa/algorithm.cpp > +++ b/src/ipa/libipa/algorithm.cpp > @@ -29,6 +29,22 @@ 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 before the camera is running to get default > + * algorithm parameters. I think this sentence is a leftover of v1, it can be dropped. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > + * 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 766aee5d..f5be1caf 100644 > --- a/src/ipa/libipa/algorithm.h > +++ b/src/ipa/libipa/algorithm.h > @@ -10,12 +10,20 @@ namespace libcamera { > > namespace ipa { > > -template<typename Context, typename Config, typename Params, typename Stats> > +template<typename Context, typename TuningData, > + 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/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h index d2eecc78..32cdfe52 100644 --- a/src/ipa/ipu3/algorithms/algorithm.h +++ b/src/ipa/ipu3/algorithms/algorithm.h @@ -15,9 +15,11 @@ namespace libcamera { +class YamlObject; + namespace ipa::ipu3 { -using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPAConfigInfo, ipu3_uapi_params, ipu3_uapi_stats_3a>; +using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, 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 398d5372..3424610b 100644 --- a/src/ipa/libipa/algorithm.cpp +++ b/src/ipa/libipa/algorithm.cpp @@ -29,6 +29,22 @@ 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 before the camera is running to get default + * algorithm parameters. + * 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 766aee5d..f5be1caf 100644 --- a/src/ipa/libipa/algorithm.h +++ b/src/ipa/libipa/algorithm.h @@ -10,12 +10,20 @@ namespace libcamera { namespace ipa { -template<typename Context, typename Config, typename Params, typename Stats> +template<typename Context, typename TuningData, + 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) {
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@baylibre.com> --- src/ipa/ipu3/algorithms/algorithm.h | 4 +++- src/ipa/libipa/algorithm.cpp | 16 ++++++++++++++++ src/ipa/libipa/algorithm.h | 10 +++++++++- 3 files changed, 28 insertions(+), 2 deletions(-)