{"id":20656,"url":"https://patchwork.libcamera.org/api/1.1/patches/20656/?format=json","web_url":"https://patchwork.libcamera.org/patch/20656/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","date":"2024-07-12T14:32:02","name":"[v1,1/5] ipa: rkisp1: awb: Clamp gains to machine limits","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4d89faacf130abb489ecb50da4b3c31fc963e9c2","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20656/mbox/","series":[{"id":4452,"url":"https://patchwork.libcamera.org/api/1.1/series/4452/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4452","date":"2024-07-12T14:32:01","name":"A few fixes for the rkisp1 ipa","version":1,"mbox":"https://patchwork.libcamera.org/series/4452/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20656/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20656/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 24944BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Jul 2024 14:32:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ABC6A63374;\n\tFri, 12 Jul 2024 16:32:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A074063369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Jul 2024 16:32:41 +0200 (CEST)","from ideasonboard.com (unknown [94.31.101.36])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CCCC6471;\n\tFri, 12 Jul 2024 16:32:06 +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=\"rDv3g0sS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720794726;\n\tbh=LCq8SKORXeGtsgkrM/bufoXzyT6SZprfYNLDGcaZQMQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=rDv3g0sSMj9s8hQh0aNe2fpKFkuf9zxS29koRB2l5cUfpgqygBU6pcxhnN6y8PBR1\n\t6Pbh9HbIiZcms/cown9ezOXYHTFRg2VI4laLzictu1YDYIg+6yden15XIjvnyX/Bd6\n\top/qJZL2ajlo2gXyrOSkjy6jEbHdbHfixBVMun5Y=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","Date":"Fri, 12 Jul 2024 16:32:02 +0200","Message-ID":"<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20240712143227.3036702-1-stefan.klug@ideasonboard.com>","References":"<20240712143227.3036702-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","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>"},"content":"When the color gains where set manually it was possible to specify a\ngain that wrapped the hardware limits. It would also be possible to\nfurther tune the floating point limits, but that is an error prone\napproach. So the limits are imposed on the integers, just before writing\nto the hardware. This noticeably reduces some oscillations in the awb\nregulation.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/awb.cpp | 12 ++++++++----\n 1 file changed, 8 insertions(+), 4 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex a01fe5d90973..1a5d4776970a 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -120,10 +120,14 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n \t\tframeContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue;\n \t}\n \n-\tparams->others.awb_gain_config.gain_green_b = 256 * frameContext.awb.gains.green;\n-\tparams->others.awb_gain_config.gain_blue = 256 * frameContext.awb.gains.blue;\n-\tparams->others.awb_gain_config.gain_red = 256 * frameContext.awb.gains.red;\n-\tparams->others.awb_gain_config.gain_green_r = 256 * frameContext.awb.gains.green;\n+\tparams->others.awb_gain_config.gain_green_b =\n+\t\tstd::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n+\tparams->others.awb_gain_config.gain_blue =\n+\t\tstd::clamp<int>(256 * frameContext.awb.gains.blue, 0, 0x3ff);\n+\tparams->others.awb_gain_config.gain_red =\n+\t\tstd::clamp<int>(256 * frameContext.awb.gains.red, 0, 0x3ff);\n+\tparams->others.awb_gain_config.gain_green_r =\n+\t\tstd::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n \n \t/* Update the gains. */\n \tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;\n","prefixes":["v1","1/5"]}