| Message ID | 20260407-kbingham-awb-split-v1-13-a39af3f4dc20@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hi Kieran On Tue, Apr 07, 2026 at 11:01:16PM +0100, Kieran Bingham wrote: > Move the common duplicated code from both the simple and rkisp1 IPA modules > and add these to the prepare function of libipa awb module. > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/ipa/libipa/awb.cpp | 20 ++++++++++++++++++++ > src/ipa/libipa/awb.h | 4 ++++ > src/ipa/rkisp1/algorithms/awb.cpp | 11 ++--------- > src/ipa/simple/algorithms/awb.cpp | 12 +++--------- > 4 files changed, 29 insertions(+), 18 deletions(-) > > diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp > index cac6b4bd206faa4f32680e16c7522685cfd30cac..b079a9c24b0d2d1e11b8da1087023af715765e31 100644 > --- a/src/ipa/libipa/awb.cpp > +++ b/src/ipa/libipa/awb.cpp > @@ -227,6 +227,26 @@ void AwbAlgorithm::queueRequest(awb::ActiveState &state, > frameContext.temperatureK = state.manual.temperatureK; > } > > +/** > + * \brief Prepare the AWB frame context ready for usage > + * \param[in] state The AWB specific active state shared across frames > + * \param[in] frame The frame number to apply the control values > + * \param[in] frameContext The current frame's AWB specific context > + */ > +void AwbAlgorithm::prepare(awb::ActiveState &state, > + [[maybe_unused]] const uint32_t frame, same comment as on queueRequest. Should we keep 'frame' in the parameters list ? > + awb::FrameContext &frameContext) > +{ > + /* > + * When AutoAWB is enabled, this is the latest opportunity to take > + * the most recent and up to date desired AWB gains. > + */ > + if (frameContext.autoEnabled) { > + frameContext.gains = state.automatic.gains; > + frameContext.temperatureK = state.automatic.temperatureK; > + } > +} > + > /** > * \fn AwbAlgorithm::calculateAwb() > * \brief Calculate AWB data from the given statistics > diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h > index 0256ff8ca3429288c317d3ee940255c4a5391357..ae061f4082ed947c5b8df95bd33566be6777849f 100644 > --- a/src/ipa/libipa/awb.h > +++ b/src/ipa/libipa/awb.h > @@ -73,6 +73,10 @@ public: > awb::FrameContext &frameContext, > const ControlList &controls); > > + void prepare(awb::ActiveState &state, > + [[maybe_unused]] const uint32_t frame, > + awb::FrameContext &frameContext); > + > virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0; > virtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0; > > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp > index b91132fc6177650b9338867359583bf5429ea7e5..9aacb0cff0e747dba588e45434c108d592742701 100644 > --- a/src/ipa/rkisp1/algorithms/awb.cpp > +++ b/src/ipa/rkisp1/algorithms/awb.cpp > @@ -160,15 +160,8 @@ void Awb::queueRequest(IPAContext &context, > void Awb::prepare(IPAContext &context, const uint32_t frame, > IPAFrameContext &frameContext, RkISP1Params *params) > { > - /* > - * This is the latest time we can read the active state. This is the > - * most up-to-date automatic values we can read. > - */ > - if (frameContext.awb.autoEnabled) { > - const auto &awb = context.activeState.awb; > - frameContext.awb.gains = awb.automatic.gains; > - frameContext.awb.temperatureK = awb.automatic.temperatureK; > - } > + awbAlgo_->prepare(context.activeState.awb, > + frame, frameContext.awb); > > auto gainConfig = params->block<BlockType::AwbGain>(); > gainConfig.setEnabled(true); > diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp > index d8516871562724fc65ffbb67161ff4fd988c4b1c..6ce1ed340a5338e25f44145942de95f7f4f6c637 100644 > --- a/src/ipa/simple/algorithms/awb.cpp > +++ b/src/ipa/simple/algorithms/awb.cpp > @@ -124,18 +124,12 @@ void Awb::queueRequest(IPAContext &context, > } > > void Awb::prepare(IPAContext &context, > - [[maybe_unused]] const uint32_t frame, > + const uint32_t frame, > IPAFrameContext &frameContext, > DebayerParams *params) > { > - /* > - * When AutoAWB is enabled, this is the latest opportunity to take > - * the most recent and up to date desired AWB gains. > - */ > - if (frameContext.awb.autoEnabled) { > - frameContext.awb.gains = context.activeState.awb.automatic.gains; > - frameContext.awb.temperatureK = context.activeState.awb.automatic.temperatureK; > - } > + awbAlgo_->prepare(context.activeState.awb, > + frame, frameContext.awb); Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Thanks j > > params->gains = frameContext.awb.gains; > } > > -- > 2.53.0 >
diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp index cac6b4bd206faa4f32680e16c7522685cfd30cac..b079a9c24b0d2d1e11b8da1087023af715765e31 100644 --- a/src/ipa/libipa/awb.cpp +++ b/src/ipa/libipa/awb.cpp @@ -227,6 +227,26 @@ void AwbAlgorithm::queueRequest(awb::ActiveState &state, frameContext.temperatureK = state.manual.temperatureK; } +/** + * \brief Prepare the AWB frame context ready for usage + * \param[in] state The AWB specific active state shared across frames + * \param[in] frame The frame number to apply the control values + * \param[in] frameContext The current frame's AWB specific context + */ +void AwbAlgorithm::prepare(awb::ActiveState &state, + [[maybe_unused]] const uint32_t frame, + awb::FrameContext &frameContext) +{ + /* + * When AutoAWB is enabled, this is the latest opportunity to take + * the most recent and up to date desired AWB gains. + */ + if (frameContext.autoEnabled) { + frameContext.gains = state.automatic.gains; + frameContext.temperatureK = state.automatic.temperatureK; + } +} + /** * \fn AwbAlgorithm::calculateAwb() * \brief Calculate AWB data from the given statistics diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h index 0256ff8ca3429288c317d3ee940255c4a5391357..ae061f4082ed947c5b8df95bd33566be6777849f 100644 --- a/src/ipa/libipa/awb.h +++ b/src/ipa/libipa/awb.h @@ -73,6 +73,10 @@ public: awb::FrameContext &frameContext, const ControlList &controls); + void prepare(awb::ActiveState &state, + [[maybe_unused]] const uint32_t frame, + awb::FrameContext &frameContext); + virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0; virtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0; diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index b91132fc6177650b9338867359583bf5429ea7e5..9aacb0cff0e747dba588e45434c108d592742701 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -160,15 +160,8 @@ void Awb::queueRequest(IPAContext &context, void Awb::prepare(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, RkISP1Params *params) { - /* - * This is the latest time we can read the active state. This is the - * most up-to-date automatic values we can read. - */ - if (frameContext.awb.autoEnabled) { - const auto &awb = context.activeState.awb; - frameContext.awb.gains = awb.automatic.gains; - frameContext.awb.temperatureK = awb.automatic.temperatureK; - } + awbAlgo_->prepare(context.activeState.awb, + frame, frameContext.awb); auto gainConfig = params->block<BlockType::AwbGain>(); gainConfig.setEnabled(true); diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp index d8516871562724fc65ffbb67161ff4fd988c4b1c..6ce1ed340a5338e25f44145942de95f7f4f6c637 100644 --- a/src/ipa/simple/algorithms/awb.cpp +++ b/src/ipa/simple/algorithms/awb.cpp @@ -124,18 +124,12 @@ void Awb::queueRequest(IPAContext &context, } void Awb::prepare(IPAContext &context, - [[maybe_unused]] const uint32_t frame, + const uint32_t frame, IPAFrameContext &frameContext, DebayerParams *params) { - /* - * When AutoAWB is enabled, this is the latest opportunity to take - * the most recent and up to date desired AWB gains. - */ - if (frameContext.awb.autoEnabled) { - frameContext.awb.gains = context.activeState.awb.automatic.gains; - frameContext.awb.temperatureK = context.activeState.awb.automatic.temperatureK; - } + awbAlgo_->prepare(context.activeState.awb, + frame, frameContext.awb); params->gains = frameContext.awb.gains; }
Move the common duplicated code from both the simple and rkisp1 IPA modules and add these to the prepare function of libipa awb module. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- src/ipa/libipa/awb.cpp | 20 ++++++++++++++++++++ src/ipa/libipa/awb.h | 4 ++++ src/ipa/rkisp1/algorithms/awb.cpp | 11 ++--------- src/ipa/simple/algorithms/awb.cpp | 12 +++--------- 4 files changed, 29 insertions(+), 18 deletions(-)