[{"id":36837,"web_url":"https://patchwork.libcamera.org/comment/36837/","msgid":"<e4ccf9e1-24d2-49aa-a7aa-fe5c4cd87785@ideasonboard.com>","date":"2025-11-14T18:08:57","subject":"Re: [PATCH v4 12/21] ipa: rkisp1: cproc: Convert to use Quantized\n\ttypes","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 11. 14. 1:54 keltezéssel, Kieran Bingham írta:\n> Convert the Contrast and Saturuation helper functions to a Quantizer\n> type to support maintaining the data.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> ---\n> v3:\n> - Don't add <algorithm> into ipa_context.h anymore\n> \n>   src/ipa/rkisp1/algorithms/cproc.cpp | 36 +++++++++++------------------\n>   src/ipa/rkisp1/ipa_context.h        | 19 ++++++++++-----\n>   2 files changed, 27 insertions(+), 28 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\n> index d1fff6990d37..4637a824af03 100644\n> --- a/src/ipa/rkisp1/algorithms/cproc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n> @@ -14,6 +14,8 @@\n>   \n>   #include <libcamera/control_ids.h>\n>   \n> +#include \"libipa/quantized.h\"\n> +\n>   /**\n>    * \\file cproc.h\n>    */\n> @@ -39,16 +41,6 @@ constexpr float kDefaultBrightness = 0.0f;\n>   constexpr float kDefaultContrast = 1.0f;\n>   constexpr float kDefaultSaturation = 1.0f;\n>   \n> -int convertBrightness(const float v)\n> -{\n> -\treturn std::clamp<int>(std::lround(v * 128), -128, 127);\n> -}\n> -\n> -int convertContrastOrSaturation(const float v)\n> -{\n> -\treturn std::clamp<int>(std::lround(v * 128), 0, 255);\n> -}\n> -\n>   } /* namespace */\n>   \n>   /**\n> @@ -74,9 +66,9 @@ int ColorProcessing::configure(IPAContext &context,\n>   {\n>   \tauto &cproc = context.activeState.cproc;\n>   \n> -\tcproc.brightness = convertBrightness(kDefaultBrightness);\n> -\tcproc.contrast = convertContrastOrSaturation(kDefaultContrast);\n> -\tcproc.saturation = convertContrastOrSaturation(kDefaultSaturation);\n> +\tcproc.brightness = BrightnessQ(kDefaultBrightness);\n> +\tcproc.contrast = ContrastQ(kDefaultContrast);\n> +\tcproc.saturation = SaturationQ(kDefaultSaturation);\n>   \n>   \treturn 0;\n>   }\n> @@ -97,35 +89,35 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>   \n>   \tconst auto &brightness = controls.get(controls::Brightness);\n>   \tif (brightness) {\n> -\t\tint value = convertBrightness(*brightness);\n> +\t\tBrightnessQ value = *brightness;\n>   \t\tif (cproc.brightness != value) {\n>   \t\t\tcproc.brightness = value;\n>   \t\t\tupdate = true;\n>   \t\t}\n>   \n> -\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << value;\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << value.value();\n\nIf you add an `operator<<` to `Quantized<>`, then I think it makes sense to do\njust `<< value` to see the underlying integer value as well in these debug messages.\n\n\n>   \t}\n>   \n>   \tconst auto &contrast = controls.get(controls::Contrast);\n>   \tif (contrast) {\n> -\t\tint value = convertContrastOrSaturation(*contrast);\n> +\t\tContrastQ value = *contrast;\n>   \t\tif (cproc.contrast != value) {\n>   \t\t\tcproc.contrast = value;\n>   \t\t\tupdate = true;\n>   \t\t}\n>   \n> -\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value;\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value.value();\n>   \t}\n>   \n>   \tconst auto saturation = controls.get(controls::Saturation);\n>   \tif (saturation) {\n> -\t\tint value = convertContrastOrSaturation(*saturation);\n> +\t\tSaturationQ value = *saturation;\n>   \t\tif (cproc.saturation != value) {\n>   \t\t\tcproc.saturation = value;\n>   \t\t\tupdate = true;\n>   \t\t}\n>   \n> -\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << value;\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << value.value();\n>   \t}\n>   \n>   \tframeContext.cproc.brightness = cproc.brightness;\n> @@ -148,9 +140,9 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n>   \n>   \tauto config = params->block<BlockType::Cproc>();\n>   \tconfig.setEnabled(true);\n> -\tconfig->brightness = frameContext.cproc.brightness;\n> -\tconfig->contrast = frameContext.cproc.contrast;\n> -\tconfig->sat = frameContext.cproc.saturation;\n> +\tconfig->brightness = frameContext.cproc.brightness.quantized();\n> +\tconfig->contrast = frameContext.cproc.contrast.quantized();\n> +\tconfig->sat = frameContext.cproc.saturation.quantized();\n>   }\n>   \n>   REGISTER_IPA_ALGORITHM(ColorProcessing, \"ColorProcessing\")\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 6BD5EC3263\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 18:09:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1C2F960AA9;\n\tFri, 14 Nov 2025 19:09:00 +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 41BED60A9E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 19:08:58 +0100 (CET)","from [192.168.33.35] (185.221.143.100.nat.pool.zt.hu\n\t[185.221.143.100])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3FA1A397;\n\tFri, 14 Nov 2025 19:06:57 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"pp2bM4dO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763143617;\n\tbh=tE/3WiX08fspJ3AuoIsN4FTb/72SH5q1E4S/kZYrU6I=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=pp2bM4dOEnyaUCScyaTXxyUNlEGf9NbGj83Z5hH/LM/cRyGK6LWWEMOMvPIFNyHzM\n\tzbVb+bHMHFa3aaeaUIDxc9SA0Dzqffkd5I6rjaLyGJDJ11GhndaWsKI8yHcuK5tmME\n\t91q7lHWf21uJBLAaaxdHC5i5muRgdT8XNZBtHpCY=","Message-ID":"<e4ccf9e1-24d2-49aa-a7aa-fe5c4cd87785@ideasonboard.com>","Date":"Fri, 14 Nov 2025 19:08:57 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4 12/21] ipa: rkisp1: cproc: Convert to use Quantized\n\ttypes","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","References":"<20251114005428.90024-1-kieran.bingham@ideasonboard.com>\n\t<20251114005428.90024-13-kieran.bingham@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20251114005428.90024-13-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":36878,"web_url":"https://patchwork.libcamera.org/comment/36878/","msgid":"<176346962144.880260.15545021885101072640@isaac-ThinkPad-T16-Gen-2>","date":"2025-11-18T12:40:21","subject":"Re: [PATCH v4 12/21] ipa: rkisp1: cproc: Convert to use Quantized\n\ttypes","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch!\n\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n\nQuoting Kieran Bingham (2025-11-14 00:54:16)\n> Convert the Contrast and Saturuation helper functions to a Quantizer\n> type to support maintaining the data.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> ---\n> v3:\n> - Don't add <algorithm> into ipa_context.h anymore\n> \n>  src/ipa/rkisp1/algorithms/cproc.cpp | 36 +++++++++++------------------\n>  src/ipa/rkisp1/ipa_context.h        | 19 ++++++++++-----\n>  2 files changed, 27 insertions(+), 28 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\n> index d1fff6990d37..4637a824af03 100644\n> --- a/src/ipa/rkisp1/algorithms/cproc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n> @@ -14,6 +14,8 @@\n>  \n>  #include <libcamera/control_ids.h>\n>  \n> +#include \"libipa/quantized.h\"\n> +\n>  /**\n>   * \\file cproc.h\n>   */\n> @@ -39,16 +41,6 @@ constexpr float kDefaultBrightness = 0.0f;\n>  constexpr float kDefaultContrast = 1.0f;\n>  constexpr float kDefaultSaturation = 1.0f;\n>  \n> -int convertBrightness(const float v)\n> -{\n> -       return std::clamp<int>(std::lround(v * 128), -128, 127);\n> -}\n> -\n> -int convertContrastOrSaturation(const float v)\n> -{\n> -       return std::clamp<int>(std::lround(v * 128), 0, 255);\n> -}\n> -\n>  } /* namespace */\n>  \n>  /**\n> @@ -74,9 +66,9 @@ int ColorProcessing::configure(IPAContext &context,\n>  {\n>         auto &cproc = context.activeState.cproc;\n>  \n> -       cproc.brightness = convertBrightness(kDefaultBrightness);\n> -       cproc.contrast = convertContrastOrSaturation(kDefaultContrast);\n> -       cproc.saturation = convertContrastOrSaturation(kDefaultSaturation);\n> +       cproc.brightness = BrightnessQ(kDefaultBrightness);\n> +       cproc.contrast = ContrastQ(kDefaultContrast);\n> +       cproc.saturation = SaturationQ(kDefaultSaturation);\n>  \n>         return 0;\n>  }\n> @@ -97,35 +89,35 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>  \n>         const auto &brightness = controls.get(controls::Brightness);\n>         if (brightness) {\n> -               int value = convertBrightness(*brightness);\n> +               BrightnessQ value = *brightness;\n>                 if (cproc.brightness != value) {\n>                         cproc.brightness = value;\n>                         update = true;\n>                 }\n>  \n> -               LOG(RkISP1CProc, Debug) << \"Set brightness to \" << value;\n> +               LOG(RkISP1CProc, Debug) << \"Set brightness to \" << value.value();\n>         }\n>  \n>         const auto &contrast = controls.get(controls::Contrast);\n>         if (contrast) {\n> -               int value = convertContrastOrSaturation(*contrast);\n> +               ContrastQ value = *contrast;\n>                 if (cproc.contrast != value) {\n>                         cproc.contrast = value;\n>                         update = true;\n>                 }\n>  \n> -               LOG(RkISP1CProc, Debug) << \"Set contrast to \" << value;\n> +               LOG(RkISP1CProc, Debug) << \"Set contrast to \" << value.value();\n>         }\n>  \n>         const auto saturation = controls.get(controls::Saturation);\n>         if (saturation) {\n> -               int value = convertContrastOrSaturation(*saturation);\n> +               SaturationQ value = *saturation;\n>                 if (cproc.saturation != value) {\n>                         cproc.saturation = value;\n>                         update = true;\n>                 }\n>  \n> -               LOG(RkISP1CProc, Debug) << \"Set saturation to \" << value;\n> +               LOG(RkISP1CProc, Debug) << \"Set saturation to \" << value.value();\n>         }\n>  \n>         frameContext.cproc.brightness = cproc.brightness;\n> @@ -148,9 +140,9 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n>  \n>         auto config = params->block<BlockType::Cproc>();\n>         config.setEnabled(true);\n> -       config->brightness = frameContext.cproc.brightness;\n> -       config->contrast = frameContext.cproc.contrast;\n> -       config->sat = frameContext.cproc.saturation;\n> +       config->brightness = frameContext.cproc.brightness.quantized();\n> +       config->contrast = frameContext.cproc.contrast.quantized();\n> +       config->sat = frameContext.cproc.saturation.quantized();\n>  }\n>  \n>  REGISTER_IPA_ALGORITHM(ColorProcessing, \"ColorProcessing\")\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index f85a130d9c23..651558bdf42d 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -27,11 +27,17 @@\n>  #include <libipa/camera_sensor_helper.h>\n>  #include <libipa/fc_queue.h>\n>  #include \"libipa/agc_mean_luminance.h\"\n> +#include \"libipa/fixedpoint.h\"\n>  \n>  namespace libcamera {\n>  \n>  namespace ipa::rkisp1 {\n>  \n> +/* Fixed point types used by CPROC */\n> +using BrightnessQ = Q1_7;\n> +using ContrastQ = UQ1_7;\n> +using SaturationQ = UQ1_7;\n> +\n>  struct IPAHwSettings {\n>         unsigned int numAeCells;\n>         unsigned int numHistogramBins;\n> @@ -115,9 +121,9 @@ struct IPAActiveState {\n>         } ccm;\n>  \n>         struct {\n> -               int8_t brightness;\n> -               uint8_t contrast;\n> -               uint8_t saturation;\n> +               BrightnessQ brightness;\n> +               ContrastQ contrast;\n> +               SaturationQ saturation;\n>         } cproc;\n>  \n>         struct {\n> @@ -169,9 +175,10 @@ struct IPAFrameContext : public FrameContext {\n>         } awb;\n>  \n>         struct {\n> -               int8_t brightness;\n> -               uint8_t contrast;\n> -               uint8_t saturation;\n> +               BrightnessQ brightness;\n> +               ContrastQ contrast;\n> +               SaturationQ saturation;\n> +\n>                 bool update;\n>         } cproc;\n>  \n> -- \n> 2.51.1\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 74669BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Nov 2025 12:40:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32D2560A86;\n\tTue, 18 Nov 2025 13:40:25 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A359606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Nov 2025 13:40:24 +0100 (CET)","from thinkpad.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 A0A121E33;\n\tTue, 18 Nov 2025 13:38:20 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"IDYp5XpY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763469500;\n\tbh=QthhHumqkCPF9tcThK3/w/sxLilULhvuIAsNtLs4fo0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=IDYp5XpYEzcWRnUYKLXW9L3Jit312q0tdw5qMpKJPM9TKZLe4jSm1jf6E10SH42oe\n\tzI+TUid2/163BOY2BcWYr1Pl8+vf88GeoizCtJG4f9Js9pgQsnR7s+bSmD2ioo1Gch\n\tTNZ4AVlirdVEi+orX7EHATW0NQZ4+xCEL5cItZEs=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251114005428.90024-13-kieran.bingham@ideasonboard.com>","References":"<20251114005428.90024-1-kieran.bingham@ideasonboard.com>\n\t<20251114005428.90024-13-kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v4 12/21] ipa: rkisp1: cproc: Convert to use Quantized\n\ttypes","From":"Isaac Scott <isaac.scott@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 18 Nov 2025 12:40:21 +0000","Message-ID":"<176346962144.880260.15545021885101072640@isaac-ThinkPad-T16-Gen-2>","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":36904,"web_url":"https://patchwork.libcamera.org/comment/36904/","msgid":"<20251119043057.GE17526@pendragon.ideasonboard.com>","date":"2025-11-19T04:30:57","subject":"Re: [PATCH v4 12/21] ipa: rkisp1: cproc: Convert to use Quantized\n\ttypes","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Nov 14, 2025 at 12:54:16AM +0000, Kieran Bingham wrote:\n> Convert the Contrast and Saturuation helper functions to a Quantizer\n\ns/Saturuation/Saturation/\n\nYou forgot brighness.\n\n> type to support maintaining the data.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> ---\n> v3:\n> - Don't add <algorithm> into ipa_context.h anymore\n> \n>  src/ipa/rkisp1/algorithms/cproc.cpp | 36 +++++++++++------------------\n>  src/ipa/rkisp1/ipa_context.h        | 19 ++++++++++-----\n>  2 files changed, 27 insertions(+), 28 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\n> index d1fff6990d37..4637a824af03 100644\n> --- a/src/ipa/rkisp1/algorithms/cproc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n> @@ -14,6 +14,8 @@\n>  \n>  #include <libcamera/control_ids.h>\n>  \n> +#include \"libipa/quantized.h\"\n> +\n>  /**\n>   * \\file cproc.h\n>   */\n> @@ -39,16 +41,6 @@ constexpr float kDefaultBrightness = 0.0f;\n>  constexpr float kDefaultContrast = 1.0f;\n>  constexpr float kDefaultSaturation = 1.0f;\n>  \n> -int convertBrightness(const float v)\n> -{\n> -\treturn std::clamp<int>(std::lround(v * 128), -128, 127);\n> -}\n> -\n> -int convertContrastOrSaturation(const float v)\n> -{\n> -\treturn std::clamp<int>(std::lround(v * 128), 0, 255);\n> -}\n> -\n>  } /* namespace */\n>  \n>  /**\n> @@ -74,9 +66,9 @@ int ColorProcessing::configure(IPAContext &context,\n>  {\n>  \tauto &cproc = context.activeState.cproc;\n>  \n> -\tcproc.brightness = convertBrightness(kDefaultBrightness);\n> -\tcproc.contrast = convertContrastOrSaturation(kDefaultContrast);\n> -\tcproc.saturation = convertContrastOrSaturation(kDefaultSaturation);\n> +\tcproc.brightness = BrightnessQ(kDefaultBrightness);\n> +\tcproc.contrast = ContrastQ(kDefaultContrast);\n> +\tcproc.saturation = SaturationQ(kDefaultSaturation);\n>  \n>  \treturn 0;\n>  }\n> @@ -97,35 +89,35 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>  \n>  \tconst auto &brightness = controls.get(controls::Brightness);\n>  \tif (brightness) {\n> -\t\tint value = convertBrightness(*brightness);\n> +\t\tBrightnessQ value = *brightness;\n>  \t\tif (cproc.brightness != value) {\n>  \t\t\tcproc.brightness = value;\n>  \t\t\tupdate = true;\n>  \t\t}\n>  \n> -\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << value;\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << value.value();\n\nAn operator<<() would be nice.\n\n>  \t}\n>  \n>  \tconst auto &contrast = controls.get(controls::Contrast);\n>  \tif (contrast) {\n> -\t\tint value = convertContrastOrSaturation(*contrast);\n> +\t\tContrastQ value = *contrast;\n>  \t\tif (cproc.contrast != value) {\n>  \t\t\tcproc.contrast = value;\n>  \t\t\tupdate = true;\n>  \t\t}\n>  \n> -\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value;\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value.value();\n>  \t}\n>  \n>  \tconst auto saturation = controls.get(controls::Saturation);\n>  \tif (saturation) {\n> -\t\tint value = convertContrastOrSaturation(*saturation);\n> +\t\tSaturationQ value = *saturation;\n>  \t\tif (cproc.saturation != value) {\n>  \t\t\tcproc.saturation = value;\n>  \t\t\tupdate = true;\n>  \t\t}\n>  \n> -\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << value;\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << value.value();\n>  \t}\n>  \n>  \tframeContext.cproc.brightness = cproc.brightness;\n> @@ -148,9 +140,9 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n>  \n>  \tauto config = params->block<BlockType::Cproc>();\n>  \tconfig.setEnabled(true);\n> -\tconfig->brightness = frameContext.cproc.brightness;\n> -\tconfig->contrast = frameContext.cproc.contrast;\n> -\tconfig->sat = frameContext.cproc.saturation;\n> +\tconfig->brightness = frameContext.cproc.brightness.quantized();\n> +\tconfig->contrast = frameContext.cproc.contrast.quantized();\n> +\tconfig->sat = frameContext.cproc.saturation.quantized();\n>  }\n>  \n>  REGISTER_IPA_ALGORITHM(ColorProcessing, \"ColorProcessing\")\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index f85a130d9c23..651558bdf42d 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -27,11 +27,17 @@\n>  #include <libipa/camera_sensor_helper.h>\n>  #include <libipa/fc_queue.h>\n>  #include \"libipa/agc_mean_luminance.h\"\n> +#include \"libipa/fixedpoint.h\"\n\nWhile at it, could you unify the include style ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \n>  namespace libcamera {\n>  \n>  namespace ipa::rkisp1 {\n>  \n> +/* Fixed point types used by CPROC */\n> +using BrightnessQ = Q1_7;\n> +using ContrastQ = UQ1_7;\n> +using SaturationQ = UQ1_7;\n> +\n>  struct IPAHwSettings {\n>  \tunsigned int numAeCells;\n>  \tunsigned int numHistogramBins;\n> @@ -115,9 +121,9 @@ struct IPAActiveState {\n>  \t} ccm;\n>  \n>  \tstruct {\n> -\t\tint8_t brightness;\n> -\t\tuint8_t contrast;\n> -\t\tuint8_t saturation;\n> +\t\tBrightnessQ brightness;\n> +\t\tContrastQ contrast;\n> +\t\tSaturationQ saturation;\n>  \t} cproc;\n>  \n>  \tstruct {\n> @@ -169,9 +175,10 @@ struct IPAFrameContext : public FrameContext {\n>  \t} awb;\n>  \n>  \tstruct {\n> -\t\tint8_t brightness;\n> -\t\tuint8_t contrast;\n> -\t\tuint8_t saturation;\n> +\t\tBrightnessQ brightness;\n> +\t\tContrastQ contrast;\n> +\t\tSaturationQ saturation;\n> +\n>  \t\tbool update;\n>  \t} cproc;\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 C8244C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Nov 2025 04:31:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7D70A60A80;\n\tWed, 19 Nov 2025 05:31:33 +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 1ABD760A7B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Nov 2025 05:31:31 +0100 (CET)","from pendragon.ideasonboard.com (unknown [205.220.129.225])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 0BFE114B0; \n\tWed, 19 Nov 2025 05:29:25 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ivdvbIHi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763526567;\n\tbh=LGVgEkFx5Kq7fp3bAPtj8e4/yoxy1hcfQyGnJTICRPY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ivdvbIHiPnWluNNG2V3vxZG+TceLtwvAktKxJyhajFG0o4+ELF8/tG9YvW1li61XX\n\twJ1MK/9RW15NlANGYrgXH4S9koHRCsGDHBmznG5yACEoUVSayQD4kcM3U4UKlJmVsl\n\tYegftJiD8QPqbb8l/vElAmP89mQNa3MTRZQHrg4M=","Date":"Wed, 19 Nov 2025 13:30:57 +0900","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Subject":"Re: [PATCH v4 12/21] ipa: rkisp1: cproc: Convert to use Quantized\n\ttypes","Message-ID":"<20251119043057.GE17526@pendragon.ideasonboard.com>","References":"<20251114005428.90024-1-kieran.bingham@ideasonboard.com>\n\t<20251114005428.90024-13-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251114005428.90024-13-kieran.bingham@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>"}}]