{"id":24537,"url":"https://patchwork.libcamera.org/api/patches/24537/?format=json","web_url":"https://patchwork.libcamera.org/patch/24537/","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":"<20250930150428.11101-5-hansg@kernel.org>","date":"2025-09-30T15:04:26","name":"[v4,4/6] ipa: software_isp: AGC: Only use integers for exposure calculations","commit_ref":"b5c89375f9cf27f740f8244307157590e212648b","pull_url":null,"state":"accepted","archived":false,"hash":"681fcfaee193aaec20e9ba587f98474e77ccef40","submitter":{"id":239,"url":"https://patchwork.libcamera.org/api/people/239/?format=json","name":"Hans de Goede","email":"hansg@kernel.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24537/mbox/","series":[{"id":5470,"url":"https://patchwork.libcamera.org/api/series/5470/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5470","date":"2025-09-30T15:04:22","name":"ipa: software_isp: AGC: Fix AGC oscillation bug","version":4,"mbox":"https://patchwork.libcamera.org/series/5470/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24537/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24537/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 8A755C328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Sep 2025 15:04:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 29E206B621;\n\tTue, 30 Sep 2025 17:04:47 +0200 (CEST)","from sea.source.kernel.org (sea.source.kernel.org\n\t[IPv6:2600:3c0a:e001:78e:0:1991:8:25])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DDAEF6B5FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Sep 2025 17:04:41 +0200 (CEST)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 1548B43D82;\n\tTue, 30 Sep 2025 15:04:40 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 9C6A1C116C6;\n\tTue, 30 Sep 2025 15:04:38 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=kernel.org header.i=@kernel.org\n\theader.b=\"Uqh+aJVk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1759244679;\n\tbh=EJWoEApCSoUNGJ78tbGabNYw6JtT8v2fsDNctWXc/2Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Uqh+aJVkjTQT234V5BOXLTYh0texLpotbyjja0rt3pRCeJbcw0vb1ZhbjRJr/Zpm4\n\t8sLADo4f3z4vX5J1ux62hOwBn2kZvA3krGmixGBViep0UmkGwvBMmEOhF41sycO1sM\n\tF3uJ+spfKBmfsEL2I1v6KwSTZZ4QBaFmgUtxbn2CMb0egXPfnQzgINhOhjezE5TKBr\n\tb3vNxIrrfcBUmmeWMB8NHUdLHUx/YTVBBxW8HaE2glpAAfU0wU72XXS+w23zuTpzyn\n\tRbt+qAD1X8c+W4G7NlUOzW/xVBI1lVZRyQUpMx/f1nYKNW8uw1/i/3SXNlywlfC3DH\n\tM7pn3ew7h5Wkg==","From":"Hans de Goede <hansg@kernel.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"Hans de Goede <hansg@kernel.org>, Milan Zamazal <mzamazal@redhat.com>,\n\tIsaac Scott <isaac.scott@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH v4 4/6] ipa: software_isp: AGC: Only use integers for\n\texposure calculations","Date":"Tue, 30 Sep 2025 17:04:26 +0200","Message-ID":"<20250930150428.11101-5-hansg@kernel.org>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20250930150428.11101-1-hansg@kernel.org>","References":"<20250930150428.11101-1-hansg@kernel.org>","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":"Exposure is an integer, instead of re-using the \"double next\" used\nfor again calculations, doing intermediate calculations with double\nprecision, use a local next variable of an integer type.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\nTested-by: Milan Zamazal <mzamazal@redhat.com>\nTested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Hans de Goede <hansg@kernel.org>\n---\n src/ipa/simple/algorithms/agc.cpp | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)","diff":"diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp\nindex f7f734514..3471cc881 100644\n--- a/src/ipa/simple/algorithms/agc.cpp\n+++ b/src/ipa/simple/algorithms/agc.cpp\n@@ -51,19 +51,18 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n \tstatic constexpr uint8_t kExpNumeratorUp = kExpDenominator + 1;\n \tstatic constexpr uint8_t kExpNumeratorDown = kExpDenominator - 1;\n \n-\tdouble next;\n \tint32_t &exposure = frameContext.sensor.exposure;\n \tdouble &again = frameContext.sensor.gain;\n \n \tif (exposureMSV < kExposureOptimal - kExposureSatisfactory) {\n \t\tif (exposure < context.configuration.agc.exposureMax) {\n-\t\t\tnext = exposure * kExpNumeratorUp / kExpDenominator;\n+\t\t\tint32_t next = exposure * kExpNumeratorUp / kExpDenominator;\n \t\t\tif (next - exposure < 1)\n \t\t\t\texposure += 1;\n \t\t\telse\n \t\t\t\texposure = next;\n \t\t} else {\n-\t\t\tnext = again * kExpNumeratorUp / kExpDenominator;\n+\t\t\tdouble next = again * kExpNumeratorUp / kExpDenominator;\n \t\t\tif (next - again < context.configuration.agc.againMinStep)\n \t\t\t\tagain += context.configuration.agc.againMinStep;\n \t\t\telse\n@@ -73,13 +72,13 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou\n \n \tif (exposureMSV > kExposureOptimal + kExposureSatisfactory) {\n \t\tif (again > context.configuration.agc.again10) {\n-\t\t\tnext = again * kExpNumeratorDown / kExpDenominator;\n+\t\t\tdouble next = again * kExpNumeratorDown / kExpDenominator;\n \t\t\tif (again - next < context.configuration.agc.againMinStep)\n \t\t\t\tagain -= context.configuration.agc.againMinStep;\n \t\t\telse\n \t\t\t\tagain = next;\n \t\t} else {\n-\t\t\tnext = exposure * kExpNumeratorDown / kExpDenominator;\n+\t\t\tint32_t next = exposure * kExpNumeratorDown / kExpDenominator;\n \t\t\tif (exposure - next < 1)\n \t\t\t\texposure -= 1;\n \t\t\telse\n","prefixes":["v4","4/6"]}