[{"id":28108,"web_url":"https://patchwork.libcamera.org/comment/28108/","msgid":"<170049226949.1375089.12127836481692749105@ping.linuxembedded.co.uk>","date":"2023-11-20T14:57:49","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting David Plowman via libcamera-devel (2023-11-10 16:14:33)\n> ColourTemperature is now exported as a writable control so that\n> algorithms can set it directly. The AWB algorithm class now requires a\n> method to be provided to perform this operation. The method should\n> clamp the passed value to the calibrated range known to the algorithm.\n> \n> The default range is set very wide to cover all conceivable future AWB\n> calibrations. It will always be clamped before use.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n>  src/ipa/rpi/controller/awb_algorithm.h |  1 +\n>  src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n>  src/ipa/rpi/controller/rpi/awb.h       |  1 +\n>  4 files changed, 40 insertions(+)\n> \n> diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> index 97a32522..cd1d6e3d 100644\n> --- a/src/ipa/rpi/common/ipa_base.cpp\n> +++ b/src/ipa/rpi/common/ipa_base.cpp\n> @@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n>         { &controls::AwbEnable, ControlInfo(false, true) },\n>         { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n>         { &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n> +       { &controls::ColourTemperature, ControlInfo(100, 100000) },\n>         { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n>  };\n>  \n> @@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList &controls)\n>                         break;\n>                 }\n>  \n> +               case controls::COLOUR_TEMPERATURE: {\n> +                       /* Silently ignore this control for a mono sensor. */\n> +                       if (monoSensor_)\n> +                               break;\n\nI wonder if this is where the construction of the control info map\nshould be handled / supported by the algorithms so they can populate it\ncorrectly / dynamically based on what they can handle. But that's not\nfor this patch - and I suspect this is ok.\n\n\n> +\n> +                       auto temperatureK = ctrl.second.get<int32_t>();\n> +                       RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n> +                               controller_.getAlgorithm(\"awb\"));\n> +                       if (!awb) {\n> +                               LOG(IPARPI, Warning)\n> +                                       << \"Could not set COLOUR_TEMPERATURE - no AWB algorithm\";\n> +                               break;\n\nI guess it would also prevent exposing a control when there's no\nalgorithm to implement/support it though. Still - for now this seems\nlike all that could be done here then.\n\n\nBut otherwise\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +                       }\n> +\n> +                       awb->setColourTemperature(temperatureK);\n> +                       /* This metadata will get reported back automatically. */\n> +                       break;\n> +               }\n> +\n>                 case controls::BRIGHTNESS: {\n>                         RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>(\n>                                 controller_.getAlgorithm(\"contrast\"));\n> diff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h\n> index 8462c4db..d966dfa8 100644\n> --- a/src/ipa/rpi/controller/awb_algorithm.h\n> +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> @@ -18,6 +18,7 @@ public:\n>         virtual unsigned int getConvergenceFrames() const = 0;\n>         virtual void setMode(std::string const &modeName) = 0;\n>         virtual void setManualGains(double manualR, double manualB) = 0;\n> +       virtual void setColourTemperature(double temperatureK) = 0;\n>         virtual void enableAuto() = 0;\n>         virtual void disableAuto() = 0;\n>  };\n> diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> index 5ae0c2fa..0918e20d 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> @@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double manualB)\n>         }\n>  }\n>  \n> +void Awb::setColourTemperature(double temperatureK)\n> +{\n> +       if (!config_.bayes) {\n> +               LOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set colour temperature\";\n> +               return;\n> +       }\n> +\n> +       temperatureK = config_.ctR.domain().clip(temperatureK);\n> +       manualR_ = 1 / config_.ctR.eval(temperatureK);\n> +       manualB_ = 1 / config_.ctB.eval(temperatureK);\n> +\n> +       syncResults_.temperatureK = temperatureK;\n> +       syncResults_.gainR = manualR_;\n> +       syncResults_.gainG = 1.0;\n> +       syncResults_.gainB = manualB_;\n> +       prevSyncResults_ = syncResults_;\n> +}\n> +\n>  void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n>                      Metadata *metadata)\n>  {\n> diff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\n> index e7d49cd8..dbd79eda 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.h\n> +++ b/src/ipa/rpi/controller/rpi/awb.h\n> @@ -97,6 +97,7 @@ public:\n>         unsigned int getConvergenceFrames() const override;\n>         void setMode(std::string const &name) override;\n>         void setManualGains(double manualR, double manualB) override;\n> +       void setColourTemperature(double temperatureK) override;\n>         void enableAuto() override;\n>         void disableAuto() override;\n>         void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n> -- \n> 2.39.2\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 B5039C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Nov 2023 14:57:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 151C8629BC;\n\tMon, 20 Nov 2023 15:57:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 28EE161DAF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Nov 2023 15:57:52 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 322A5BBB;\n\tMon, 20 Nov 2023 15:57:22 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700492274;\n\tbh=7b42f0uxjIc+XtoXJZ+dV51Ii+JggQ4qcZrvd61Vsz0=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=fh4r5cCMm/HrSGOuHn+C2YkNq+wcaM2RaI6YQoBTTztdtE3EDdeTwq3hkeeHsnolU\n\tSoOFROYvHuaz3lfsP2Ag933n5mxRvvbTilrY8AhoP5Dl77QCDH92v3RjuEBsl0Dm0M\n\tfX1AngirpIC+uCegWDq22HxxVIg3aTFpSLAYo6EH+SRglpar0uywiAnNBYk1PgClud\n\tm1hk2l8HqFP1gpIyCAt3ULtEYcUmoaLW4Sil9lGOebLK71DjG841tBZvH4WR3O9gTK\n\tw3b8UIqB+C1Bs6gIeGfvsKS6a1lHJXJPUpvM9Zc/aeHsEBKtd8s1pkgtRPwYxucl4v\n\tUfF0bb6pydijA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1700492242;\n\tbh=7b42f0uxjIc+XtoXJZ+dV51Ii+JggQ4qcZrvd61Vsz0=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=wlvBnwHYua+jJ88Az0qzrKfpjkPJ8LxbjaAFnDxDkBejGVRYQYJQhh++T3RK2I+PV\n\tfkVpWMLZoVhLfdXMRcao2/rbIpVdYqvKlBbwbighHR6xcQWeXRT3EWPwCCw5yuDsUv\n\tnFFj+4Iby1KXZvYSXuNh0YbNEvpDbOrVsibiii5U="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"wlvBnwHY\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20231110161433.413382-1-david.plowman@raspberrypi.com>","References":"<20231110161433.413382-1-david.plowman@raspberrypi.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 20 Nov 2023 14:57:49 +0000","Message-ID":"<170049226949.1375089.12127836481692749105@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28133,"web_url":"https://patchwork.libcamera.org/comment/28133/","msgid":"<170067306160.4089757.1924870482073437793@ping.linuxembedded.co.uk>","date":"2023-11-22T17:11:01","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nAre you happy with this patch?\n\n\nQuoting Kieran Bingham (2023-11-20 14:57:49)\n> Quoting David Plowman via libcamera-devel (2023-11-10 16:14:33)\n> > ColourTemperature is now exported as a writable control so that\n> > algorithms can set it directly. The AWB algorithm class now requires a\n> > method to be provided to perform this operation. The method should\n> > clamp the passed value to the calibrated range known to the algorithm.\n> > \n> > The default range is set very wide to cover all conceivable future AWB\n> > calibrations. It will always be clamped before use.\n> > \n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n> >  src/ipa/rpi/controller/awb_algorithm.h |  1 +\n> >  src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n> >  src/ipa/rpi/controller/rpi/awb.h       |  1 +\n> >  4 files changed, 40 insertions(+)\n> > \n> > diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> > index 97a32522..cd1d6e3d 100644\n> > --- a/src/ipa/rpi/common/ipa_base.cpp\n> > +++ b/src/ipa/rpi/common/ipa_base.cpp\n> > @@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n> >         { &controls::AwbEnable, ControlInfo(false, true) },\n> >         { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n> >         { &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n> > +       { &controls::ColourTemperature, ControlInfo(100, 100000) },\n> >         { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n> >  };\n> >  \n> > @@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList &controls)\n> >                         break;\n> >                 }\n> >  \n> > +               case controls::COLOUR_TEMPERATURE: {\n> > +                       /* Silently ignore this control for a mono sensor. */\n> > +                       if (monoSensor_)\n> > +                               break;\n> \n> I wonder if this is where the construction of the control info map\n> should be handled / supported by the algorithms so they can populate it\n> correctly / dynamically based on what they can handle. But that's not\n> for this patch - and I suspect this is ok.\n> \n> \n> > +\n> > +                       auto temperatureK = ctrl.second.get<int32_t>();\n> > +                       RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n> > +                               controller_.getAlgorithm(\"awb\"));\n> > +                       if (!awb) {\n> > +                               LOG(IPARPI, Warning)\n> > +                                       << \"Could not set COLOUR_TEMPERATURE - no AWB algorithm\";\n> > +                               break;\n> \n> I guess it would also prevent exposing a control when there's no\n> algorithm to implement/support it though. Still - for now this seems\n> like all that could be done here then.\n> \n> \n> But otherwise\n> \n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nNaush ... are you happy with this patch ?\n\n> \n> > +                       }\n> > +\n> > +                       awb->setColourTemperature(temperatureK);\n> > +                       /* This metadata will get reported back automatically. */\n> > +                       break;\n> > +               }\n> > +\n> >                 case controls::BRIGHTNESS: {\n> >                         RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>(\n> >                                 controller_.getAlgorithm(\"contrast\"));\n> > diff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h\n> > index 8462c4db..d966dfa8 100644\n> > --- a/src/ipa/rpi/controller/awb_algorithm.h\n> > +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> > @@ -18,6 +18,7 @@ public:\n> >         virtual unsigned int getConvergenceFrames() const = 0;\n> >         virtual void setMode(std::string const &modeName) = 0;\n> >         virtual void setManualGains(double manualR, double manualB) = 0;\n> > +       virtual void setColourTemperature(double temperatureK) = 0;\n> >         virtual void enableAuto() = 0;\n> >         virtual void disableAuto() = 0;\n> >  };\n> > diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> > index 5ae0c2fa..0918e20d 100644\n> > --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> > +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> > @@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double manualB)\n> >         }\n> >  }\n> >  \n> > +void Awb::setColourTemperature(double temperatureK)\n> > +{\n> > +       if (!config_.bayes) {\n> > +               LOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set colour temperature\";\n> > +               return;\n> > +       }\n> > +\n> > +       temperatureK = config_.ctR.domain().clip(temperatureK);\n> > +       manualR_ = 1 / config_.ctR.eval(temperatureK);\n> > +       manualB_ = 1 / config_.ctB.eval(temperatureK);\n> > +\n> > +       syncResults_.temperatureK = temperatureK;\n> > +       syncResults_.gainR = manualR_;\n> > +       syncResults_.gainG = 1.0;\n> > +       syncResults_.gainB = manualB_;\n> > +       prevSyncResults_ = syncResults_;\n> > +}\n> > +\n> >  void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n> >                      Metadata *metadata)\n> >  {\n> > diff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\n> > index e7d49cd8..dbd79eda 100644\n> > --- a/src/ipa/rpi/controller/rpi/awb.h\n> > +++ b/src/ipa/rpi/controller/rpi/awb.h\n> > @@ -97,6 +97,7 @@ public:\n> >         unsigned int getConvergenceFrames() const override;\n> >         void setMode(std::string const &name) override;\n> >         void setManualGains(double manualR, double manualB) override;\n> > +       void setColourTemperature(double temperatureK) override;\n> >         void enableAuto() override;\n> >         void disableAuto() override;\n> >         void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n> > -- \n> > 2.39.2\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 F1722BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Nov 2023 17:11:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 48AB8629AF;\n\tWed, 22 Nov 2023 18:11:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8505961DAD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Nov 2023 18:11:04 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 39DBC276;\n\tWed, 22 Nov 2023 18:10:33 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700673066;\n\tbh=htDYGG5hdZU616Yb2Wi8/a0yua/VaJPcCPSKmitdeXk=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=s0Fe2QJGqAvFQeQtO5Uwd4QUDcWNay2pfgV4XxxbOlH0kwWuArDO4jFM3pvf2wmrf\n\t6UICaQaLggXtI29CBzaedpy24kzuUcFnHid/jjtuC6G0TksNS7L7h/D5gxy99GMMa6\n\ttAIxSdHTV8XWs1mGyEivi0WCH18/EeQp9bPHRKPT49Fy4ehYMHfO4349XkJ838NqsB\n\tqGgKmmDZMrWoKXRQJvoLgL5LULZBvzeVgQQhakA6PyGxxAOTrd4XePI+jyBA406iWe\n\trp/4kOP/0aOhMTb2z2KNHjQe4x34dTGGnwtZ0JIn6N0NR+XMdh3wKaEYTpNH4EPFms\n\tm/WhDTWOvKdhA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1700673033;\n\tbh=htDYGG5hdZU616Yb2Wi8/a0yua/VaJPcCPSKmitdeXk=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=PmiOZ5Am8knUMoMAaBWVDw9ZWUBslfKoRK2+pLtTFra0kreNn+yDWDNCdLROs3E8c\n\t19L7JehQ+RllEUmYUfnKMAjr4+ftnRIx25oKc4z9IIi7XgDfs3QGDKDhyWAK6H4a0O\n\tUXLcgSeakA8h4PbjsJOQ6oef4wwgWQY4x14bSV14="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"PmiOZ5Am\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<170049226949.1375089.12127836481692749105@ping.linuxembedded.co.uk>","References":"<20231110161433.413382-1-david.plowman@raspberrypi.com>\n\t<170049226949.1375089.12127836481692749105@ping.linuxembedded.co.uk>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>, ","Date":"Wed, 22 Nov 2023 17:11:01 +0000","Message-ID":"<170067306160.4089757.1924870482073437793@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28135,"web_url":"https://patchwork.libcamera.org/comment/28135/","msgid":"<CAEmqJPr2mLsBYKcMfzAHJN5OB9wKMJrPoMmXRTCrOjpqC_+SMg@mail.gmail.com>","date":"2023-11-22T18:39:24","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Fri, 10 Nov 2023, 4:14 pm David Plowman via libcamera-devel, <\nlibcamera-devel@lists.libcamera.org> wrote:\n\n> ColourTemperature is now exported as a writable control so that\n> algorithms can set it directly. The AWB algorithm class now requires a\n> method to be provided to perform this operation. The method should\n> clamp the passed value to the calibrated range known to the algorithm.\n>\n> The default range is set very wide to cover all conceivable future AWB\n> calibrations. It will always be clamped before use.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n\nOops thought I had already reviewed this!\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n---\n>  src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n>  src/ipa/rpi/controller/awb_algorithm.h |  1 +\n>  src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n>  src/ipa/rpi/controller/rpi/awb.h       |  1 +\n>  4 files changed, 40 insertions(+)\n>\n> diff --git a/src/ipa/rpi/common/ipa_base.cpp\n> b/src/ipa/rpi/common/ipa_base.cpp\n> index 97a32522..cd1d6e3d 100644\n> --- a/src/ipa/rpi/common/ipa_base.cpp\n> +++ b/src/ipa/rpi/common/ipa_base.cpp\n> @@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n>         { &controls::AwbEnable, ControlInfo(false, true) },\n>         { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n>         { &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n> +       { &controls::ColourTemperature, ControlInfo(100, 100000) },\n>         { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n>  };\n>\n> @@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList\n> &controls)\n>                         break;\n>                 }\n>\n> +               case controls::COLOUR_TEMPERATURE: {\n> +                       /* Silently ignore this control for a mono sensor.\n> */\n> +                       if (monoSensor_)\n> +                               break;\n> +\n> +                       auto temperatureK = ctrl.second.get<int32_t>();\n> +                       RPiController::AwbAlgorithm *awb =\n> dynamic_cast<RPiController::AwbAlgorithm *>(\n> +                               controller_.getAlgorithm(\"awb\"));\n> +                       if (!awb) {\n> +                               LOG(IPARPI, Warning)\n> +                                       << \"Could not set\n> COLOUR_TEMPERATURE - no AWB algorithm\";\n> +                               break;\n> +                       }\n> +\n> +                       awb->setColourTemperature(temperatureK);\n> +                       /* This metadata will get reported back\n> automatically. */\n> +                       break;\n> +               }\n> +\n>                 case controls::BRIGHTNESS: {\n>                         RPiController::ContrastAlgorithm *contrast =\n> dynamic_cast<RPiController::ContrastAlgorithm *>(\n>                                 controller_.getAlgorithm(\"contrast\"));\n> diff --git a/src/ipa/rpi/controller/awb_algorithm.h\n> b/src/ipa/rpi/controller/awb_algorithm.h\n> index 8462c4db..d966dfa8 100644\n> --- a/src/ipa/rpi/controller/awb_algorithm.h\n> +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> @@ -18,6 +18,7 @@ public:\n>         virtual unsigned int getConvergenceFrames() const = 0;\n>         virtual void setMode(std::string const &modeName) = 0;\n>         virtual void setManualGains(double manualR, double manualB) = 0;\n> +       virtual void setColourTemperature(double temperatureK) = 0;\n>         virtual void enableAuto() = 0;\n>         virtual void disableAuto() = 0;\n>  };\n> diff --git a/src/ipa/rpi/controller/rpi/awb.cpp\n> b/src/ipa/rpi/controller/rpi/awb.cpp\n> index 5ae0c2fa..0918e20d 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> @@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double\n> manualB)\n>         }\n>  }\n>\n> +void Awb::setColourTemperature(double temperatureK)\n> +{\n> +       if (!config_.bayes) {\n> +               LOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set\n> colour temperature\";\n> +               return;\n> +       }\n> +\n> +       temperatureK = config_.ctR.domain().clip(temperatureK);\n> +       manualR_ = 1 / config_.ctR.eval(temperatureK);\n> +       manualB_ = 1 / config_.ctB.eval(temperatureK);\n> +\n> +       syncResults_.temperatureK = temperatureK;\n> +       syncResults_.gainR = manualR_;\n> +       syncResults_.gainG = 1.0;\n> +       syncResults_.gainB = manualB_;\n> +       prevSyncResults_ = syncResults_;\n> +}\n> +\n>  void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n>                      Metadata *metadata)\n>  {\n> diff --git a/src/ipa/rpi/controller/rpi/awb.h\n> b/src/ipa/rpi/controller/rpi/awb.h\n> index e7d49cd8..dbd79eda 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.h\n> +++ b/src/ipa/rpi/controller/rpi/awb.h\n> @@ -97,6 +97,7 @@ public:\n>         unsigned int getConvergenceFrames() const override;\n>         void setMode(std::string const &name) override;\n>         void setManualGains(double manualR, double manualB) override;\n> +       void setColourTemperature(double temperatureK) override;\n>         void enableAuto() override;\n>         void disableAuto() override;\n>         void switchMode(CameraMode const &cameraMode, Metadata *metadata)\n> override;\n> --\n> 2.39.2\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 243A7BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Nov 2023 18:39:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5996F629BC;\n\tWed, 22 Nov 2023 19:39:37 +0100 (CET)","from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com\n\t[IPv6:2607:f8b0:4864:20::112d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7209261DAD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Nov 2023 19:39:35 +0100 (CET)","by mail-yw1-x112d.google.com with SMTP id\n\t00721157ae682-5ac376d311aso686947b3.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Nov 2023 10:39:35 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700678377;\n\tbh=nwnCX0Jhf5ANgSIsBGzRnEuiTj9FQcX19QM5k8231Z4=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=yzAEv87c/l7elORbj1LprZwUOL/WSjG/R6XQlnOOJrJr5qQR4ZrfDFicH8LVOoL29\n\tcnhuHFEnIqM15gB8a0YkRzFyhl33vFCas6Vunsi/H821WMgwMXF5EXDQiCWRfzgo/o\n\thj3SnleWYTWOUqKwrjYtSL597h5hoE6Afg1wj4AnTkIDHi5EO+KGdXr6WUh0WDuoZq\n\tlPSPe//LkjB3IbLO2iAy3MtDMsziiQWmud2+vIG6odsEchxzEk+9kQ3BxgfdzoP28Z\n\tazAKYsPRhM/2ilSGD5EjiBNV7T709IZioUT+n/ZHLL+iEqclg2wPa4MwbLGLiwVH97\n\tkLocDyBN1aWDg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1700678374; x=1701283174;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=Q90sEOo2+atmkiiB4EKGEAc3RdUJPqVv8f2y8y0oMDg=;\n\tb=pomdnKwJTSLvB3zXyIGqdfi5Yw6fj04L9gUomORBHemmP3g98MJkRhFicTtJeePmog\n\tBnduqYnmzZoMHXfdKytNvccLTnv8uVflEybOqYosPqbl5QTmyC1tR5oVAOFv/p1bL74X\n\tXj7AX3hLJB5mvdpbPxVJF3LbIEGV59o6ar8sUDn/YEwmLewPrFoLosr/pMCgeOTPDT0X\n\tQW7Y7NNIcswFgMvWFm7ZiFqXHZ/WqbXw2L534G1sDRkolE+5qRObCTzqwpEYenvz3Vdp\n\tIZSVksdrnxyPeyI3fBklQxDZH+qUXGp+wYiOXNZzsizf6O1ubbbrPodw5LyUlE55iBmO\n\tMQsQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"pomdnKwJ\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1700678374; x=1701283174;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=Q90sEOo2+atmkiiB4EKGEAc3RdUJPqVv8f2y8y0oMDg=;\n\tb=gm5fA6rap3hnNIYoAOVzRbNo6cg8cnRAJDoqY1lfPYwBX2eSG8y6EN46vpPYix8CFT\n\tS+PPqEQtGL8FhXmRnY6+ZM/FOkcUJzlmB+C03PJ+bIjF+KMkQJX5MUwT8v3j1YNIWOEW\n\tHx+NPIne0LEurXZ3DeW64UyrNyzx/3fn1JtaD11CGCIat/W+JcFt/FP0hKm2SE/dlCfg\n\tHJsyUzoK/c+yfY1Mz1lCNNolLSpiRnXeA8hKrpXgLra2qATTh2YjnKGGTaKzH6EOIfgY\n\tpIFjte+qPvqX1slhPt+qcDHeUxfnmi1xSJyonYX/utoaqelfOqY2N6WJzpaMO0RTwLMD\n\t6Lhw==","X-Gm-Message-State":"AOJu0YxAPKWLWa/MpZnccw9cNB0/NxbyEjBaVFfQisDqwhqQQ23vwrqU\n\tZKOkulFerMTlruViPqRY+Mfu90bVav5rrgRlxL+kOA==","X-Google-Smtp-Source":"AGHT+IGm/itNruxC2kkfGfGVEmJLqn44idjH1GdX186oOnT19P9aGAhq1KFo+EL/wOhP2Qb80SeePfEhtVuw0Y4LhXY=","X-Received":"by 2002:a81:528f:0:b0:5cb:49d6:cea4 with SMTP id\n\tg137-20020a81528f000000b005cb49d6cea4mr2846920ywb.20.1700678374233;\n\tWed, 22 Nov 2023 10:39:34 -0800 (PST)","MIME-Version":"1.0","References":"<20231110161433.413382-1-david.plowman@raspberrypi.com>","In-Reply-To":"<20231110161433.413382-1-david.plowman@raspberrypi.com>","Date":"Wed, 22 Nov 2023 18:39:24 +0000","Message-ID":"<CAEmqJPr2mLsBYKcMfzAHJN5OB9wKMJrPoMmXRTCrOjpqC_+SMg@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"0000000000005fb037060ac20a33\"","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28155,"web_url":"https://patchwork.libcamera.org/comment/28155/","msgid":"<20231123122805.GM15697@pendragon.ideasonboard.com>","date":"2023-11-23T12:28:05","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Fri, Nov 10, 2023 at 04:14:33PM +0000, David Plowman via libcamera-devel wrote:\n> ColourTemperature is now exported as a writable control so that\n> algorithms can set it directly.\n\nI'm puzzled here. You mention algorithms, but the patch exposes the\ncontrol as being writable from applications. Is it a typo in the commit\nmessage ? If so, what's the use case ? control_ids.yaml documents the\ncontrol as\n\n  - ColourTemperature:\n      type: int32_t\n      description: Report the current estimate of the colour temperature, in\n        kelvin, for this frame. The ColourTemperature control can only be\n        returned in metadata.\n\nso this would need to be updated as a prerequisite for this patch.\n\n> The AWB algorithm class now requires a\n> method to be provided to perform this operation. The method should\n> clamp the passed value to the calibrated range known to the algorithm.\n> \n> The default range is set very wide to cover all conceivable future AWB\n> calibrations. It will always be clamped before use.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n>  src/ipa/rpi/controller/awb_algorithm.h |  1 +\n>  src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n>  src/ipa/rpi/controller/rpi/awb.h       |  1 +\n>  4 files changed, 40 insertions(+)\n> \n> diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> index 97a32522..cd1d6e3d 100644\n> --- a/src/ipa/rpi/common/ipa_base.cpp\n> +++ b/src/ipa/rpi/common/ipa_base.cpp\n> @@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n>  \t{ &controls::AwbEnable, ControlInfo(false, true) },\n>  \t{ &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n>  \t{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n> +\t{ &controls::ColourTemperature, ControlInfo(100, 100000) },\n>  \t{ &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n>  };\n>  \n> @@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList &controls)\n>  \t\t\tbreak;\n>  \t\t}\n>  \n> +\t\tcase controls::COLOUR_TEMPERATURE: {\n> +\t\t\t/* Silently ignore this control for a mono sensor. */\n> +\t\t\tif (monoSensor_)\n> +\t\t\t\tbreak;\n> +\n> +\t\t\tauto temperatureK = ctrl.second.get<int32_t>();\n> +\t\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n> +\t\t\t\tcontroller_.getAlgorithm(\"awb\"));\n> +\t\t\tif (!awb) {\n> +\t\t\t\tLOG(IPARPI, Warning)\n> +\t\t\t\t\t<< \"Could not set COLOUR_TEMPERATURE - no AWB algorithm\";\n> +\t\t\t\tbreak;\n> +\t\t\t}\n> +\n> +\t\t\tawb->setColourTemperature(temperatureK);\n> +\t\t\t/* This metadata will get reported back automatically. */\n> +\t\t\tbreak;\n> +\t\t}\n> +\n>  \t\tcase controls::BRIGHTNESS: {\n>  \t\t\tRPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>(\n>  \t\t\t\tcontroller_.getAlgorithm(\"contrast\"));\n> diff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h\n> index 8462c4db..d966dfa8 100644\n> --- a/src/ipa/rpi/controller/awb_algorithm.h\n> +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> @@ -18,6 +18,7 @@ public:\n>  \tvirtual unsigned int getConvergenceFrames() const = 0;\n>  \tvirtual void setMode(std::string const &modeName) = 0;\n>  \tvirtual void setManualGains(double manualR, double manualB) = 0;\n> +\tvirtual void setColourTemperature(double temperatureK) = 0;\n>  \tvirtual void enableAuto() = 0;\n>  \tvirtual void disableAuto() = 0;\n>  };\n> diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> index 5ae0c2fa..0918e20d 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> @@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double manualB)\n>  \t}\n>  }\n>  \n> +void Awb::setColourTemperature(double temperatureK)\n> +{\n> +\tif (!config_.bayes) {\n> +\t\tLOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set colour temperature\";\n> +\t\treturn;\n> +\t}\n> +\n> +\ttemperatureK = config_.ctR.domain().clip(temperatureK);\n> +\tmanualR_ = 1 / config_.ctR.eval(temperatureK);\n> +\tmanualB_ = 1 / config_.ctB.eval(temperatureK);\n> +\n> +\tsyncResults_.temperatureK = temperatureK;\n> +\tsyncResults_.gainR = manualR_;\n> +\tsyncResults_.gainG = 1.0;\n> +\tsyncResults_.gainB = manualB_;\n> +\tprevSyncResults_ = syncResults_;\n> +}\n> +\n>  void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n>  \t\t     Metadata *metadata)\n>  {\n> diff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\n> index e7d49cd8..dbd79eda 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.h\n> +++ b/src/ipa/rpi/controller/rpi/awb.h\n> @@ -97,6 +97,7 @@ public:\n>  \tunsigned int getConvergenceFrames() const override;\n>  \tvoid setMode(std::string const &name) override;\n>  \tvoid setManualGains(double manualR, double manualB) override;\n> +\tvoid setColourTemperature(double temperatureK) override;\n>  \tvoid enableAuto() override;\n>  \tvoid disableAuto() override;\n>  \tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;","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 81E47C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Nov 2023 12:28:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB343629BD;\n\tThu, 23 Nov 2023 13:27:59 +0100 (CET)","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 46E1A61DAC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Nov 2023 13:27:58 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 46972A06;\n\tThu, 23 Nov 2023 13:27:26 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700742480;\n\tbh=11x3PBGkoB9rUfFQM/GlOzN9ATmrPyToWR3YfAcxAYY=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=uRjHVSh78Ot45RAHK3UtDScOaPYUf2VQCe0YHASiTvFP8TK4eEThNHEsZz5LszYne\n\tFu8vi6mhyr6yiY8Hs0lRxSl5vde5kl1dlJtllyzMnCMAvidrcNd5Pslt/NIvajaMd0\n\taNAWONnCppcHAdOKPuV8UfVo7kskoK1nMi5C8BYyf+ycyjhdbfkJ/X2CCMEOsZeE0r\n\tWn8CJ+T9OicvWdUnbe2RunaAhCZyYetmGRCV0PR/1K17G/+xmsW1rwJydBx+L5Qst/\n\tXrJ1qlG2eJbRouEUMYxJ3M5jQ3T38m4/IW32IeHZb3N/6AZ9cbtmvcS+eIULjOy+GI\n\tyMvZ8YWmVW5tQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1700742446;\n\tbh=11x3PBGkoB9rUfFQM/GlOzN9ATmrPyToWR3YfAcxAYY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mCNNqkTLTKIkkcG6lmYC8GgdZvIO9VvM1ihsDr3kmLyBuGZy4+HlRozGp2ZLHNhS/\n\tMKqjN81oV7PTVCYIaJRFLJ/PsYDoheCENctGzGbIACi7HVkv6d/a9QfRALA4f79+W8\n\tTmfQ9p573iM2+vqbKW3bwk70rYnXuGlPSQ2gOvCs="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"mCNNqkTL\"; dkim-atps=neutral","Date":"Thu, 23 Nov 2023 14:28:05 +0200","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20231123122805.GM15697@pendragon.ideasonboard.com>","References":"<20231110161433.413382-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20231110161433.413382-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28157,"web_url":"https://patchwork.libcamera.org/comment/28157/","msgid":"<CAHW6GYLPk4ALUhhRfK_+NWL0JdBC5YP1g4WfTyzMa-isBOxVwQ@mail.gmail.com>","date":"2023-11-23T12:54:43","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks for the review.\n\nOn Thu, 23 Nov 2023 at 12:27, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Fri, Nov 10, 2023 at 04:14:33PM +0000, David Plowman via libcamera-devel wrote:\n> > ColourTemperature is now exported as a writable control so that\n> > algorithms can set it directly.\n>\n> I'm puzzled here. You mention algorithms, but the patch exposes the\n> control as being writable from applications. Is it a typo in the commit\n> message ? If so, what's the use case ? control_ids.yaml documents the\n> control as\n\nYes, I'll change \"algorithms\" to \"applications\".\n\n>\n>   - ColourTemperature:\n>       type: int32_t\n>       description: Report the current estimate of the colour temperature, in\n>         kelvin, for this frame. The ColourTemperature control can only be\n>         returned in metadata.\n>\n> so this would need to be updated as a prerequisite for this patch.\n\nI'll add a patch before this one to change that description.\n\nThanks!\nDavid\n\n>\n> > The AWB algorithm class now requires a\n> > method to be provided to perform this operation. The method should\n> > clamp the passed value to the calibrated range known to the algorithm.\n> >\n> > The default range is set very wide to cover all conceivable future AWB\n> > calibrations. It will always be clamped before use.\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n> >  src/ipa/rpi/controller/awb_algorithm.h |  1 +\n> >  src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n> >  src/ipa/rpi/controller/rpi/awb.h       |  1 +\n> >  4 files changed, 40 insertions(+)\n> >\n> > diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> > index 97a32522..cd1d6e3d 100644\n> > --- a/src/ipa/rpi/common/ipa_base.cpp\n> > +++ b/src/ipa/rpi/common/ipa_base.cpp\n> > @@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n> >       { &controls::AwbEnable, ControlInfo(false, true) },\n> >       { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n> >       { &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n> > +     { &controls::ColourTemperature, ControlInfo(100, 100000) },\n> >       { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n> >  };\n> >\n> > @@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList &controls)\n> >                       break;\n> >               }\n> >\n> > +             case controls::COLOUR_TEMPERATURE: {\n> > +                     /* Silently ignore this control for a mono sensor. */\n> > +                     if (monoSensor_)\n> > +                             break;\n> > +\n> > +                     auto temperatureK = ctrl.second.get<int32_t>();\n> > +                     RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n> > +                             controller_.getAlgorithm(\"awb\"));\n> > +                     if (!awb) {\n> > +                             LOG(IPARPI, Warning)\n> > +                                     << \"Could not set COLOUR_TEMPERATURE - no AWB algorithm\";\n> > +                             break;\n> > +                     }\n> > +\n> > +                     awb->setColourTemperature(temperatureK);\n> > +                     /* This metadata will get reported back automatically. */\n> > +                     break;\n> > +             }\n> > +\n> >               case controls::BRIGHTNESS: {\n> >                       RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>(\n> >                               controller_.getAlgorithm(\"contrast\"));\n> > diff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h\n> > index 8462c4db..d966dfa8 100644\n> > --- a/src/ipa/rpi/controller/awb_algorithm.h\n> > +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> > @@ -18,6 +18,7 @@ public:\n> >       virtual unsigned int getConvergenceFrames() const = 0;\n> >       virtual void setMode(std::string const &modeName) = 0;\n> >       virtual void setManualGains(double manualR, double manualB) = 0;\n> > +     virtual void setColourTemperature(double temperatureK) = 0;\n> >       virtual void enableAuto() = 0;\n> >       virtual void disableAuto() = 0;\n> >  };\n> > diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> > index 5ae0c2fa..0918e20d 100644\n> > --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> > +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> > @@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double manualB)\n> >       }\n> >  }\n> >\n> > +void Awb::setColourTemperature(double temperatureK)\n> > +{\n> > +     if (!config_.bayes) {\n> > +             LOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set colour temperature\";\n> > +             return;\n> > +     }\n> > +\n> > +     temperatureK = config_.ctR.domain().clip(temperatureK);\n> > +     manualR_ = 1 / config_.ctR.eval(temperatureK);\n> > +     manualB_ = 1 / config_.ctB.eval(temperatureK);\n> > +\n> > +     syncResults_.temperatureK = temperatureK;\n> > +     syncResults_.gainR = manualR_;\n> > +     syncResults_.gainG = 1.0;\n> > +     syncResults_.gainB = manualB_;\n> > +     prevSyncResults_ = syncResults_;\n> > +}\n> > +\n> >  void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n> >                    Metadata *metadata)\n> >  {\n> > diff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\n> > index e7d49cd8..dbd79eda 100644\n> > --- a/src/ipa/rpi/controller/rpi/awb.h\n> > +++ b/src/ipa/rpi/controller/rpi/awb.h\n> > @@ -97,6 +97,7 @@ public:\n> >       unsigned int getConvergenceFrames() const override;\n> >       void setMode(std::string const &name) override;\n> >       void setManualGains(double manualR, double manualB) override;\n> > +     void setColourTemperature(double temperatureK) override;\n> >       void enableAuto() override;\n> >       void disableAuto() override;\n> >       void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 1D964BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Nov 2023 12:54:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B1035629BC;\n\tThu, 23 Nov 2023 13:54:57 +0100 (CET)","from mail-ua1-x929.google.com (mail-ua1-x929.google.com\n\t[IPv6:2607:f8b0:4864:20::929])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 277AE61DAC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Nov 2023 13:54:56 +0100 (CET)","by mail-ua1-x929.google.com with SMTP id\n\ta1e0cc1a2514c-7bae8dd095cso298838241.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Nov 2023 04:54:56 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700744097;\n\tbh=sTHGuSQuHJv7hIxsYfLjkY/KNYEwT8GAfpiiLppx9u4=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=nAnXqZm1kTJfH1rQPDGBerL3pfsKgJz5E7B1lTysyFhwASUlf4FL8yINNshFaEj5C\n\tLrgVghYyLvjJ7Pk2Vwr2YD7MSEjDpd5C1hQwWu9wwyBwMuQZFYc+qPKpil6KkS7g/t\n\tt4vcqnrPuJMRQ/UVno/dVunjTkFsUCaO4Hb0mbVp5RJrHVuRrwdmk8Gprbv/YuGzjq\n\tYwWXltMUaBvSQEokEYXm6CHU4qRWI3xTGDbHVTBNspQ3oBmqegwbZnehLd70FDiecc\n\tsAGRlPqH3S+IGdqcjzzKJS+O12JDCuayw9b3t3Uez6JtHno7qtPdW4TFPxIEtbTqVG\n\tRt9fG3w0wV0Qg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1700744095; x=1701348895;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=YlafZH7WzwppN2rEi6IvgfzwNFqUeUOP//So+GDVNKc=;\n\tb=J/N+79tS1aYZJEA6oTHQT0hPGBpP+ZSU7He7js0XfC6s4b+JvI6ksrkay6ptxw/HQQ\n\tzmMGP2EqJF7mj3RI38ei5YQOpvzV3c3eve8M+EARkpdNF7KvWzb77RbzcmxQSe0bgHF1\n\tYxp8sBLSYDqwzTRvEVCzpoM+AeHexLJQxRIESKIgzqOuT4kINjQ7BgoUW9uq9YkX/Y6u\n\tIhQFYzK4WqyoRldB+f7BS95DGP/AkvfLtGFJ9nsNpLZ3gtxlyKECO1aG20SlLJhQCV8M\n\t4ZQ0YUZ3y5/u3jwN26biewpCeeo+femRNraqIIF22S+PGIeGOoaTcIFqI1thC6iX/XGe\n\t9AaA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"J/N+79tS\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1700744095; x=1701348895;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=YlafZH7WzwppN2rEi6IvgfzwNFqUeUOP//So+GDVNKc=;\n\tb=U5iRAM1EMu/k/UTEpB6OKcpUYSzCFOXfmiS+9BabE95xuVyhB3JNn51qhMsKikvxJK\n\tCVn3BMdrmDCn5PX+/Vredb+NVi3gJFLRhGuki8uUHnmTCcIPMwdP7GIW8tCbUT/KD0SM\n\tYnP/d8OSi2vEDTHTZCMY0ciiQguEommUXTwfm59GQ3HiynDRrqS30ePkcyaZJ1zlbVrl\n\tbTXbx6eyYNJ+3bA/RrkGW4pntyk9eNH3/fJJfeRgyEwI+e7waUVRTmWF9v0Jor7A4RYK\n\tlemkl2ex4xPv0Q8gOg8FOwH47LOQefWTFyidv7yEhbboh8hyp8pU+OxsVEB88J4b+esH\n\tMBqQ==","X-Gm-Message-State":"AOJu0YwBEuY8LzWZNclEuE9tlGjOnCUCi6hXPYMrvvMWHmcPjb52oJbo\n\tkmO5QO1fKIIH/fTQbAdQCLXafY5SVLdXd0UpUJaFZw==","X-Google-Smtp-Source":"AGHT+IEvRarlFXQA/ApB/9I0s7nv1+6pX0aKMSpv9Zl/Xq+fBwlYpUsncAroU95lCi1akiGvREBPTCkuMBi0J8cgXPM=","X-Received":"by 2002:a1f:d946:0:b0:4a4:680:bfad with SMTP id\n\tq67-20020a1fd946000000b004a40680bfadmr6029004vkg.7.1700744094903;\n\tThu, 23 Nov 2023 04:54:54 -0800 (PST)","MIME-Version":"1.0","References":"<20231110161433.413382-1-david.plowman@raspberrypi.com>\n\t<20231123122805.GM15697@pendragon.ideasonboard.com>","In-Reply-To":"<20231123122805.GM15697@pendragon.ideasonboard.com>","Date":"Thu, 23 Nov 2023 12:54:43 +0000","Message-ID":"<CAHW6GYLPk4ALUhhRfK_+NWL0JdBC5YP1g4WfTyzMa-isBOxVwQ@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":28160,"web_url":"https://patchwork.libcamera.org/comment/28160/","msgid":"<20231123135626.GF16377@pendragon.ideasonboard.com>","date":"2023-11-23T13:56:26","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Nov 23, 2023 at 12:54:43PM +0000, David Plowman wrote:\n> On Thu, 23 Nov 2023 at 12:27, Laurent Pinchart wrote:\n> > On Fri, Nov 10, 2023 at 04:14:33PM +0000, David Plowman via libcamera-devel wrote:\n> > > ColourTemperature is now exported as a writable control so that\n> > > algorithms can set it directly.\n> >\n> > I'm puzzled here. You mention algorithms, but the patch exposes the\n> > control as being writable from applications. Is it a typo in the commit\n> > message ? If so, what's the use case ? control_ids.yaml documents the\n> > control as\n> \n> Yes, I'll change \"algorithms\" to \"applications\".\n> \n> >\n> >   - ColourTemperature:\n> >       type: int32_t\n> >       description: Report the current estimate of the colour temperature, in\n> >         kelvin, for this frame. The ColourTemperature control can only be\n> >         returned in metadata.\n> >\n> > so this would need to be updated as a prerequisite for this patch.\n> \n> I'll add a patch before this one to change that description.\n\nOK, let's discuss the use case there.\n\n> > > The AWB algorithm class now requires a\n> > > method to be provided to perform this operation. The method should\n> > > clamp the passed value to the calibrated range known to the algorithm.\n> > >\n> > > The default range is set very wide to cover all conceivable future AWB\n> > > calibrations. It will always be clamped before use.\n> > >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n> > >  src/ipa/rpi/controller/awb_algorithm.h |  1 +\n> > >  src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n> > >  src/ipa/rpi/controller/rpi/awb.h       |  1 +\n> > >  4 files changed, 40 insertions(+)\n> > >\n> > > diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> > > index 97a32522..cd1d6e3d 100644\n> > > --- a/src/ipa/rpi/common/ipa_base.cpp\n> > > +++ b/src/ipa/rpi/common/ipa_base.cpp\n> > > @@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n> > >       { &controls::AwbEnable, ControlInfo(false, true) },\n> > >       { &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n> > >       { &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n> > > +     { &controls::ColourTemperature, ControlInfo(100, 100000) },\n> > >       { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n> > >  };\n> > >\n> > > @@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList &controls)\n> > >                       break;\n> > >               }\n> > >\n> > > +             case controls::COLOUR_TEMPERATURE: {\n> > > +                     /* Silently ignore this control for a mono sensor. */\n> > > +                     if (monoSensor_)\n> > > +                             break;\n> > > +\n> > > +                     auto temperatureK = ctrl.second.get<int32_t>();\n> > > +                     RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n> > > +                             controller_.getAlgorithm(\"awb\"));\n> > > +                     if (!awb) {\n> > > +                             LOG(IPARPI, Warning)\n> > > +                                     << \"Could not set COLOUR_TEMPERATURE - no AWB algorithm\";\n> > > +                             break;\n> > > +                     }\n> > > +\n> > > +                     awb->setColourTemperature(temperatureK);\n> > > +                     /* This metadata will get reported back automatically. */\n> > > +                     break;\n> > > +             }\n> > > +\n> > >               case controls::BRIGHTNESS: {\n> > >                       RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>(\n> > >                               controller_.getAlgorithm(\"contrast\"));\n> > > diff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h\n> > > index 8462c4db..d966dfa8 100644\n> > > --- a/src/ipa/rpi/controller/awb_algorithm.h\n> > > +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> > > @@ -18,6 +18,7 @@ public:\n> > >       virtual unsigned int getConvergenceFrames() const = 0;\n> > >       virtual void setMode(std::string const &modeName) = 0;\n> > >       virtual void setManualGains(double manualR, double manualB) = 0;\n> > > +     virtual void setColourTemperature(double temperatureK) = 0;\n> > >       virtual void enableAuto() = 0;\n> > >       virtual void disableAuto() = 0;\n> > >  };\n> > > diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> > > index 5ae0c2fa..0918e20d 100644\n> > > --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> > > +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> > > @@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double manualB)\n> > >       }\n> > >  }\n> > >\n> > > +void Awb::setColourTemperature(double temperatureK)\n> > > +{\n> > > +     if (!config_.bayes) {\n> > > +             LOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set colour temperature\";\n> > > +             return;\n> > > +     }\n> > > +\n> > > +     temperatureK = config_.ctR.domain().clip(temperatureK);\n> > > +     manualR_ = 1 / config_.ctR.eval(temperatureK);\n> > > +     manualB_ = 1 / config_.ctB.eval(temperatureK);\n> > > +\n> > > +     syncResults_.temperatureK = temperatureK;\n> > > +     syncResults_.gainR = manualR_;\n> > > +     syncResults_.gainG = 1.0;\n> > > +     syncResults_.gainB = manualB_;\n> > > +     prevSyncResults_ = syncResults_;\n> > > +}\n> > > +\n> > >  void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n> > >                    Metadata *metadata)\n> > >  {\n> > > diff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\n> > > index e7d49cd8..dbd79eda 100644\n> > > --- a/src/ipa/rpi/controller/rpi/awb.h\n> > > +++ b/src/ipa/rpi/controller/rpi/awb.h\n> > > @@ -97,6 +97,7 @@ public:\n> > >       unsigned int getConvergenceFrames() const override;\n> > >       void setMode(std::string const &name) override;\n> > >       void setManualGains(double manualR, double manualB) override;\n> > > +     void setColourTemperature(double temperatureK) override;\n> > >       void enableAuto() override;\n> > >       void disableAuto() override;\n> > >       void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;","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 B31F6BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Nov 2023 13:56:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F0607629BC;\n\tThu, 23 Nov 2023 14:56:20 +0100 (CET)","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 E777361DAC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Nov 2023 14:56:19 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E0899DB7;\n\tThu, 23 Nov 2023 14:55:47 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700747781;\n\tbh=fD3fp3kviguL6C+96vy1VtKXYtuccwp2LcKIVan1sig=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=mzro8apCTFlZUpsMs6wdgoinQNOXB8aEtw19VGvZUDLOy05fa+Ne2gxTd1tYoEJEN\n\tYDO2swJGgixUn3VPYvRvItMEPBYtvJD4Kn8qsrW66VdkRELbIJBENl25lRgCvZ7Oju\n\tq4aYcoWQQq+EI0hrr9xqY5FnNZP40XNPuBZll41gub91eNMcmAYemhyH8G+p7YJysK\n\tz8Mcs7jN5TFPgIz7l2armlXECX+l7TgjrgtS/S/Rm0yD/iBTXLOTFrNxK/uOCUDFGI\n\tZXnRjWKC2c8/BY1uRtzQXoQqbmirZJAOAFLdwTPK5fxmpVsYLrMFij9tdP00HdhP/r\n\tV/QUbKmMaUz+g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1700747748;\n\tbh=fD3fp3kviguL6C+96vy1VtKXYtuccwp2LcKIVan1sig=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=igL+RZ/LeNM/YfE0W6s9agUsnG/8w2zauOyrQLA0qf0jeTMddsUKNaJRoUtEDLOH6\n\tsC9MBhupTM5i+5liPq0cp7EQqfS4kpmEUehWwlCkPsgBOLmnFx1gqsVVDPBYmGkqNl\n\t75cKuGybY/GzBnUBQDyHdve2GPwiGbyWXw2wHv6Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"igL+RZ/L\"; dkim-atps=neutral","Date":"Thu, 23 Nov 2023 15:56:26 +0200","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<20231123135626.GF16377@pendragon.ideasonboard.com>","References":"<20231110161433.413382-1-david.plowman@raspberrypi.com>\n\t<20231123122805.GM15697@pendragon.ideasonboard.com>\n\t<CAHW6GYLPk4ALUhhRfK_+NWL0JdBC5YP1g4WfTyzMa-isBOxVwQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAHW6GYLPk4ALUhhRfK_+NWL0JdBC5YP1g4WfTyzMa-isBOxVwQ@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to\n\tset the colour temperature directly","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]