[{"id":32894,"web_url":"https://patchwork.libcamera.org/comment/32894/","msgid":"<pkxbs75bwz3v5wfo6g4btjwx2h4sumtvipx3up4yg2qyvzxgji@5wqz24jjs7b2>","date":"2024-12-20T10:03:31","subject":"Re: [PATCH v6 9/9] ipa: rpi: awb: Make it possible to set the colour\n\ttemperature directly","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi David,\n\nThat patch is mostly unmodified. The only fix I had to apply was the\nchange from config_.ctR.domain().clip() to config_.ctR.domain().clamp().\n\nSo I guess you are fine with merging it?\n\nBest regards,\nStefan\n\nOn Thu, Dec 19, 2024 at 06:57:26PM +0100, Stefan Klug wrote:\n> From: David Plowman <david.plowman@raspberrypi.com>\n> \n> ColourTemperature is now exported as a writable control so that\n> applications can set it directly. The AWB algorithm class now requires\n> a 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> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Tested-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> --- Changes in v6:\n> - Added this commit from https://patchwork.libcamera.org/patch/19232/\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 45e2a1d7a6eb..0c8aee699155 100644\n> --- a/src/ipa/rpi/common/ipa_base.cpp\n> +++ b/src/ipa/rpi/common/ipa_base.cpp\n> @@ -81,6 +81,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> @@ -1011,6 +1012,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 1779b0500a04..d941ed4e3476 100644\n> --- a/src/ipa/rpi/controller/awb_algorithm.h\n> +++ b/src/ipa/rpi/controller/awb_algorithm.h\n> @@ -19,6 +19,7 @@ public:\n>  \tvirtual void initialValues(double &gainR, double &gainB) = 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 c277a1764112..8479ae40951d 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> @@ -293,6 +293,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().clamp(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 5d628b47c8a6..86640f8f8e21 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.h\n> +++ b/src/ipa/rpi/controller/rpi/awb.h\n> @@ -105,6 +105,7 @@ public:\n>  \tvoid initialValues(double &gainR, double &gainB) 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;\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 1B26EC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Dec 2024 10:03:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C0BE86848F;\n\tFri, 20 Dec 2024 11:03:37 +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 6305D68488\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Dec 2024 11:03:35 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:4eeb:7fa7:1fd0:c13d])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D476F7E2;\n\tFri, 20 Dec 2024 11:02:55 +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=\"ced3229F\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734688975;\n\tbh=dlKNiR1bib/mCoOfTAWJUmik3R5DNCR/VVNmDbrtGX0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ced3229F7p9ej1LKFckuavkx6LFpHoUvqRFmb7gezAJBlm6S11qOi/CCpfx8MUApZ\n\tiTs2N5FMRkLOtlEmCi4gKTaVBhoO160DsZP7UdI/G04/kemcZZJVFi2UOTREU48B7g\n\tsrBc/xZ6u0DQUlzpyGv1eCbDwnjQilO9FZM2dCag=","Date":"Fri, 20 Dec 2024 11:03:31 +0100","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org, \n\tDavid Plowman <david.plowman@raspberrypi.com>","Cc":"Naushir Patuck <naush@raspberrypi.com>, \n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v6 9/9] ipa: rpi: awb: Make it possible to set the colour\n\ttemperature directly","Message-ID":"<pkxbs75bwz3v5wfo6g4btjwx2h4sumtvipx3up4yg2qyvzxgji@5wqz24jjs7b2>","References":"<20241219175729.293782-1-stefan.klug@ideasonboard.com>\n\t<20241219175729.293782-10-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20241219175729.293782-10-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>"}}]