{"id":26565,"url":"https://patchwork.libcamera.org/api/patches/26565/?format=json","web_url":"https://patchwork.libcamera.org/patch/26565/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260424200255.356798-4-mzamazal@redhat.com>","date":"2026-04-24T20:02:49","name":"[RFC,v3,3/7] ipa: simple: Introduce default temperature value","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9f6d474d7f41c94e47a5f9783f3f0def59aa61e1","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26565/mbox/","series":[{"id":5885,"url":"https://patchwork.libcamera.org/api/series/5885/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5885","date":"2026-04-24T20:02:46","name":"LSC for SoftISP simple pipeline","version":3,"mbox":"https://patchwork.libcamera.org/series/5885/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26565/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26565/checks/","tags":{},"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 E6210BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Apr 2026 20:03:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9B3E662FAA;\n\tFri, 24 Apr 2026 22:03:25 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 78F4B62F9D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2026 22:03:22 +0200 (CEST)","from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-475-ECyIt0R6OIyt36YclkNa7A-1;\n\tFri, 24 Apr 2026 16:03:13 -0400","from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 55F901956059; Fri, 24 Apr 2026 20:03:11 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.33])\n\tby mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 071B53007572; Fri, 24 Apr 2026 20:03:09 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"DMdGeKFH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1777061001;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=nT+0moHosv4tRpd4gfW9X5s1r+t8wPBaJAM2u1YjK04=;\n\tb=DMdGeKFHTzqIU/8z2V63a/5+383iKkHFd6Kh/TPaIo4TtC8py493DQivgM60p6updAlx5k\n\twMXpUJBYf8pqQqYYIhLn139hM0nb9TAT1ItC15wu3bCN8SWWLCUBSdcYSIpoPv2MHbpv2Z\n\tfrjkBa8IndFfo+rU3RnqQ7CfIBjH82k=","X-MC-Unique":"ECyIt0R6OIyt36YclkNa7A-1","X-Mimecast-MFC-AGG-ID":"ECyIt0R6OIyt36YclkNa7A_1777060991","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>, Bryan O'Donoghue <bod.linux@nxsw.ie>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>","Subject":"[RFC PATCH v3 3/7] ipa: simple: Introduce default temperature value","Date":"Fri, 24 Apr 2026 22:02:49 +0200","Message-ID":"<20260424200255.356798-4-mzamazal@redhat.com>","In-Reply-To":"<20260424200255.356798-1-mzamazal@redhat.com>","References":"<20260424200255.356798-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.4","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"q3TOS1zC5mlEWKKqbVWL2fLcm_Y7biDPDKA9l2yBNxw_1777060991","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","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>"},"content":"Some algorithms use interpolated values based on temperature.\nTemperature is computed in the AWB algorithm.  Technically, the AWB\nalgorithm can be disabled and then no temperature is computed.  Let's\navoid implicit assumptions and introduce a constant for a default\ntemperature value and make the temperature value optional.\n\nThis is currently used by the CCM algorithm.  It will be used also by\nthe LSC algorithm in the followup patch.\n\nThe default temperature value of 6500 is just a common value, there is\nno special reason to use this or another value.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/ipa/simple/algorithms/awb.cpp | 4 ++--\n src/ipa/simple/algorithms/awb.h   | 4 +++-\n src/ipa/simple/algorithms/ccm.cpp | 5 ++++-\n src/ipa/simple/ipa_context.h      | 2 +-\n 4 files changed, 10 insertions(+), 5 deletions(-)","diff":"diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\nindex f5c88ea6f..961126c0d 100644\n--- a/src/ipa/simple/algorithms/awb.cpp\n+++ b/src/ipa/simple/algorithms/awb.cpp\n@@ -96,11 +96,11 @@ void Awb::process(IPAContext &context,\n \n \tRGB<double> rgbGains{ { 1 / gains.r(), 1 / gains.g(), 1 / gains.b() } };\n \tcontext.activeState.awb.temperatureK = estimateCCT(rgbGains);\n-\tmetadata.set(controls::ColourTemperature, context.activeState.awb.temperatureK);\n+\tmetadata.set(controls::ColourTemperature, context.activeState.awb.temperatureK.value_or(0));\n \n \tLOG(IPASoftAwb, Debug)\n \t\t<< \"gain R/B: \" << gains << \"; temperature: \"\n-\t\t<< context.activeState.awb.temperatureK;\n+\t\t<< context.activeState.awb.temperatureK.value_or(0);\n }\n \n REGISTER_IPA_ALGORITHM(Awb, \"Awb\")\ndiff --git a/src/ipa/simple/algorithms/awb.h b/src/ipa/simple/algorithms/awb.h\nindex ad993f39c..df46baee4 100644\n--- a/src/ipa/simple/algorithms/awb.h\n+++ b/src/ipa/simple/algorithms/awb.h\n@@ -1,6 +1,6 @@\n /* SPDX-License-Identifier: LGPL-2.1-or-later */\n /*\n- * Copyright (C) 2024-2025 Red Hat Inc.\n+ * Copyright (C) 2024-2026 Red Hat Inc.\n  *\n  * Auto white balance\n  */\n@@ -13,6 +13,8 @@ namespace libcamera {\n \n namespace ipa::soft::algorithms {\n \n+constexpr unsigned int kDefaultTemperature = 6500;\n+\n class Awb : public Algorithm\n {\n public:\ndiff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp\nindex 911a5af2c..6bac45006 100644\n--- a/src/ipa/simple/algorithms/ccm.cpp\n+++ b/src/ipa/simple/algorithms/ccm.cpp\n@@ -15,6 +15,8 @@\n \n #include \"libcamera/internal/matrix.h\"\n \n+#include \"awb.h\"\n+\n namespace {\n \n constexpr unsigned int kTemperatureThreshold = 100;\n@@ -44,7 +46,8 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData\n void Ccm::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t\t  IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)\n {\n-\tconst unsigned int ct = context.activeState.awb.temperatureK;\n+\tconst unsigned int ct =\n+\t\tcontext.activeState.awb.temperatureK.value_or(kDefaultTemperature);\n \n \t/* Change CCM only on bigger temperature changes. */\n \tif (!currentCcm_ ||\ndiff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\nindex 34f7403a4..c4bd91bb0 100644\n--- a/src/ipa/simple/ipa_context.h\n+++ b/src/ipa/simple/ipa_context.h\n@@ -50,7 +50,7 @@ struct IPAActiveState {\n \n \tstruct {\n \t\tRGB<float> gains;\n-\t\tunsigned int temperatureK;\n+\t\tstd::optional<unsigned int> temperatureK;\n \t} awb;\n \n \tMatrix<float, 3, 3> combinedMatrix;\n","prefixes":["RFC","v3","3/7"]}