[{"id":37677,"web_url":"https://patchwork.libcamera.org/comment/37677/","msgid":"<3bbc38fe-5c3a-446e-9e07-103bdd49f986@ideasonboard.com>","date":"2026-01-15T15:11:12","subject":"Re: [PATCH v5 09/16] ipa: rkisp1: cproc: Provide a Hue control","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 14. 18:39 keltezéssel, Kieran Bingham írta:\n> The RKISP1 supports a configurable Hue as part of the colour processing\n> unit (cproc).\n> \n> Implement the new control converting to the hardware scale accordingly\n> and report the applied control in the completed request metadata.\n> \n> This is implemented as a phase shift of the chrominance values between\n> -90 and +87.188 degrees according to the datasheet however the type\n> itself would imply that this is a range between -90 and 89.2969.\n> \n> Moreover, the hardware applies the inverse phase shift to the operation\n> expected and documented by libcamera, so we apply a negative scale when\n> converting the libcamera control to the Q<1,7> type, resulting in a\n> range of -89.2969 to +90.0 degrees control.\n> \n> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> ---\n\nA quick test with camshark seems ok.\n\nTested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n> \n> v5:\n> - Use Q<1, 7> directly and handle scaling in cproc.cpp\n> - Use full string of quantized in debug log\n> - Invert/Negate the hardware hue direction\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>   src/ipa/rkisp1/algorithms/cproc.cpp | 28 ++++++++++++++++++++++++++++\n>   src/ipa/rkisp1/ipa_context.h        |  3 +++\n>   2 files changed, 31 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\n> index e9e2b5444bc9..7484e4780094 100644\n> --- a/src/ipa/rkisp1/algorithms/cproc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n> @@ -37,8 +37,15 @@ namespace {\n>   \n>   constexpr float kDefaultBrightness = 0.0f;\n>   constexpr float kDefaultContrast = 1.0f;\n> +constexpr float kDefaultHue = 0.0f;\n>   constexpr float kDefaultSaturation = 1.0f;\n>   \n> +/*\n> + * The Hue scale is negated as the hardware performs the opposite phase shift\n> + * to what is expected and defined from the libcamera Hue control value.\n> + */\n> +constexpr float kHueScale = -90.0f;\n> +\n>   } /* namespace */\n>   \n>   /**\n> @@ -53,6 +60,11 @@ int ColorProcessing::init(IPAContext &context,\n>   \tcmap[&controls::Contrast] = ControlInfo(0.0f, 1.993f, kDefaultContrast);\n>   \tcmap[&controls::Saturation] = ControlInfo(0.0f, 1.993f, kDefaultSaturation);\n>   \n> +\t/* Hue adjustment is negated by kHueScale, min/max are swapped */\n> +\tcmap[&controls::Hue] = ControlInfo(HueQ::TraitsType::max * kHueScale,\n> +\t\t\t\t\t   HueQ::TraitsType::min * kHueScale,\n> +\t\t\t\t\t   kDefaultHue);\n> +\n>   \treturn 0;\n>   }\n>   \n> @@ -66,6 +78,7 @@ int ColorProcessing::configure(IPAContext &context,\n>   \n>   \tcproc.brightness = BrightnessQ(kDefaultBrightness);\n>   \tcproc.contrast = ContrastQ(kDefaultContrast);\n> +\tcproc.hue = HueQ(kDefaultHue);\n>   \tcproc.saturation = SaturationQ(kDefaultSaturation);\n>   \n>   \treturn 0;\n> @@ -107,6 +120,18 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>   \t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value;\n>   \t}\n>   \n> +\tconst auto &hue = controls.get(controls::Hue);\n> +\tif (hue) {\n> +\t\t/* Scale the Hue from ]-90, +90] */\n> +\t\tHueQ value = *hue / kHueScale;\n> +\t\tif (cproc.hue != value) {\n> +\t\t\tcproc.hue = value;\n> +\t\t\tupdate = true;\n> +\t\t}\n> +\n> +\t\tLOG(RkISP1CProc, Debug) << \"Set hue to \" << value;\n> +\t}\n> +\n>   \tconst auto saturation = controls.get(controls::Saturation);\n>   \tif (saturation) {\n>   \t\tSaturationQ value = *saturation;\n> @@ -120,6 +145,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>   \n>   \tframeContext.cproc.brightness = cproc.brightness;\n>   \tframeContext.cproc.contrast = cproc.contrast;\n> +\tframeContext.cproc.hue = cproc.hue;\n>   \tframeContext.cproc.saturation = cproc.saturation;\n>   \tframeContext.cproc.update = update;\n>   }\n> @@ -140,6 +166,7 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n>   \tconfig.setEnabled(true);\n>   \tconfig->brightness = frameContext.cproc.brightness.quantized();\n>   \tconfig->contrast = frameContext.cproc.contrast.quantized();\n> +\tconfig->hue = frameContext.cproc.hue.quantized();\n>   \tconfig->sat = frameContext.cproc.saturation.quantized();\n>   }\n>   \n> @@ -154,6 +181,7 @@ void ColorProcessing::process([[maybe_unused]] IPAContext &context,\n>   {\n>   \tmetadata.set(controls::Brightness, frameContext.cproc.brightness.value());\n>   \tmetadata.set(controls::Contrast, frameContext.cproc.contrast.value());\n> +\tmetadata.set(controls::Hue, frameContext.cproc.hue.value() * kHueScale);\n>   \tmetadata.set(controls::Saturation, frameContext.cproc.saturation.value());\n>   }\n>   \n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index cdb9a17b5adc..80b035044cda 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -36,6 +36,7 @@ namespace ipa::rkisp1 {\n>   /* Fixed point types used by CPROC */\n>   using BrightnessQ = Q<1, 7>;\n>   using ContrastQ = UQ<1, 7>;\n> +using HueQ = Q<1, 7>;\n>   using SaturationQ = UQ<1, 7>;\n>   \n>   struct IPAHwSettings {\n> @@ -123,6 +124,7 @@ struct IPAActiveState {\n>   \tstruct {\n>   \t\tBrightnessQ brightness;\n>   \t\tContrastQ contrast;\n> +\t\tHueQ hue;\n>   \t\tSaturationQ saturation;\n>   \t} cproc;\n>   \n> @@ -181,6 +183,7 @@ struct IPAFrameContext : public FrameContext {\n>   \tstruct {\n>   \t\tBrightnessQ brightness;\n>   \t\tContrastQ contrast;\n> +\t\tHueQ hue;\n>   \t\tSaturationQ saturation;\n>   \n>   \t\tbool update;","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 185C6C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Jan 2026 15:11:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5421C61FBC;\n\tThu, 15 Jan 2026 16:11: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 213D261F84\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Jan 2026 16:11:24 +0100 (CET)","from [192.168.33.20] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 50ADA316;\n\tThu, 15 Jan 2026 16:10:53 +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=\"oCI9nhzi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768489856;\n\tbh=tdwbJjyBuL7a0ZTn3wIh/0vBzz2K5jkEd54fHeJYNXk=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=oCI9nhziVYw63bksv7NRcAOm6mXA6gQriJ9AQ7sUj4Qp/59SiSZiRZ49F8PBhDjzP\n\tzNPgaf/o0XySnGz2xOD+ybl3LpVxkYbOW/5hn3gANWjE1cpnlX8S5HxaQ1aNhTAXxC\n\tGOd5viwDXq4oQrr+FisZwONiKL6PSNomq+YU6LIU=","Message-ID":"<3bbc38fe-5c3a-446e-9e07-103bdd49f986@ideasonboard.com>","Date":"Thu, 15 Jan 2026 16:11:12 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v5 09/16] ipa: rkisp1: cproc: Provide a Hue control","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","Cc":"Isaac Scott <isaac.scott@ideasonboard.com>","References":"<20260114173918.1744023-1-kieran.bingham@ideasonboard.com>\n\t<20260114173918.1744023-10-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":"<20260114173918.1744023-10-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":37678,"web_url":"https://patchwork.libcamera.org/comment/37678/","msgid":"<5462895d-a973-4c97-8511-393b91c6cbf2@ideasonboard.com>","date":"2026-01-15T15:37:55","subject":"Re: [PATCH v5 09/16] ipa: rkisp1: cproc: Provide a Hue control","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 15. 16:11 keltezéssel, Barnabás Pőcze írta:\n> 2026. 01. 14. 18:39 keltezéssel, Kieran Bingham írta:\n>> The RKISP1 supports a configurable Hue as part of the colour processing\n>> unit (cproc).\n>>\n>> Implement the new control converting to the hardware scale accordingly\n>> and report the applied control in the completed request metadata.\n>>\n>> This is implemented as a phase shift of the chrominance values between\n>> -90 and +87.188 degrees according to the datasheet however the type\n>> itself would imply that this is a range between -90 and 89.2969.\n>>\n>> Moreover, the hardware applies the inverse phase shift to the operation\n>> expected and documented by libcamera, so we apply a negative scale when\n>> converting the libcamera control to the Q<1,7> type, resulting in a\n>> range of -89.2969 to +90.0 degrees control.\n>>\n>> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>\n>> ---\n> \n> A quick test with camshark seems ok.\n> \n> Tested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> \n> \n>>\n>> v5:\n>> - Use Q<1, 7> directly and handle scaling in cproc.cpp\n>> - Use full string of quantized in debug log\n>> - Invert/Negate the hardware hue direction\n>>\n>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>> ---\n>>   src/ipa/rkisp1/algorithms/cproc.cpp | 28 ++++++++++++++++++++++++++++\n>>   src/ipa/rkisp1/ipa_context.h        |  3 +++\n>>   2 files changed, 31 insertions(+)\n>>\n>> diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\n>> index e9e2b5444bc9..7484e4780094 100644\n>> --- a/src/ipa/rkisp1/algorithms/cproc.cpp\n>> +++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n>> @@ -37,8 +37,15 @@ namespace {\n>>   constexpr float kDefaultBrightness = 0.0f;\n>>   constexpr float kDefaultContrast = 1.0f;\n>> +constexpr float kDefaultHue = 0.0f;\n>>   constexpr float kDefaultSaturation = 1.0f;\n>> +/*\n>> + * The Hue scale is negated as the hardware performs the opposite phase shift\n>> + * to what is expected and defined from the libcamera Hue control value.\n>> + */\n>> +constexpr float kHueScale = -90.0f;\n>> +\n>>   } /* namespace */\n>>   /**\n>> @@ -53,6 +60,11 @@ int ColorProcessing::init(IPAContext &context,\n>>       cmap[&controls::Contrast] = ControlInfo(0.0f, 1.993f, kDefaultContrast);\n>>       cmap[&controls::Saturation] = ControlInfo(0.0f, 1.993f, kDefaultSaturation);\n>> +    /* Hue adjustment is negated by kHueScale, min/max are swapped */\n>> +    cmap[&controls::Hue] = ControlInfo(HueQ::TraitsType::max * kHueScale,\n>> +                       HueQ::TraitsType::min * kHueScale,\n>> +                       kDefaultHue);\n>> +\n>>       return 0;\n>>   }\n>> @@ -66,6 +78,7 @@ int ColorProcessing::configure(IPAContext &context,\n>>       cproc.brightness = BrightnessQ(kDefaultBrightness);\n>>       cproc.contrast = ContrastQ(kDefaultContrast);\n>> +    cproc.hue = HueQ(kDefaultHue);\n>>       cproc.saturation = SaturationQ(kDefaultSaturation);\n>>       return 0;\n>> @@ -107,6 +120,18 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>>           LOG(RkISP1CProc, Debug) << \"Set contrast to \" << value;\n>>       }\n>> +    const auto &hue = controls.get(controls::Hue);\n>> +    if (hue) {\n>> +        /* Scale the Hue from ]-90, +90] */\n>> +        HueQ value = *hue / kHueScale;\n>> +        if (cproc.hue != value) {\n>> +            cproc.hue = value;\n>> +            update = true;\n>> +        }\n>> +\n>> +        LOG(RkISP1CProc, Debug) << \"Set hue to \" << value;\n>> +    }\n>> +\n>>       const auto saturation = controls.get(controls::Saturation);\n>>       if (saturation) {\n>>           SaturationQ value = *saturation;\n>> @@ -120,6 +145,7 @@ void ColorProcessing::queueRequest(IPAContext &context,\n>>       frameContext.cproc.brightness = cproc.brightness;\n>>       frameContext.cproc.contrast = cproc.contrast;\n>> +    frameContext.cproc.hue = cproc.hue;\n>>       frameContext.cproc.saturation = cproc.saturation;\n>>       frameContext.cproc.update = update;\n>>   }\n>> @@ -140,6 +166,7 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n>>       config.setEnabled(true);\n>>       config->brightness = frameContext.cproc.brightness.quantized();\n>>       config->contrast = frameContext.cproc.contrast.quantized();\n>> +    config->hue = frameContext.cproc.hue.quantized();\n>>       config->sat = frameContext.cproc.saturation.quantized();\n>>   }\n>> @@ -154,6 +181,7 @@ void ColorProcessing::process([[maybe_unused]] IPAContext &context,\n>>   {\n>>       metadata.set(controls::Brightness, frameContext.cproc.brightness.value());\n>>       metadata.set(controls::Contrast, frameContext.cproc.contrast.value());\n>> +    metadata.set(controls::Hue, frameContext.cproc.hue.value() * kHueScale);\n\nI suppose there is one thing that might be somewhat annoying: if it is set to 0,\nthen the metadata returns -0.\n\n\n>>       metadata.set(controls::Saturation, frameContext.cproc.saturation.value());\n>>   }\n>> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n>> index cdb9a17b5adc..80b035044cda 100644\n>> --- a/src/ipa/rkisp1/ipa_context.h\n>> +++ b/src/ipa/rkisp1/ipa_context.h\n>> @@ -36,6 +36,7 @@ namespace ipa::rkisp1 {\n>>   /* Fixed point types used by CPROC */\n>>   using BrightnessQ = Q<1, 7>;\n>>   using ContrastQ = UQ<1, 7>;\n>> +using HueQ = Q<1, 7>;\n>>   using SaturationQ = UQ<1, 7>;\n>>   struct IPAHwSettings {\n>> @@ -123,6 +124,7 @@ struct IPAActiveState {\n>>       struct {\n>>           BrightnessQ brightness;\n>>           ContrastQ contrast;\n>> +        HueQ hue;\n>>           SaturationQ saturation;\n>>       } cproc;\n>> @@ -181,6 +183,7 @@ struct IPAFrameContext : public FrameContext {\n>>       struct {\n>>           BrightnessQ brightness;\n>>           ContrastQ contrast;\n>> +        HueQ hue;\n>>           SaturationQ saturation;\n>>           bool update;\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 E2146BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Jan 2026 15:38:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D55A761FC3;\n\tThu, 15 Jan 2026 16:38:01 +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 C980161F84\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Jan 2026 16:37:59 +0100 (CET)","from [192.168.33.20] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ED5C3316;\n\tThu, 15 Jan 2026 16:37:31 +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=\"BSyWR79F\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768491452;\n\tbh=WePx3TQdR/HUKWEgK/1gkVxXX4pqacwVPJPQzwldSzw=;\n\th=Date:Subject:From:To:Cc:References:In-Reply-To:From;\n\tb=BSyWR79FuzpnXUSiFWRFHIPT7z+ekBTu1/3yatpWHAjjHZpZUe4hdmfJpOZ8g4I8u\n\tEPzgAPmFwgEQRW5nWeUk9sHc7+oY9/O1HfXF7jFpDz3KBwAMI6dm8Oa5dcL+uvrXTM\n\tW2EA7kUYKLUDjxvE6HwEis+VYLygAAApCUviXmTw=","Message-ID":"<5462895d-a973-4c97-8511-393b91c6cbf2@ideasonboard.com>","Date":"Thu, 15 Jan 2026 16:37:55 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v5 09/16] ipa: rkisp1: cproc: Provide a Hue control","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","Cc":"Isaac Scott <isaac.scott@ideasonboard.com>","References":"<20260114173918.1744023-1-kieran.bingham@ideasonboard.com>\n\t<20260114173918.1744023-10-kieran.bingham@ideasonboard.com>\n\t<3bbc38fe-5c3a-446e-9e07-103bdd49f986@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<3bbc38fe-5c3a-446e-9e07-103bdd49f986@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>"}}]