[{"id":34102,"web_url":"https://patchwork.libcamera.org/comment/34102/","msgid":"<174617344373.1586992.18436670469122420786@ping.linuxembedded.co.uk>","date":"2025-05-02T08:10:43","subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-04-03 16:49:16)\n> In RkISP1Awb::process(), the color temperature in the active state is\n> updated every time new statistics are available.  The CCM/LSC algorithms\n> use that value in prepare() to update the CCM/LSC. This is not correct\n> if the color temperature was specified manually and leads to visible\n> flicker even when AwbEnable is set to false.\n> \n> To fix that, track the auto and manual color temperature separately in\n> active state. In Awb::prepare() the current frame context is updated\n> with the corresponding value from active state. Change the algorithms to\n> fetch the color temperature from the frame context instead of the active\n> state in prepare().\n> \n> Fixes: 02308809548d (\"ipa: rkisp1: awb: Implement ColourTemperature control\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> ---\n> \n> Changes in v2:\n> - None\n> \n> Changes in v3:\n> - Move incorrect colour temperature metadata to separate fixup patch\n\nThat answers my question on the previous patch ;-)\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> - Updated documentation\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 16 +++++++++-------\n>  src/ipa/rkisp1/algorithms/ccm.cpp |  2 +-\n>  src/ipa/rkisp1/algorithms/lsc.cpp |  6 +++---\n>  src/ipa/rkisp1/ipa_context.cpp    |  6 +++---\n>  src/ipa/rkisp1/ipa_context.h      |  2 +-\n>  5 files changed, 17 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 79c4c658406d..0795b8e5b1e1 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -128,7 +128,8 @@ int Awb::configure(IPAContext &context,\n>         context.activeState.awb.automatic.gains =\n>                 awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n>         context.activeState.awb.autoEnabled = true;\n> -       context.activeState.awb.temperatureK = kDefaultColourTemperature;\n> +       context.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> +       context.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n>  \n>         /*\n>          * Define the measurement window for AWB as a centered rectangle\n> @@ -185,7 +186,7 @@ void Awb::queueRequest(IPAContext &context,\n>                 const auto &gains = awbAlgo_->gainsFromColourTemperature(*colourTemperature);\n>                 awb.manual.gains.r() = gains.r();\n>                 awb.manual.gains.b() = gains.b();\n> -               awb.temperatureK = *colourTemperature;\n> +               awb.manual.temperatureK = *colourTemperature;\n>                 update = true;\n>         }\n>  \n> @@ -194,7 +195,7 @@ void Awb::queueRequest(IPAContext &context,\n>                         << \"Set colour gains to \" << awb.manual.gains;\n>  \n>         frameContext.awb.gains = awb.manual.gains;\n> -       frameContext.awb.temperatureK = awb.temperatureK;\n> +       frameContext.awb.temperatureK = awb.manual.temperatureK;\n>  }\n>  \n>  /**\n> @@ -208,8 +209,9 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>          * most up-to-date automatic values we can read.\n>          */\n>         if (frameContext.awb.autoEnabled) {\n> -               frameContext.awb.gains = context.activeState.awb.automatic.gains;\n> -               frameContext.awb.temperatureK = context.activeState.awb.temperatureK;\n> +               auto &awb = context.activeState.awb;\n> +               frameContext.awb.gains = awb.automatic.gains;\n> +               frameContext.awb.temperatureK = awb.automatic.temperatureK;\n>         }\n>  \n>         auto gainConfig = params->block<BlockType::AwbGain>();\n> @@ -309,7 +311,7 @@ void Awb::process(IPAContext &context,\n>         RkISP1AwbStats awbStats{ rgbMeans };\n>         AwbResult awbResult = awbAlgo_->calculateAwb(awbStats, frameContext.lux.lux);\n>  \n> -       activeState.awb.temperatureK = awbResult.colourTemperature;\n> +       activeState.awb.automatic.temperatureK = awbResult.colourTemperature;\n>  \n>         /*\n>          * Clamp the gain values to the hardware, which expresses gains as Q2.8\n> @@ -330,7 +332,7 @@ void Awb::process(IPAContext &context,\n>                 << std::showpoint\n>                 << \"Means \" << rgbMeans << \", gains \"\n>                 << activeState.awb.automatic.gains << \", temp \"\n> -               << activeState.awb.temperatureK << \"K\";\n> +               << activeState.awb.automatic.temperatureK << \"K\";\n>  }\n>  \n>  RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rkisp1_cif_isp_awb_stat *awb) const\n> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp\n> index eb8ca39e56a8..2e5e91006b55 100644\n> --- a/src/ipa/rkisp1/algorithms/ccm.cpp\n> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp\n> @@ -88,7 +88,7 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,\n>  void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>                   IPAFrameContext &frameContext, RkISP1Params *params)\n>  {\n> -       uint32_t ct = context.activeState.awb.temperatureK;\n> +       uint32_t ct = frameContext.awb.temperatureK;\n>  \n>         /*\n>          * \\todo The colour temperature will likely be noisy, add filtering to\n> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\n> index e47aa2f0727e..e7301bfec863 100644\n> --- a/src/ipa/rkisp1/algorithms/lsc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n> @@ -404,12 +404,12 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,\n>  /**\n>   * \\copydoc libcamera::ipa::Algorithm::prepare\n>   */\n> -void LensShadingCorrection::prepare(IPAContext &context,\n> +void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n>                                     [[maybe_unused]] const uint32_t frame,\n> -                                   [[maybe_unused]] IPAFrameContext &frameContext,\n> +                                   IPAFrameContext &frameContext,\n>                                     RkISP1Params *params)\n>  {\n> -       uint32_t ct = context.activeState.awb.temperatureK;\n> +       uint32_t ct = frameContext.awb.temperatureK;\n>         if (std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <\n>             kColourTemperatureChangeThreshhold)\n>                 return;\n> diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\n> index 39b97d143e95..7bc42e6de415 100644\n> --- a/src/ipa/rkisp1/ipa_context.cpp\n> +++ b/src/ipa/rkisp1/ipa_context.cpp\n> @@ -197,15 +197,15 @@ namespace libcamera::ipa::rkisp1 {\n>   * \\struct IPAActiveState::awb::AwbState.gains\n>   * \\brief White balance gains\n>   *\n> + * \\var IPAActiveState::awb::AwbState.temperatureK\n> + * \\brief Estimated color temperature\n> + *\n>   * \\var IPAActiveState::awb.manual\n>   * \\brief Manual regulation state (set through requests)\n>   *\n>   * \\var IPAActiveState::awb.automatic\n>   * \\brief Automatic regulation state (computed by the algorithm)\n>   *\n> - * \\var IPAActiveState::awb.temperatureK\n> - * \\brief Estimated color temperature\n> - *\n>   * \\var IPAActiveState::awb.autoEnabled\n>   * \\brief Whether the Auto White Balance algorithm is enabled\n>   */\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index 6bc922a82971..769e9f114e23 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -91,12 +91,12 @@ struct IPAActiveState {\n>         struct {\n>                 struct AwbState {\n>                         RGB<double> gains;\n> +                       unsigned int temperatureK;\n>                 };\n>  \n>                 AwbState manual;\n>                 AwbState automatic;\n>  \n> -               unsigned int temperatureK;\n>                 bool autoEnabled;\n>         } awb;\n>  \n> -- \n> 2.43.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 1C565C327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 May 2025 08:10:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F0BD68ADB;\n\tFri,  2 May 2025 10:10:48 +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 7EED168ACB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 May 2025 10:10:47 +0200 (CEST)","from pendragon.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 C87A0353;\n\tFri,  2 May 2025 10:10:39 +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=\"AIaadqOm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1746173439;\n\tbh=iEKgOJzQAeRVB6TyOVrjmJ/Me4Zp/Gw+Bf1n738O17k=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=AIaadqOmCCpZ8eRp5fIduj0fAMuD+U+YnXwOVNHp7vKRjvQI6dXj90kq5EY8Jwkoo\n\tBy5CnkxVPM0sHUTFagNBmpdQuAU0OGHeFdNoP6h1MTXPG4IbA7LZggeWqsMuFC1/os\n\tEEdOncdjy/vX9PhkwruPZZbWjjVHGXn0fn1LjHPY=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250403154925.382973-12-stefan.klug@ideasonboard.com>","References":"<20250403154925.382973-1-stefan.klug@ideasonboard.com>\n\t<20250403154925.382973-12-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 02 May 2025 09:10:43 +0100","Message-ID":"<174617344373.1586992.18436670469122420786@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":34148,"web_url":"https://patchwork.libcamera.org/comment/34148/","msgid":"<aBuRyVHufoJPZT5t@pyrite.rasen.tech>","date":"2025-05-07T17:00:57","subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Thu, Apr 03, 2025 at 05:49:16PM +0200, Stefan Klug wrote:\n> In RkISP1Awb::process(), the color temperature in the active state is\n> updated every time new statistics are available.  The CCM/LSC algorithms\n> use that value in prepare() to update the CCM/LSC. This is not correct\n> if the color temperature was specified manually and leads to visible\n> flicker even when AwbEnable is set to false.\n> \n> To fix that, track the auto and manual color temperature separately in\n> active state. In Awb::prepare() the current frame context is updated\n> with the corresponding value from active state. Change the algorithms to\n> fetch the color temperature from the frame context instead of the active\n> state in prepare().\n> \n> Fixes: 02308809548d (\"ipa: rkisp1: awb: Implement ColourTemperature control\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \n> ---\n> \n> Changes in v2:\n> - None\n> \n> Changes in v3:\n> - Move incorrect colour temperature metadata to separate fixup patch\n> - Updated documentation\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 16 +++++++++-------\n>  src/ipa/rkisp1/algorithms/ccm.cpp |  2 +-\n>  src/ipa/rkisp1/algorithms/lsc.cpp |  6 +++---\n>  src/ipa/rkisp1/ipa_context.cpp    |  6 +++---\n>  src/ipa/rkisp1/ipa_context.h      |  2 +-\n>  5 files changed, 17 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 79c4c658406d..0795b8e5b1e1 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -128,7 +128,8 @@ int Awb::configure(IPAContext &context,\n>  \tcontext.activeState.awb.automatic.gains =\n>  \t\tawbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n>  \tcontext.activeState.awb.autoEnabled = true;\n> -\tcontext.activeState.awb.temperatureK = kDefaultColourTemperature;\n> +\tcontext.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> +\tcontext.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n>  \n>  \t/*\n>  \t * Define the measurement window for AWB as a centered rectangle\n> @@ -185,7 +186,7 @@ void Awb::queueRequest(IPAContext &context,\n>  \t\tconst auto &gains = awbAlgo_->gainsFromColourTemperature(*colourTemperature);\n>  \t\tawb.manual.gains.r() = gains.r();\n>  \t\tawb.manual.gains.b() = gains.b();\n> -\t\tawb.temperatureK = *colourTemperature;\n> +\t\tawb.manual.temperatureK = *colourTemperature;\n>  \t\tupdate = true;\n>  \t}\n>  \n> @@ -194,7 +195,7 @@ void Awb::queueRequest(IPAContext &context,\n>  \t\t\t<< \"Set colour gains to \" << awb.manual.gains;\n>  \n>  \tframeContext.awb.gains = awb.manual.gains;\n> -\tframeContext.awb.temperatureK = awb.temperatureK;\n> +\tframeContext.awb.temperatureK = awb.manual.temperatureK;\n>  }\n>  \n>  /**\n> @@ -208,8 +209,9 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>  \t * most up-to-date automatic values we can read.\n>  \t */\n>  \tif (frameContext.awb.autoEnabled) {\n> -\t\tframeContext.awb.gains = context.activeState.awb.automatic.gains;\n> -\t\tframeContext.awb.temperatureK = context.activeState.awb.temperatureK;\n> +\t\tauto &awb = context.activeState.awb;\n> +\t\tframeContext.awb.gains = awb.automatic.gains;\n> +\t\tframeContext.awb.temperatureK = awb.automatic.temperatureK;\n>  \t}\n>  \n>  \tauto gainConfig = params->block<BlockType::AwbGain>();\n> @@ -309,7 +311,7 @@ void Awb::process(IPAContext &context,\n>  \tRkISP1AwbStats awbStats{ rgbMeans };\n>  \tAwbResult awbResult = awbAlgo_->calculateAwb(awbStats, frameContext.lux.lux);\n>  \n> -\tactiveState.awb.temperatureK = awbResult.colourTemperature;\n> +\tactiveState.awb.automatic.temperatureK = awbResult.colourTemperature;\n>  \n>  \t/*\n>  \t * Clamp the gain values to the hardware, which expresses gains as Q2.8\n> @@ -330,7 +332,7 @@ void Awb::process(IPAContext &context,\n>  \t\t<< std::showpoint\n>  \t\t<< \"Means \" << rgbMeans << \", gains \"\n>  \t\t<< activeState.awb.automatic.gains << \", temp \"\n> -\t\t<< activeState.awb.temperatureK << \"K\";\n> +\t\t<< activeState.awb.automatic.temperatureK << \"K\";\n>  }\n>  \n>  RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rkisp1_cif_isp_awb_stat *awb) const\n> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp\n> index eb8ca39e56a8..2e5e91006b55 100644\n> --- a/src/ipa/rkisp1/algorithms/ccm.cpp\n> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp\n> @@ -88,7 +88,7 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,\n>  void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>  \t\t  IPAFrameContext &frameContext, RkISP1Params *params)\n>  {\n> -\tuint32_t ct = context.activeState.awb.temperatureK;\n> +\tuint32_t ct = frameContext.awb.temperatureK;\n>  \n>  \t/*\n>  \t * \\todo The colour temperature will likely be noisy, add filtering to\n> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\n> index e47aa2f0727e..e7301bfec863 100644\n> --- a/src/ipa/rkisp1/algorithms/lsc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n> @@ -404,12 +404,12 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,\n>  /**\n>   * \\copydoc libcamera::ipa::Algorithm::prepare\n>   */\n> -void LensShadingCorrection::prepare(IPAContext &context,\n> +void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n>  \t\t\t\t    [[maybe_unused]] const uint32_t frame,\n> -\t\t\t\t    [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t\t\t    IPAFrameContext &frameContext,\n>  \t\t\t\t    RkISP1Params *params)\n>  {\n> -\tuint32_t ct = context.activeState.awb.temperatureK;\n> +\tuint32_t ct = frameContext.awb.temperatureK;\n>  \tif (std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <\n>  \t    kColourTemperatureChangeThreshhold)\n>  \t\treturn;\n> diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\n> index 39b97d143e95..7bc42e6de415 100644\n> --- a/src/ipa/rkisp1/ipa_context.cpp\n> +++ b/src/ipa/rkisp1/ipa_context.cpp\n> @@ -197,15 +197,15 @@ namespace libcamera::ipa::rkisp1 {\n>   * \\struct IPAActiveState::awb::AwbState.gains\n>   * \\brief White balance gains\n>   *\n> + * \\var IPAActiveState::awb::AwbState.temperatureK\n> + * \\brief Estimated color temperature\n> + *\n>   * \\var IPAActiveState::awb.manual\n>   * \\brief Manual regulation state (set through requests)\n>   *\n>   * \\var IPAActiveState::awb.automatic\n>   * \\brief Automatic regulation state (computed by the algorithm)\n>   *\n> - * \\var IPAActiveState::awb.temperatureK\n> - * \\brief Estimated color temperature\n> - *\n>   * \\var IPAActiveState::awb.autoEnabled\n>   * \\brief Whether the Auto White Balance algorithm is enabled\n>   */\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index 6bc922a82971..769e9f114e23 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -91,12 +91,12 @@ struct IPAActiveState {\n>  \tstruct {\n>  \t\tstruct AwbState {\n>  \t\t\tRGB<double> gains;\n> +\t\t\tunsigned int temperatureK;\n>  \t\t};\n>  \n>  \t\tAwbState manual;\n>  \t\tAwbState automatic;\n>  \n> -\t\tunsigned int temperatureK;\n>  \t\tbool autoEnabled;\n>  \t} awb;\n>  \n> -- \n> 2.43.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 AE76CC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 May 2025 17:01:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9B9E568B31;\n\tWed,  7 May 2025 19:01:02 +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 E08F468AD8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 May 2025 19:01:00 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2001:861:3a80:3300:4f2f:8c2c:b3ef:17d4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C3216D5;\n\tWed,  7 May 2025 19:00:49 +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=\"C+mQDMCi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1746637249;\n\tbh=8CSR00uII2XuESvGs3v+hU45jKMpddC08xH9YvvQZxY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=C+mQDMCi5Hfp4+5gDo2Spvro1qL8Blkom96z/CQyWuQP6RDSgriHpvu8KCbRFEicv\n\teb8+zRmb24cM8DyvGXlYZbSdJDUWdg8dAu46sr7e++h4PplYEKDugusUsdG81CujMq\n\t0uVRgeMyO6ZZQ1WTn4TaGxWQEBmtYNTYC1HEkQPQ=","Date":"Wed, 7 May 2025 19:00:57 +0200","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","Message-ID":"<aBuRyVHufoJPZT5t@pyrite.rasen.tech>","References":"<20250403154925.382973-1-stefan.klug@ideasonboard.com>\n\t<20250403154925.382973-12-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20250403154925.382973-12-stefan.klug@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":34157,"web_url":"https://patchwork.libcamera.org/comment/34157/","msgid":"<20250507203944.GA28896@pendragon.ideasonboard.com>","date":"2025-05-07T20:39:44","subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Thu, Apr 03, 2025 at 05:49:16PM +0200, Stefan Klug wrote:\n> In RkISP1Awb::process(), the color temperature in the active state is\n> updated every time new statistics are available.  The CCM/LSC algorithms\n> use that value in prepare() to update the CCM/LSC. This is not correct\n> if the color temperature was specified manually and leads to visible\n> flicker even when AwbEnable is set to false.\n> \n> To fix that, track the auto and manual color temperature separately in\n> active state. In Awb::prepare() the current frame context is updated\n> with the corresponding value from active state. Change the algorithms to\n> fetch the color temperature from the frame context instead of the active\n> state in prepare().\n> \n> Fixes: 02308809548d (\"ipa: rkisp1: awb: Implement ColourTemperature control\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> ---\n> \n> Changes in v2:\n> - None\n> \n> Changes in v3:\n> - Move incorrect colour temperature metadata to separate fixup patch\n> - Updated documentation\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 16 +++++++++-------\n>  src/ipa/rkisp1/algorithms/ccm.cpp |  2 +-\n>  src/ipa/rkisp1/algorithms/lsc.cpp |  6 +++---\n>  src/ipa/rkisp1/ipa_context.cpp    |  6 +++---\n>  src/ipa/rkisp1/ipa_context.h      |  2 +-\n>  5 files changed, 17 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 79c4c658406d..0795b8e5b1e1 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -128,7 +128,8 @@ int Awb::configure(IPAContext &context,\n>  \tcontext.activeState.awb.automatic.gains =\n>  \t\tawbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n>  \tcontext.activeState.awb.autoEnabled = true;\n> -\tcontext.activeState.awb.temperatureK = kDefaultColourTemperature;\n> +\tcontext.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> +\tcontext.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n>  \n>  \t/*\n>  \t * Define the measurement window for AWB as a centered rectangle\n> @@ -185,7 +186,7 @@ void Awb::queueRequest(IPAContext &context,\n>  \t\tconst auto &gains = awbAlgo_->gainsFromColourTemperature(*colourTemperature);\n>  \t\tawb.manual.gains.r() = gains.r();\n>  \t\tawb.manual.gains.b() = gains.b();\n> -\t\tawb.temperatureK = *colourTemperature;\n> +\t\tawb.manual.temperatureK = *colourTemperature;\n>  \t\tupdate = true;\n>  \t}\n>  \n> @@ -194,7 +195,7 @@ void Awb::queueRequest(IPAContext &context,\n>  \t\t\t<< \"Set colour gains to \" << awb.manual.gains;\n>  \n>  \tframeContext.awb.gains = awb.manual.gains;\n> -\tframeContext.awb.temperatureK = awb.temperatureK;\n> +\tframeContext.awb.temperatureK = awb.manual.temperatureK;\n>  }\n>  \n>  /**\n> @@ -208,8 +209,9 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>  \t * most up-to-date automatic values we can read.\n>  \t */\n>  \tif (frameContext.awb.autoEnabled) {\n> -\t\tframeContext.awb.gains = context.activeState.awb.automatic.gains;\n> -\t\tframeContext.awb.temperatureK = context.activeState.awb.temperatureK;\n> +\t\tauto &awb = context.activeState.awb;\n\nconst\n\n> +\t\tframeContext.awb.gains = awb.automatic.gains;\n> +\t\tframeContext.awb.temperatureK = awb.automatic.temperatureK;\n>  \t}\n>  \n>  \tauto gainConfig = params->block<BlockType::AwbGain>();\n> @@ -309,7 +311,7 @@ void Awb::process(IPAContext &context,\n>  \tRkISP1AwbStats awbStats{ rgbMeans };\n>  \tAwbResult awbResult = awbAlgo_->calculateAwb(awbStats, frameContext.lux.lux);\n>  \n> -\tactiveState.awb.temperatureK = awbResult.colourTemperature;\n> +\tactiveState.awb.automatic.temperatureK = awbResult.colourTemperature;\n>  \n>  \t/*\n>  \t * Clamp the gain values to the hardware, which expresses gains as Q2.8\n> @@ -330,7 +332,7 @@ void Awb::process(IPAContext &context,\n>  \t\t<< std::showpoint\n>  \t\t<< \"Means \" << rgbMeans << \", gains \"\n>  \t\t<< activeState.awb.automatic.gains << \", temp \"\n> -\t\t<< activeState.awb.temperatureK << \"K\";\n> +\t\t<< activeState.awb.automatic.temperatureK << \"K\";\n>  }\n>  \n>  RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rkisp1_cif_isp_awb_stat *awb) const\n> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp\n> index eb8ca39e56a8..2e5e91006b55 100644\n> --- a/src/ipa/rkisp1/algorithms/ccm.cpp\n> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp\n> @@ -88,7 +88,7 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,\n>  void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>  \t\t  IPAFrameContext &frameContext, RkISP1Params *params)\n>  {\n> -\tuint32_t ct = context.activeState.awb.temperatureK;\n> +\tuint32_t ct = frameContext.awb.temperatureK;\n>  \n>  \t/*\n>  \t * \\todo The colour temperature will likely be noisy, add filtering to\n> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\n> index e47aa2f0727e..e7301bfec863 100644\n> --- a/src/ipa/rkisp1/algorithms/lsc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n> @@ -404,12 +404,12 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,\n>  /**\n>   * \\copydoc libcamera::ipa::Algorithm::prepare\n>   */\n> -void LensShadingCorrection::prepare(IPAContext &context,\n> +void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n>  \t\t\t\t    [[maybe_unused]] const uint32_t frame,\n> -\t\t\t\t    [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t\t\t    IPAFrameContext &frameContext,\n>  \t\t\t\t    RkISP1Params *params)\n>  {\n> -\tuint32_t ct = context.activeState.awb.temperatureK;\n> +\tuint32_t ct = frameContext.awb.temperatureK;\n>  \tif (std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <\n>  \t    kColourTemperatureChangeThreshhold)\n>  \t\treturn;\n> diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\n> index 39b97d143e95..7bc42e6de415 100644\n> --- a/src/ipa/rkisp1/ipa_context.cpp\n> +++ b/src/ipa/rkisp1/ipa_context.cpp\n> @@ -197,15 +197,15 @@ namespace libcamera::ipa::rkisp1 {\n>   * \\struct IPAActiveState::awb::AwbState.gains\n>   * \\brief White balance gains\n>   *\n> + * \\var IPAActiveState::awb::AwbState.temperatureK\n> + * \\brief Estimated color temperature\n> + *\n\nIs that right ? automatic.temperatureK is indeed estimated by the AWB\nalgorithm, but manual.temperatureK is the value set through requests.\nBeing more precise would be nice, as the code is already confusing as-is\n:-)\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>   * \\var IPAActiveState::awb.manual\n>   * \\brief Manual regulation state (set through requests)\n>   *\n>   * \\var IPAActiveState::awb.automatic\n>   * \\brief Automatic regulation state (computed by the algorithm)\n>   *\n> - * \\var IPAActiveState::awb.temperatureK\n> - * \\brief Estimated color temperature\n> - *\n>   * \\var IPAActiveState::awb.autoEnabled\n>   * \\brief Whether the Auto White Balance algorithm is enabled\n>   */\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index 6bc922a82971..769e9f114e23 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -91,12 +91,12 @@ struct IPAActiveState {\n>  \tstruct {\n>  \t\tstruct AwbState {\n>  \t\t\tRGB<double> gains;\n> +\t\t\tunsigned int temperatureK;\n>  \t\t};\n>  \n>  \t\tAwbState manual;\n>  \t\tAwbState automatic;\n>  \n> -\t\tunsigned int temperatureK;\n>  \t\tbool autoEnabled;\n>  \t} awb;\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 0356CC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 May 2025 20:39:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 19B2968B45;\n\tWed,  7 May 2025 22:39:54 +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 A303168B3F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 May 2025 22:39:52 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(static-176-133-119-130.ftth.abo.bbox.fr [176.133.119.130])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DFD336D5;\n\tWed,  7 May 2025 22:39:40 +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=\"SmXaiC4Q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1746650381;\n\tbh=IJtXPX5/XSjbSXrt5LBTI9iqjhPyjEJ4+rBMIqNdx18=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SmXaiC4QUQizouF1n7Mbfse/Ox8Gy8qtHr+ncuCx9XnpD40UQgMbC+6fD9/XyPvUI\n\tiRZpj5+fnot3hG5Pfz6ZsjEDwwktnGywJRNKAzaekNosB0f02KCrqnxV202Z8VhLcW\n\t2zcW+QQjhuPjZowUKJGStilbNqlTlriTWXJGCNac=","Date":"Wed, 7 May 2025 22:39:44 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","Message-ID":"<20250507203944.GA28896@pendragon.ideasonboard.com>","References":"<20250403154925.382973-1-stefan.klug@ideasonboard.com>\n\t<20250403154925.382973-12-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250403154925.382973-12-stefan.klug@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":34286,"web_url":"https://patchwork.libcamera.org/comment/34286/","msgid":"<174773277815.11206.12629119127341853782@localhost>","date":"2025-05-20T09:19:38","subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the review.\n\nQuoting Laurent Pinchart (2025-05-07 22:39:44)\n> Hi Stefan,\n> \n> Thank you for the patch.\n> \n> On Thu, Apr 03, 2025 at 05:49:16PM +0200, Stefan Klug wrote:\n> > In RkISP1Awb::process(), the color temperature in the active state is\n> > updated every time new statistics are available.  The CCM/LSC algorithms\n> > use that value in prepare() to update the CCM/LSC. This is not correct\n> > if the color temperature was specified manually and leads to visible\n> > flicker even when AwbEnable is set to false.\n> > \n> > To fix that, track the auto and manual color temperature separately in\n> > active state. In Awb::prepare() the current frame context is updated\n> > with the corresponding value from active state. Change the algorithms to\n> > fetch the color temperature from the frame context instead of the active\n> > state in prepare().\n> > \n> > Fixes: 02308809548d (\"ipa: rkisp1: awb: Implement ColourTemperature control\")\n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > \n> > ---\n> > \n> > Changes in v2:\n> > - None\n> > \n> > Changes in v3:\n> > - Move incorrect colour temperature metadata to separate fixup patch\n> > - Updated documentation\n> > ---\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 16 +++++++++-------\n> >  src/ipa/rkisp1/algorithms/ccm.cpp |  2 +-\n> >  src/ipa/rkisp1/algorithms/lsc.cpp |  6 +++---\n> >  src/ipa/rkisp1/ipa_context.cpp    |  6 +++---\n> >  src/ipa/rkisp1/ipa_context.h      |  2 +-\n> >  5 files changed, 17 insertions(+), 15 deletions(-)\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> > index 79c4c658406d..0795b8e5b1e1 100644\n> > --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> > @@ -128,7 +128,8 @@ int Awb::configure(IPAContext &context,\n> >       context.activeState.awb.automatic.gains =\n> >               awbAlgo_->gainsFromColourTemperature(kDefaultColourTemperature);\n> >       context.activeState.awb.autoEnabled = true;\n> > -     context.activeState.awb.temperatureK = kDefaultColourTemperature;\n> > +     context.activeState.awb.manual.temperatureK = kDefaultColourTemperature;\n> > +     context.activeState.awb.automatic.temperatureK = kDefaultColourTemperature;\n> >  \n> >       /*\n> >        * Define the measurement window for AWB as a centered rectangle\n> > @@ -185,7 +186,7 @@ void Awb::queueRequest(IPAContext &context,\n> >               const auto &gains = awbAlgo_->gainsFromColourTemperature(*colourTemperature);\n> >               awb.manual.gains.r() = gains.r();\n> >               awb.manual.gains.b() = gains.b();\n> > -             awb.temperatureK = *colourTemperature;\n> > +             awb.manual.temperatureK = *colourTemperature;\n> >               update = true;\n> >       }\n> >  \n> > @@ -194,7 +195,7 @@ void Awb::queueRequest(IPAContext &context,\n> >                       << \"Set colour gains to \" << awb.manual.gains;\n> >  \n> >       frameContext.awb.gains = awb.manual.gains;\n> > -     frameContext.awb.temperatureK = awb.temperatureK;\n> > +     frameContext.awb.temperatureK = awb.manual.temperatureK;\n> >  }\n> >  \n> >  /**\n> > @@ -208,8 +209,9 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n> >        * most up-to-date automatic values we can read.\n> >        */\n> >       if (frameContext.awb.autoEnabled) {\n> > -             frameContext.awb.gains = context.activeState.awb.automatic.gains;\n> > -             frameContext.awb.temperatureK = context.activeState.awb.temperatureK;\n> > +             auto &awb = context.activeState.awb;\n> \n> const\n> \n> > +             frameContext.awb.gains = awb.automatic.gains;\n> > +             frameContext.awb.temperatureK = awb.automatic.temperatureK;\n> >       }\n> >  \n> >       auto gainConfig = params->block<BlockType::AwbGain>();\n> > @@ -309,7 +311,7 @@ void Awb::process(IPAContext &context,\n> >       RkISP1AwbStats awbStats{ rgbMeans };\n> >       AwbResult awbResult = awbAlgo_->calculateAwb(awbStats, frameContext.lux.lux);\n> >  \n> > -     activeState.awb.temperatureK = awbResult.colourTemperature;\n> > +     activeState.awb.automatic.temperatureK = awbResult.colourTemperature;\n> >  \n> >       /*\n> >        * Clamp the gain values to the hardware, which expresses gains as Q2.8\n> > @@ -330,7 +332,7 @@ void Awb::process(IPAContext &context,\n> >               << std::showpoint\n> >               << \"Means \" << rgbMeans << \", gains \"\n> >               << activeState.awb.automatic.gains << \", temp \"\n> > -             << activeState.awb.temperatureK << \"K\";\n> > +             << activeState.awb.automatic.temperatureK << \"K\";\n> >  }\n> >  \n> >  RGB<double> Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rkisp1_cif_isp_awb_stat *awb) const\n> > diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp\n> > index eb8ca39e56a8..2e5e91006b55 100644\n> > --- a/src/ipa/rkisp1/algorithms/ccm.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/ccm.cpp\n> > @@ -88,7 +88,7 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,\n> >  void Ccm::prepare(IPAContext &context, const uint32_t frame,\n> >                 IPAFrameContext &frameContext, RkISP1Params *params)\n> >  {\n> > -     uint32_t ct = context.activeState.awb.temperatureK;\n> > +     uint32_t ct = frameContext.awb.temperatureK;\n> >  \n> >       /*\n> >        * \\todo The colour temperature will likely be noisy, add filtering to\n> > diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\n> > index e47aa2f0727e..e7301bfec863 100644\n> > --- a/src/ipa/rkisp1/algorithms/lsc.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n> > @@ -404,12 +404,12 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,\n> >  /**\n> >   * \\copydoc libcamera::ipa::Algorithm::prepare\n> >   */\n> > -void LensShadingCorrection::prepare(IPAContext &context,\n> > +void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,\n> >                                   [[maybe_unused]] const uint32_t frame,\n> > -                                 [[maybe_unused]] IPAFrameContext &frameContext,\n> > +                                 IPAFrameContext &frameContext,\n> >                                   RkISP1Params *params)\n> >  {\n> > -     uint32_t ct = context.activeState.awb.temperatureK;\n> > +     uint32_t ct = frameContext.awb.temperatureK;\n> >       if (std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <\n> >           kColourTemperatureChangeThreshhold)\n> >               return;\n> > diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\n> > index 39b97d143e95..7bc42e6de415 100644\n> > --- a/src/ipa/rkisp1/ipa_context.cpp\n> > +++ b/src/ipa/rkisp1/ipa_context.cpp\n> > @@ -197,15 +197,15 @@ namespace libcamera::ipa::rkisp1 {\n> >   * \\struct IPAActiveState::awb::AwbState.gains\n> >   * \\brief White balance gains\n> >   *\n> > + * \\var IPAActiveState::awb::AwbState.temperatureK\n> > + * \\brief Estimated color temperature\n> > + *\n> \n> Is that right ? automatic.temperatureK is indeed estimated by the AWB\n> algorithm, but manual.temperatureK is the value set through requests.\n> Being more precise would be nice, as the code is already confusing as-is\n> :-)\n\nYou are right. I improved it a bit before the merge. There are other\nplaces in the docs that need a bit of love. Maybe I'll find some time to\ninclude the docs in doxygen and use that to carry a bit of rework.\n\nBest regards,\nStefan\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> >   * \\var IPAActiveState::awb.manual\n> >   * \\brief Manual regulation state (set through requests)\n> >   *\n> >   * \\var IPAActiveState::awb.automatic\n> >   * \\brief Automatic regulation state (computed by the algorithm)\n> >   *\n> > - * \\var IPAActiveState::awb.temperatureK\n> > - * \\brief Estimated color temperature\n> > - *\n> >   * \\var IPAActiveState::awb.autoEnabled\n> >   * \\brief Whether the Auto White Balance algorithm is enabled\n> >   */\n> > diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> > index 6bc922a82971..769e9f114e23 100644\n> > --- a/src/ipa/rkisp1/ipa_context.h\n> > +++ b/src/ipa/rkisp1/ipa_context.h\n> > @@ -91,12 +91,12 @@ struct IPAActiveState {\n> >       struct {\n> >               struct AwbState {\n> >                       RGB<double> gains;\n> > +                     unsigned int temperatureK;\n> >               };\n> >  \n> >               AwbState manual;\n> >               AwbState automatic;\n> >  \n> > -             unsigned int temperatureK;\n> >               bool autoEnabled;\n> >       } awb;\n> >  \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 2D9B0BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 May 2025 09:19:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 13D1B68D82;\n\tTue, 20 May 2025 11:19:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4875C614DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 May 2025 11:19:41 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:1988:b6b6:ff72:2181])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C258BB;\n\tTue, 20 May 2025 11:19:20 +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=\"Ds76POY9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1747732760;\n\tbh=OktLwCRB+k7PAFNAtEk8Pq1dN3YcCpFeEG1g+oJ/8Vg=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Ds76POY9xcuUWRBz0rMrX63Nx7Ggq5YL+4ckJSd4ahAfz+YX/9I8WjAFuucrWL9fl\n\t5x59uqFt0kxQ3GrAor7eH8Uiu3NmWA9i5dvR/IpXpzlONb+7uO1Qy3aEHbAF6vOPsB\n\tjhxyy/rVbLJnMU7MpYliO6uQnjnRYuyU8Fx6qc0Q=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250507203944.GA28896@pendragon.ideasonboard.com>","References":"<20250403154925.382973-1-stefan.klug@ideasonboard.com>\n\t<20250403154925.382973-12-stefan.klug@ideasonboard.com>\n\t<20250507203944.GA28896@pendragon.ideasonboard.com>","Subject":"Re: [PATCH v3 11/16] ipa: rkisp1: ccm/lsc: Fix CCM/LSC based on\n\tmanual color temperature","From":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Tue, 20 May 2025 11:19:38 +0200","Message-ID":"<174773277815.11206.12629119127341853782@localhost>","User-Agent":"alot/0.12.dev16+g501a9541e2e6.d20250519","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>"}}]