[{"id":38530,"web_url":"https://patchwork.libcamera.org/comment/38530/","msgid":"<adYUqVKNXjw7YaNt@zed>","date":"2026-04-08T08:47:29","subject":"Re: [PATCH 11/13] ipa: libipa: awb: Move configure to common","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Kieran\n\nOn Tue, Apr 07, 2026 at 11:01:14PM +0100, Kieran Bingham wrote:\n> Refactor the AWB configuration to use the common implementation supplied\n> by libipa awb module.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/libipa/awb.cpp            | 29 +++++++++++++++++++++++++++++\n>  src/ipa/libipa/awb.h              |  3 +++\n>  src/ipa/rkisp1/algorithms/awb.cpp | 13 +------------\n>  src/ipa/simple/algorithms/awb.cpp | 16 ++--------------\n>  4 files changed, 35 insertions(+), 26 deletions(-)\n>\n> diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\n> index f215bea0b59483eadf95572f073928a4eb1275f4..d0c577958caebc0b7e24fe58506da964df2200fe 100644\n> --- a/src/ipa/libipa/awb.cpp\n> +++ b/src/ipa/libipa/awb.cpp\n> @@ -11,6 +11,8 @@\n>\n>  #include <libcamera/control_ids.h>\n>\n> +constexpr int32_t kDefaultColourTemperature = 5000;\n> +\n>  /**\n>   * \\file awb.h\n>   * \\brief Base classes for AWB algorithms\n> @@ -139,6 +141,33 @@ namespace ipa {\n>   * \\return 0 on success, a negative error code otherwise\n>   */\n>\n> +/**\n> + * \\brief Configure the Awb algorithm given an IPAConfigInfo\n\nno IPAConfigInfo :)\n\nI would simply:\n        \\brief Configure the Awb algorithm initial state\n\n> + * \\param[in] state The AWB specific active state shared across frames\n> + * \\param[in] session The AWB specific session configuration\n\n[inout] maybe, as this function initializes these two arguments ?\n\n> + *\n> + * Configure and initialise the AWB algorithm module.\n> + *\n> + * \\return 0 if successful, an error code otherwise\n\nDoesn't seem to return errors at all. What is a failure condition for\nconfigure() ?\n\n> + */\n> +int AwbAlgorithm::configure(awb::ActiveState &state, awb::Session &session)\n> +{\n> +\tstate.manual.gains = RGB<double>{ 1.0 };\n> +\tauto gains = gainsFromColourTemperature(kDefaultColourTemperature);\n> +\tif (gains)\n\nI think the AwbGrey implemenation could be updated\n\n * \\return The colour gains if a colour temperature curve is available,\n * [1, 1, 1] otherwise.\n */\nstd::optional<RGB<double>> AwbGrey::gainsFromColourTemperature(double colourTemperature)\n{\n\tif (!colourGainCurve_) {\n\t\tLOG(Awb, Error) << \"No gains defined\";\n\t\treturn std::nullopt;\n\t}\n\nto return RGB<double>{ 1.0 };\n\nso that it matches its documentation and you could avoid handling the\nfailure case here\n\n> +\t\tstate.automatic.gains = *gains;\n> +\telse\n> +\t\tstate.automatic.gains = RGB<double>{ 1.0 };\n> +\n> +\tstate.autoEnabled = true;\n> +\tstate.manual.temperatureK = kDefaultColourTemperature;\n> +\tstate.automatic.temperatureK = kDefaultColourTemperature;\n> +\n> +\tsession.enabled = true;\n> +\n> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\fn AwbAlgorithm::calculateAwb()\n>   * \\brief Calculate AWB data from the given statistics\n> diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\n> index 764be849270bcd42ecdf67aea3d13afa170c7499..4ceae537686f8f4c93686fab4b9efbc06e112b1d 100644\n> --- a/src/ipa/libipa/awb.h\n> +++ b/src/ipa/libipa/awb.h\n> @@ -65,6 +65,9 @@ public:\n>  \tvirtual ~AwbAlgorithm() = default;\n>\n>  \tvirtual int init(const YamlObject &tuningData) = 0;\n> +\n> +\tint configure(awb::ActiveState &state, awb::Session &session);\n> +\n>  \tvirtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;\n>  \tvirtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;\n>\n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index f83da545be856c08cd758dc20a5ace91344101cf..86d5dfed3e1c2bb587705f05362229db3cdadafd 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -128,16 +128,7 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n>  int Awb::configure(IPAContext &context,\n>  \t\t   const IPACameraSensorInfo &configInfo)\n>  {\n> -\tcontext.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> -\tauto gains = awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> -\tif (gains)\n> -\t\tcontext.activeState.awb.automatic.gains = *gains;\n> -\telse\n> -\t\tcontext.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n> -\n> -\tcontext.activeState.awb.autoEnabled = true;\n> -\tcontext.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> -\tcontext.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> +\tawbAlgo_->configure(context.activeState.awb, context.configuration.awb);\n>\n>  \t/*\n>  \t * Define the measurement window for AWB as a centered rectangle\n> @@ -148,8 +139,6 @@ int Awb::configure(IPAContext &context,\n>  \tcontext.configuration.awb.measureWindow.h_size = 3 * configInfo.outputSize.width / 4;\n>  \tcontext.configuration.awb.measureWindow.v_size = 3 * configInfo.outputSize.height / 4;\n>\n> -\tcontext.configuration.awb.enabled = true;\n> -\n>  \treturn 0;\n>  }\n>\n> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n> index 90c05e86bae6eefe4874feeb1263af07acd5fcfc..230b7807075941f086911549066e39c0a04dff5c 100644\n> --- a/src/ipa/simple/algorithms/awb.cpp\n> +++ b/src/ipa/simple/algorithms/awb.cpp\n> @@ -106,20 +106,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n>  int Awb::configure(IPAContext &context,\n>  \t\t   [[maybe_unused]] const IPAConfigInfo &configInfo)\n>  {\n> -\tcontext.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> -\tauto gains = awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> -\tif (gains)\n> -\t\tcontext.activeState.awb.automatic.gains = *gains;\n> -\telse\n> -\t\tcontext.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n> -\n> -\tcontext.activeState.awb.autoEnabled = true;\n> -\tcontext.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> -\tcontext.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> -\n> -\tcontext.configuration.awb.enabled = true;\n> -\n> -\treturn 0;\n> +\treturn awbAlgo_->configure(context.activeState.awb,\n> +\t\t\t\t   context.configuration.awb);\n>  }\n>\n>  /**\n>\n> --\n> 2.53.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 71AD9BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Apr 2026 08:47:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6589D62DBE;\n\tWed,  8 Apr 2026 10:47:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B2CD62647\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2026 10:47:33 +0200 (CEST)","from ideasonboard.com (mob-109-113-47-41.net.vodafone.it\n\t[109.113.47.41])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D73B01544;\n\tWed,  8 Apr 2026 10:46:04 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nJPA4T3D\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775637965;\n\tbh=Km8oy+8Alur0g0UBrdxBdE9Ho4fETwsLg2lb0jcn6Lk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nJPA4T3Doc0oFCZTM5YsepEcJie8NQytZZmjByCQXjMFPhRu+SMPmC0VCt3Qc3lR+\n\tCFg8IR5S5X/FhT+0DD8lOatof0UIZmk67HXCtMEjwJi6y2I7AKZzw0Ri0n30L0L+3s\n\tWEYbgsoFqxQHvcD9hN8D+ws7QHTVOBWQI+3EToTg=","Date":"Wed, 8 Apr 2026 10:47:29 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 11/13] ipa: libipa: awb: Move configure to common","Message-ID":"<adYUqVKNXjw7YaNt@zed>","References":"<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>\n\t<20260407-kbingham-awb-split-v1-11-a39af3f4dc20@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20260407-kbingham-awb-split-v1-11-a39af3f4dc20@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":38541,"web_url":"https://patchwork.libcamera.org/comment/38541/","msgid":"<177566878023.575056.6498275535085752025@ping.linuxembedded.co.uk>","date":"2026-04-08T17:19:40","subject":"Re: [PATCH 11/13] ipa: libipa: awb: Move configure to common","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2026-04-08 09:47:29)\n> Hi Kieran\n> \n> On Tue, Apr 07, 2026 at 11:01:14PM +0100, Kieran Bingham wrote:\n> > Refactor the AWB configuration to use the common implementation supplied\n> > by libipa awb module.\n> >\n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > ---\n> >  src/ipa/libipa/awb.cpp            | 29 +++++++++++++++++++++++++++++\n> >  src/ipa/libipa/awb.h              |  3 +++\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 13 +------------\n> >  src/ipa/simple/algorithms/awb.cpp | 16 ++--------------\n> >  4 files changed, 35 insertions(+), 26 deletions(-)\n> >\n> > diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\n> > index f215bea0b59483eadf95572f073928a4eb1275f4..d0c577958caebc0b7e24fe58506da964df2200fe 100644\n> > --- a/src/ipa/libipa/awb.cpp\n> > +++ b/src/ipa/libipa/awb.cpp\n> > @@ -11,6 +11,8 @@\n> >\n> >  #include <libcamera/control_ids.h>\n> >\n> > +constexpr int32_t kDefaultColourTemperature = 5000;\n> > +\n> >  /**\n> >   * \\file awb.h\n> >   * \\brief Base classes for AWB algorithms\n> > @@ -139,6 +141,33 @@ namespace ipa {\n> >   * \\return 0 on success, a negative error code otherwise\n> >   */\n> >\n> > +/**\n> > + * \\brief Configure the Awb algorithm given an IPAConfigInfo\n> \n> no IPAConfigInfo :)\n\nArgh, Sorry, too much copya-pasta.\n\n> \n> I would simply:\n>         \\brief Configure the Awb algorithm initial state\n\nAck,\n\n> \n> > + * \\param[in] state The AWB specific active state shared across frames\n> > + * \\param[in] session The AWB specific session configuration\n> \n> [inout] maybe, as this function initializes these two arguments ?\n\nYes.\n\n> \n> > + *\n> > + * Configure and initialise the AWB algorithm module.\n> > + *\n> > + * \\return 0 if successful, an error code otherwise\n> \n> Doesn't seem to return errors at all. What is a failure condition for\n> configure() ?\n\nWhen I did this I was more or less trying to take and mirror the\nexisting IPA interface documentation. Ultimately these are supposed to\nbe the module specific implementations for those, but as you see there\nisn't actually a direct mapping as these functions then use the local or\nmodule specific context structures.\n\nI didn't want to change too much as I hope to try to keep things as\nclose as possible to the main interface or as much as possible the same\nfor each algo - but maybe that won't be reasonable.\n\nThis is the start of the path to find out ;-)\n\nAfter lux/awb, I want to see AEGC and other algorithms describe /their/\nexpected storage types and work out how much can be factored out to\ngeneric code.\n\nI know there may always be differences, but that's the point of this\nseries - to find out what I've always wanted to know. How much can we\nkeep common to make it easy to add a new platform with libipa.\n\n\n> \n> > + */\n> > +int AwbAlgorithm::configure(awb::ActiveState &state, awb::Session &session)\n> > +{\n> > +     state.manual.gains = RGB<double>{ 1.0 };\n> > +     auto gains = gainsFromColourTemperature(kDefaultColourTemperature);\n> > +     if (gains)\n> \n> I think the AwbGrey implemenation could be updated\n> \n>  * \\return The colour gains if a colour temperature curve is available,\n>  * [1, 1, 1] otherwise.\n>  */\n> std::optional<RGB<double>> AwbGrey::gainsFromColourTemperature(double colourTemperature)\n> {\n>         if (!colourGainCurve_) {\n>                 LOG(Awb, Error) << \"No gains defined\";\n>                 return std::nullopt;\n>         }\n> \n> to return RGB<double>{ 1.0 };\n> \n> so that it matches its documentation and you could avoid handling the\n> failure case here\n> \n> > +             state.automatic.gains = *gains;\n> > +     else\n> > +             state.automatic.gains = RGB<double>{ 1.0 };\n\nOhh I like that.\n\n--\nThanks\n\nKieran\n\n> > +\n> > +     state.autoEnabled = true;\n> > +     state.manual.temperatureK = kDefaultColourTemperature;\n> > +     state.automatic.temperatureK = kDefaultColourTemperature;\n> > +\n> > +     session.enabled = true;\n> > +\n> > +     return 0;\n> > +}\n> > +\n> >  /**\n> >   * \\fn AwbAlgorithm::calculateAwb()\n> >   * \\brief Calculate AWB data from the given statistics\n> > diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\n> > index 764be849270bcd42ecdf67aea3d13afa170c7499..4ceae537686f8f4c93686fab4b9efbc06e112b1d 100644\n> > --- a/src/ipa/libipa/awb.h\n> > +++ b/src/ipa/libipa/awb.h\n> > @@ -65,6 +65,9 @@ public:\n> >       virtual ~AwbAlgorithm() = default;\n> >\n> >       virtual int init(const YamlObject &tuningData) = 0;\n> > +\n> > +     int configure(awb::ActiveState &state, awb::Session &session);\n> > +\n> >       virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;\n> >       virtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;\n> >\n> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> > index f83da545be856c08cd758dc20a5ace91344101cf..86d5dfed3e1c2bb587705f05362229db3cdadafd 100644\n> > --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> > @@ -128,16 +128,7 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n> >  int Awb::configure(IPAContext &context,\n> >                  const IPACameraSensorInfo &configInfo)\n> >  {\n> > -     context.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> > -     auto gains = awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> > -     if (gains)\n> > -             context.activeState.awb.automatic.gains = *gains;\n> > -     else\n> > -             context.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n> > -\n> > -     context.activeState.awb.autoEnabled = true;\n> > -     context.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> > -     context.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> > +     awbAlgo_->configure(context.activeState.awb, context.configuration.awb);\n> >\n> >       /*\n> >        * Define the measurement window for AWB as a centered rectangle\n> > @@ -148,8 +139,6 @@ int Awb::configure(IPAContext &context,\n> >       context.configuration.awb.measureWindow.h_size = 3 * configInfo.outputSize.width / 4;\n> >       context.configuration.awb.measureWindow.v_size = 3 * configInfo.outputSize.height / 4;\n> >\n> > -     context.configuration.awb.enabled = true;\n> > -\n> >       return 0;\n> >  }\n> >\n> > diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n> > index 90c05e86bae6eefe4874feeb1263af07acd5fcfc..230b7807075941f086911549066e39c0a04dff5c 100644\n> > --- a/src/ipa/simple/algorithms/awb.cpp\n> > +++ b/src/ipa/simple/algorithms/awb.cpp\n> > @@ -106,20 +106,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n> >  int Awb::configure(IPAContext &context,\n> >                  [[maybe_unused]] const IPAConfigInfo &configInfo)\n> >  {\n> > -     context.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> > -     auto gains = awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> > -     if (gains)\n> > -             context.activeState.awb.automatic.gains = *gains;\n> > -     else\n> > -             context.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n> > -\n> > -     context.activeState.awb.autoEnabled = true;\n> > -     context.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> > -     context.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> > -\n> > -     context.configuration.awb.enabled = true;\n> > -\n> > -     return 0;\n> > +     return awbAlgo_->configure(context.activeState.awb,\n> > +                                context.configuration.awb);\n> >  }\n> >\n> >  /**\n> >\n> > --\n> > 2.53.0\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 44E5DBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Apr 2026 17:19:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3EC6562E08;\n\tWed,  8 Apr 2026 19:19:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D657162CE6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2026 19:19:43 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 705272D5;\n\tWed,  8 Apr 2026 19:18:15 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"jv0BWnsh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775668695;\n\tbh=UD37KZ1Lk6HMxUwztT6eieNNqOmKu2bgPTS173iOdgo=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=jv0BWnshOY+1sWQcLZvEB5op19qtubwyD2IIDGoee5X+fnSp+w7c17EQjlclDnIny\n\tjRAJmW43eOOzreea9dsJsWIET5/AEvzaBc8uP+I2s0XiFlV48LRY1acKMItgNuIGYz\n\tiGxd3LQuNOUitKjzFVMdkKVk/LzU+LvPKtXYedpc=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<adYUqVKNXjw7YaNt@zed>","References":"<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>\n\t<20260407-kbingham-awb-split-v1-11-a39af3f4dc20@ideasonboard.com>\n\t<adYUqVKNXjw7YaNt@zed>","Subject":"Re: [PATCH 11/13] ipa: libipa: awb: Move configure to common","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Wed, 08 Apr 2026 18:19:40 +0100","Message-ID":"<177566878023.575056.6498275535085752025@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":38787,"web_url":"https://patchwork.libcamera.org/comment/38787/","msgid":"<2395223c-be83-444f-b286-a7c761fbaf8e@oss.qualcomm.com>","date":"2026-05-07T14:37:39","subject":"Re: [PATCH 11/13] ipa: libipa: awb: Move configure to common","submitter":{"id":242,"url":"https://patchwork.libcamera.org/api/people/242/","name":"Hans de Goede","email":"johannes.goede@oss.qualcomm.com"},"content":"Hi,\n\nOn 8-Apr-26 00:01, Kieran Bingham wrote:\n> Refactor the AWB configuration to use the common implementation supplied\n> by libipa awb module.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nThanks, patch looks good to me:\n\nReviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n\nRegards,\n\nHans\n\n\n\n> ---\n>  src/ipa/libipa/awb.cpp            | 29 +++++++++++++++++++++++++++++\n>  src/ipa/libipa/awb.h              |  3 +++\n>  src/ipa/rkisp1/algorithms/awb.cpp | 13 +------------\n>  src/ipa/simple/algorithms/awb.cpp | 16 ++--------------\n>  4 files changed, 35 insertions(+), 26 deletions(-)\n> \n> diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp\n> index f215bea0b59483eadf95572f073928a4eb1275f4..d0c577958caebc0b7e24fe58506da964df2200fe 100644\n> --- a/src/ipa/libipa/awb.cpp\n> +++ b/src/ipa/libipa/awb.cpp\n> @@ -11,6 +11,8 @@\n>  \n>  #include <libcamera/control_ids.h>\n>  \n> +constexpr int32_t kDefaultColourTemperature = 5000;\n> +\n>  /**\n>   * \\file awb.h\n>   * \\brief Base classes for AWB algorithms\n> @@ -139,6 +141,33 @@ namespace ipa {\n>   * \\return 0 on success, a negative error code otherwise\n>   */\n>  \n> +/**\n> + * \\brief Configure the Awb algorithm given an IPAConfigInfo\n> + * \\param[in] state The AWB specific active state shared across frames\n> + * \\param[in] session The AWB specific session configuration\n> + *\n> + * Configure and initialise the AWB algorithm module.\n> + *\n> + * \\return 0 if successful, an error code otherwise\n> + */\n> +int AwbAlgorithm::configure(awb::ActiveState &state, awb::Session &session)\n> +{\n> +\tstate.manual.gains = RGB<double>{ 1.0 };\n> +\tauto gains = gainsFromColourTemperature(kDefaultColourTemperature);\n> +\tif (gains)\n> +\t\tstate.automatic.gains = *gains;\n> +\telse\n> +\t\tstate.automatic.gains = RGB<double>{ 1.0 };\n> +\n> +\tstate.autoEnabled = true;\n> +\tstate.manual.temperatureK = kDefaultColourTemperature;\n> +\tstate.automatic.temperatureK = kDefaultColourTemperature;\n> +\n> +\tsession.enabled = true;\n> +\n> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\fn AwbAlgorithm::calculateAwb()\n>   * \\brief Calculate AWB data from the given statistics\n> diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\n> index 764be849270bcd42ecdf67aea3d13afa170c7499..4ceae537686f8f4c93686fab4b9efbc06e112b1d 100644\n> --- a/src/ipa/libipa/awb.h\n> +++ b/src/ipa/libipa/awb.h\n> @@ -65,6 +65,9 @@ public:\n>  \tvirtual ~AwbAlgorithm() = default;\n>  \n>  \tvirtual int init(const YamlObject &tuningData) = 0;\n> +\n> +\tint configure(awb::ActiveState &state, awb::Session &session);\n> +\n>  \tvirtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;\n>  \tvirtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;\n>  \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index f83da545be856c08cd758dc20a5ace91344101cf..86d5dfed3e1c2bb587705f05362229db3cdadafd 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -128,16 +128,7 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n>  int Awb::configure(IPAContext &context,\n>  \t\t   const IPACameraSensorInfo &configInfo)\n>  {\n> -\tcontext.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> -\tauto gains = awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> -\tif (gains)\n> -\t\tcontext.activeState.awb.automatic.gains = *gains;\n> -\telse\n> -\t\tcontext.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n> -\n> -\tcontext.activeState.awb.autoEnabled = true;\n> -\tcontext.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> -\tcontext.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> +\tawbAlgo_->configure(context.activeState.awb, context.configuration.awb);\n>  \n>  \t/*\n>  \t * Define the measurement window for AWB as a centered rectangle\n> @@ -148,8 +139,6 @@ int Awb::configure(IPAContext &context,\n>  \tcontext.configuration.awb.measureWindow.h_size = 3 * configInfo.outputSize.width / 4;\n>  \tcontext.configuration.awb.measureWindow.v_size = 3 * configInfo.outputSize.height / 4;\n>  \n> -\tcontext.configuration.awb.enabled = true;\n> -\n>  \treturn 0;\n>  }\n>  \n> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n> index 90c05e86bae6eefe4874feeb1263af07acd5fcfc..230b7807075941f086911549066e39c0a04dff5c 100644\n> --- a/src/ipa/simple/algorithms/awb.cpp\n> +++ b/src/ipa/simple/algorithms/awb.cpp\n> @@ -106,20 +106,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n>  int Awb::configure(IPAContext &context,\n>  \t\t   [[maybe_unused]] const IPAConfigInfo &configInfo)\n>  {\n> -\tcontext.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> -\tauto gains = awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> -\tif (gains)\n> -\t\tcontext.activeState.awb.automatic.gains = *gains;\n> -\telse\n> -\t\tcontext.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n> -\n> -\tcontext.activeState.awb.autoEnabled = true;\n> -\tcontext.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> -\tcontext.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> -\n> -\tcontext.configuration.awb.enabled = true;\n> -\n> -\treturn 0;\n> +\treturn awbAlgo_->configure(context.activeState.awb,\n> +\t\t\t\t   context.configuration.awb);\n>  }\n>  \n>  /**\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6EEEFBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 May 2026 14:37:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8056B63020;\n\tThu,  7 May 2026 16:37:46 +0200 (CEST)","from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n\t[205.220.180.131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CE1C26301E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 May 2026 16:37:44 +0200 (CEST)","from pps.filterd (m0279872.ppops.net [127.0.0.1])\n\tby mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n\t647AnJRb3924344 for <libcamera-devel@lists.libcamera.org>;\n\tThu, 7 May 2026 14:37:43 GMT","from mail-vk1-f200.google.com (mail-vk1-f200.google.com\n\t[209.85.221.200])\n\tby mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e0c88bjad-1\n\t(version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 May 2026 14:37:43 +0000 (GMT)","by mail-vk1-f200.google.com with SMTP id\n\t71dfb90a1353d-575242b4308so2068659e0c.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 May 2026 07:37:43 -0700 (PDT)","from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec?\n\t(2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:5bfa:a036:83f0:f9ec])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-bc833742a49sm90504766b.34.2026.05.07.07.37.40\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 07 May 2026 07:37:40 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=qualcomm.com header.i=@qualcomm.com\n\theader.b=\"Wm1ADjfs\"; dkim=pass (2048-bit key;\n\tunprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n\theader.b=\"Mn4FqIOw\"; dkim-atps=neutral","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n\tcontent-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to; s=qcppdkim1; bh=\n\tGQSqdUOiUkrpOAxOyzduvr61DaLniAqLpfjIJztKaoA=; b=Wm1ADjfsVXZTM4x8\n\tG51h/F88D2DG8LLz0af7WlormaegolO24n7BB7RkyPlVWeHnAg62OOWCv7jgy+2P\n\t9GVKLO7DN5pWhyD18iOmFAhloNIFId5K5OU0bVqutL/jSMB6VvU4idGdSj3Kdm+W\n\tH6ebuzcCsmljWu+LVcFejxw2rKlYxhvcmAgg8R9PnpmpuoBAQpEkiAzxCz0EG6EU\n\t4K6IRxqZJFCl+0xs+bQWgKQL4Cfdpci1QOD65Ekxhz9wAbUlAf0rQBonPITvf7CQ\n\tAtPhc0CiWz0H+PRwhLqk5kEJ1F+QM6O99o52xwmd29RVilfvIF0fxq1NqJ4kvWOs\n\tX+X0tQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=oss.qualcomm.com; s=google; t=1778164662; x=1778769462;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:in-reply-to:content-language:references\n\t:to:subject:from:user-agent:mime-version:date:message-id:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=GQSqdUOiUkrpOAxOyzduvr61DaLniAqLpfjIJztKaoA=;\n\tb=Mn4FqIOwAhMqNor4VWxtni3tGqkCkV5z1Zq4ol/vlgb3Npclqj1YVH+pYtlUCNjbWF\n\tYpGDo61lj9/ePWi42omOAFbcJ0VfuUN9aFAPtKb/PesddPoOv1gLN0Epuua4cnuocx5B\n\t2a9fdnx07UghbZQiyBmzaJRlhvkvHH6pzAwyDhEfAvrRf2JQLqshUlAji/6Xz9bKqu5J\n\tVTetU16Wa0aRt3Q7ns+jjoPEHZcUOHpjkjXOB5PRhCtplhwLwvIiU4HrccIE96vmYol7\n\t8KugHSME7mfINWmESfcJ6xrtZkxU6PyE+2HWOpU4tr3JoMBC0XitEIobY/0kzvG+wU/k\n\txZ3A=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1778164662; x=1778769462;\n\th=content-transfer-encoding:in-reply-to:content-language:references\n\t:to:subject:from:user-agent:mime-version:date:message-id:x-gm-gg\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=GQSqdUOiUkrpOAxOyzduvr61DaLniAqLpfjIJztKaoA=;\n\tb=nj1JXj/5FdMA1CxFQGhMiv4tVFoFe3TYQldnJHJS3Ps+o4+2+J2iL+OGC5Taz3movQ\n\tebQv/8HYeEjU7v7OTucdVQLzfdnpMeZg7Qrlc5emKmTE9hPSexxdKqvpy3gmv/nbIp/t\n\tlPwaEijrT6LsZNKdUDuDWcxg0olh9/HMQW/NpKrV+3ym62S+iUWYiesXE6lk8Hee4dy3\n\tWIZvBcpCwbnkF8/W8HG9z5HHtytUOuyaylQiZ+pQyNyZRMpQX/8p6I0WBLSyQXe6ypep\n\tJJs5vgh8Xr8OfLOdt+AI4SHxIffRWglOXgtcCGTsHfv7m0kSimnBvzcJgVLXKofoELSJ\n\tEvhA==","X-Forwarded-Encrypted":"i=1;\n\tAFNElJ+lm4NQeLH6zzinm/dQjyax3po4j9Gbi0vLTxHf1secVXWLIQbp8g67OTGQsd1odQ9q7nJqdSgriWZy5HSSO6w=@lists.libcamera.org","X-Gm-Message-State":"AOJu0YwzSOh1w5jaa3guYuW7sgUa/DLY0LU0bQOI46p+L9QyHH+26iQn\n\tsvd48oZGdZXxF/XW+bqRnvxIwJScM26jySQz/LljyqGX02zOuJYvjc6+fjr6YL0EvJUbUIE3MR0\n\trYDec3c7NlKA50G/gYDguwiBpyCUeOdJzEY/jvId0uFooWvnVA3vHkTDDnvvwtw72u3SpyBrSfB\n\tGxPGD3fqsmoOg=","X-Gm-Gg":"AeBDievkBxO7Yg+G5TbyT1mPL0Jjnm5ugXXWDG+C5zBhGZpuoBwPruM6QANccsXWGpV\n\tkw5/mAt9Exh4O8BtJZmzo58JajUUEDolZY0WIVgLuWInxVBcGwK206soRAj9eQiP6I69ZIFSW7I\n\t11PhjtKFCv3Vi2mYHGosuwVFfDAmvpTLfLgQJssKs5feUQDFO6TRIJP/Ly2Lu8ppMbF7BHkbmX8\n\tYEwbr1FV9/HllnShJVRnyjEQ9HjMd2yywXPLOjKQOTskSX1GAWWoem+dnFJ7SrfHrT7MwhOyLS1\n\tzAK1Ov1c5OCIDu3nkbI8DSZ+q93QWquDvBgiq6vfgsb0mRp8F3HH3mvL9Gg7N0F6VgsuhE3bI01\n\tlljIdSfjVY8kzt7V4RmOs1jcaLz1x6+6DrJgDZXXHSWe0ViKSyypMaRnn5XaqoewDTnIUZ41Y7M\n\tHSnAWD9cEMj3bcViJwIrkMPYZ13TGn6lZfq84xczyGUx4/ukIIR2fkTrtbWqiFFfl2Hc0LBeiWz\n\taVkNjB2XUg6LY5zp9j/q4zLpc0/jPSMdL4GMg==","X-Received":["by 2002:a05:6122:4089:b0:56f:2f47:4e69 with SMTP id\n\t71dfb90a1353d-5755960af8amr5033724e0c.10.1778164662554; \n\tThu, 07 May 2026 07:37:42 -0700 (PDT)","by 2002:a05:6122:4089:b0:56f:2f47:4e69 with SMTP id\n\t71dfb90a1353d-5755960af8amr5033683e0c.10.1778164662085; \n\tThu, 07 May 2026 07:37:42 -0700 (PDT)"],"Message-ID":"<2395223c-be83-444f-b286-a7c761fbaf8e@oss.qualcomm.com>","Date":"Thu, 7 May 2026 16:37:39 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","From":"johannes.goede@oss.qualcomm.com","Subject":"Re: [PATCH 11/13] ipa: libipa: awb: Move configure to common","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>\n\t<20260407-kbingham-awb-split-v1-11-a39af3f4dc20@ideasonboard.com>","Content-Language":"en-US, nl","In-Reply-To":"<20260407-kbingham-awb-split-v1-11-a39af3f4dc20@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-Proofpoint-ORIG-GUID":"U6Y7uND3uzDeYpxeSDPnKpeB79ZAdlnm","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNTA3MDE0NiBTYWx0ZWRfX5Zup4DpKVz+Q\n\t9FnyRLp0TFu4uGT/FKfq2FG7SZOX7kbxHLLKVDBHTuh2N8xQmqq6HbVxIerY0Dyb+MmurL3SgX2\n\th37YwtgtJMerZBqSS8thMJgx0znWpuQxnJWEcZbzeXyttw1HrBdIXjt1cr4XN9kgcATW+mqxHKn\n\tmge2jLQotGU+lhhoVrhcAGKFeRuhy6P+fHeaYaAu8jNkb4/QeHmLYC/ThjCyjbJrffGUfiUQU0e\n\tnVuoPv8C+OM1LhhbJYUntuNCQ+vfk2tOrofzbp9zmCNoy/VyID2WKIbQIH9bn8Tplqc4GUAGHns\n\tj4uJaCou0Ufd6dpETuLK8AARHgxMQ739WuvgREaRcAx27icyJ6gTco5ATcC9WRfEcQz94uaAAsl\n\tu1EIjomt8xNDwBspwI4I4wvGdP8l7mQdO8srOzsSN6eDzwTUi6PP9W8QCU9hKFQ6HTas1Hi3osh\n\t6zi2eeUOQbqoey+B/QA==","X-Proofpoint-GUID":"U6Y7uND3uzDeYpxeSDPnKpeB79ZAdlnm","X-Authority-Analysis":"v=2.4 cv=X8Zi7mTe c=1 sm=1 tr=0 ts=69fca3b7 cx=c_pps\n\ta=wuOIiItHwq1biOnFUQQHKA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10\n\ta=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n\ta=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=P1BnusSwAAAA:8\n\ta=EUspDBNiAAAA:8 a=dR2rCv9jPLchitLQeDoA:9 a=QEXdDO2ut3YA:10\n\ta=XD7yVLdPMpWraOa8Un9W:22 a=D0XLA9XvdZm18NrgonBM:22","X-Proofpoint-Virus-Version":"vendor=baseguard\n\tengine=ICAP:2.0.293, Aquarius:18.0.1143, Hydra:6.1.51,\n\tFMLib:17.12.100.49\n\tdefinitions=2026-05-07_01,2026-05-06_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\timpostorscore=0 suspectscore=0 spamscore=0 adultscore=0\n\tmalwarescore=0\n\tlowpriorityscore=0 clxscore=1015 phishscore=0 priorityscore=1501\n\tbulkscore=0\n\tclassifier=typeunknown authscore=0 authtc= authcc= route=outbound\n\tadjust=0\n\treason=mlx scancount=1 engine=8.22.0-2604200000\n\tdefinitions=main-2605070146","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]