[{"id":38937,"web_url":"https://patchwork.libcamera.org/comment/38937/","msgid":"<9f2d8c0c-5cb3-4a7d-b1eb-94c23f5f9bfe@ideasonboard.com>","date":"2026-05-20T10:47:31","subject":"Re: [PATCH v1] ipa: rpi: agc: Clamp digital gain to avoid saturation\n\tissues","submitter":{"id":274,"url":"https://patchwork.libcamera.org/api/people/274/","name":"Alen Karnil","email":"alen.karnil@ideasonboard.com"},"content":"Hi David,\n\nThanks for the patch,\n\nOn 20/05/2026 09:44, David Plowman wrote:\n> Digital gain is used to adjust overall image exposure when the target\n> exposure cannot be achieved (for example, cannot go high enough). But\n> when the target exposure is lower than we can achieve, the digital\n> gain was being set to values less than unity, causing saturation\n> problems.\n> \n> The fix is simply to clamp the digital gain at the bottom to 1.0,\n> resulting in images that, while \"too bright\", saturate correctly.\n> \n\nI've tested this on the OV64A40 and can confirm this fixes the issue seen.\n\nI think it needs a fixes tag:\nFixes: 17f9912cff (ipa: rpi: agc: Calculate digital gain in process())\n\nReviewed-by: Alen Karnil <alen.karnil@ideasonboard.com>\nTested-by: Alen Karnil <alen.karnil@ideasonboard.com>\n\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>   src/ipa/rpi/controller/rpi/agc_channel.cpp | 4 ++--\n>   1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> index cf0e77bd..c9462eed 100644\n> --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> @@ -941,8 +941,8 @@ void AgcChannel::divideUpExposure()\n>   \t/* Finally work out the digital gain that we will need. */\n>   \tfiltered_.totalExposureNoDG = analogueGain * exposureTime;\n>   \tdouble digitalGain = filtered_.totalExposure / filtered_.totalExposureNoDG;\n> -\t/* Limit dg by what is allowed. */\n> -\tdigitalGain = std::min(digitalGain, config_.maxDigitalGain);\n> +\t/* Limit dg by what is allowed (and to 1.0 to avoid saturation issues). */\n> +\tdigitalGain = std::clamp(digitalGain, 1.0, config_.maxDigitalGain);\n>   \t/* Update total exposure, in case the dg went down. */\n>   \tfiltered_.totalExposure = filtered_.totalExposureNoDG * digitalGain;\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 DAB03BDCBC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 May 2026 10:47:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A52A162FEC;\n\tWed, 20 May 2026 12:47:35 +0200 (CEST)","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 C6BBB62E9D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2026 12:47:34 +0200 (CEST)","from [IPV6:2a01:cb1d:8f2:800:9c9e:9f0d:69d:9264] (unknown\n\t[IPv6:2a01:cb1d:8f2:800:9c9e:9f0d:69d:9264])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 16728E9C;\n\tWed, 20 May 2026 12:47:21 +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=\"rJSsKl4s\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1779274041;\n\tbh=OXrXxjU90gyNVv4y0SN6+hWthXUyN3YGnDLa8acJ9E0=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=rJSsKl4sOzi3Dhc+aOl/sbx2jmNrK0nNB3vAPW2bq9EDCCNApw3ms9QwC+Eq+zeg7\n\t7KJeQ0ZFeuK6smc7rzOckcKLhaMyMG+Su4TlEb1gJI5uU0qyGp4d+J+XbPZQ6d3BAn\n\tGUz8fLSlKLcEbOFOURmJe7Gq+8lxc8YtnNhWAhKA=","Message-ID":"<9f2d8c0c-5cb3-4a7d-b1eb-94c23f5f9bfe@ideasonboard.com>","Date":"Wed, 20 May 2026 11:47:31 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1] ipa: rpi: agc: Clamp digital gain to avoid saturation\n\tissues","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260520084631.3440-1-david.plowman@raspberrypi.com>","Content-Language":"en-US","From":"Alen Karnil <alen.karnil@ideasonboard.com>","Autocrypt":"addr=alen.karnil@ideasonboard.com; keydata=\n\txjMEafxhCxYJKwYBBAHaRw8BAQdAXswEEnvxYiHXb8Q8GsSAuaLuXqJFs3kmsMI7EWF9EuDN\n\tNUFsZW4gS2FybmlsIChXb3JrIElvQikgPGFsZW4ua2FybmlsQGlkZWFzb25ib2FyZC5jb20+\n\twpkEExYKAEEWIQT0whyXpTyoVtApVAlRzoJ78NRPngUCagGrrgIbAwUJBaOagAULCQgHAgIi\n\tAgYVCgkICwIEFgIDAQIeBwIXgAAKCRBRzoJ78NRPnkpDAP4kmtHsMfTtV6BC1z7GTb86BL2g\n\t9FC1EarGJDDzcafMGQEA6clsoXvRYjHPJexVebjmkI4bq1QM0X/L9Ffe0PfpdQbOOARp/GEL\n\tEgorBgEEAZdVAQUBAQdAsVoGZ4IK0EgJ8HU05PQKzK15jaCi/IEA/7Cw9ZzcBmwDAQgHwn4E\n\tGBYKACYWIQT0whyXpTyoVtApVAlRzoJ78NRPngUCafxhCwIbDAUJBaOagAAKCRBRzoJ78NRP\n\tnqYcAP0eh3LahCDsfNa8zsiK+8QzeujWPKhc5zDcIqrDI6xufwD+Mu9e202It54rNZb8UWEy\n\tV5OzTEy0JlsQfO6DYWIORwI=","In-Reply-To":"<20260520084631.3440-1-david.plowman@raspberrypi.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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":38938,"web_url":"https://patchwork.libcamera.org/comment/38938/","msgid":"<CAHW6GYJvC9hpg9KqrV3fWV5z5uzChs3K5+F03dQYuTNsNJEuwg@mail.gmail.com>","date":"2026-05-20T10:53:18","subject":"Re: [PATCH v1] ipa: rpi: agc: Clamp digital gain to avoid saturation\n\tissues","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Alen\n\nThanks for the review, and sorry if there's been some duplicated work there.\n\nOn Wed, 20 May 2026 at 11:47, Alen Karnil <alen.karnil@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thanks for the patch,\n>\n> On 20/05/2026 09:44, David Plowman wrote:\n> > Digital gain is used to adjust overall image exposure when the target\n> > exposure cannot be achieved (for example, cannot go high enough). But\n> > when the target exposure is lower than we can achieve, the digital\n> > gain was being set to values less than unity, causing saturation\n> > problems.\n> >\n> > The fix is simply to clamp the digital gain at the bottom to 1.0,\n> > resulting in images that, while \"too bright\", saturate correctly.\n> >\n>\n> I've tested this on the OV64A40 and can confirm this fixes the issue seen.\n>\n> I think it needs a fixes tag:\n> Fixes: 17f9912cff (ipa: rpi: agc: Calculate digital gain in process())\n>\n> Reviewed-by: Alen Karnil <alen.karnil@ideasonboard.com>\n> Tested-by: Alen Karnil <alen.karnil@ideasonboard.com>\n\nI'm hoping all those tags can be added while merging the patch?\nOtherwise I can always send an update.\n\nThanks!\n\nDavid\n\n>\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >   src/ipa/rpi/controller/rpi/agc_channel.cpp | 4 ++--\n> >   1 file changed, 2 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> > index cf0e77bd..c9462eed 100644\n> > --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> > +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> > @@ -941,8 +941,8 @@ void AgcChannel::divideUpExposure()\n> >       /* Finally work out the digital gain that we will need. */\n> >       filtered_.totalExposureNoDG = analogueGain * exposureTime;\n> >       double digitalGain = filtered_.totalExposure / filtered_.totalExposureNoDG;\n> > -     /* Limit dg by what is allowed. */\n> > -     digitalGain = std::min(digitalGain, config_.maxDigitalGain);\n> > +     /* Limit dg by what is allowed (and to 1.0 to avoid saturation issues). */\n> > +     digitalGain = std::clamp(digitalGain, 1.0, config_.maxDigitalGain);\n> >       /* Update total exposure, in case the dg went down. */\n> >       filtered_.totalExposure = filtered_.totalExposureNoDG * digitalGain;\n> >\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 F0584BDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 May 2026 10:53:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1CA7763029;\n\tWed, 20 May 2026 12:53:30 +0200 (CEST)","from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com\n\t[IPv6:2a00:1450:4864:20::52e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6454262E9D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2026 12:53:29 +0200 (CEST)","by mail-ed1-x52e.google.com with SMTP id\n\t4fb4d7f45d1cf-67bb5ad91bfso10547013a12.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2026 03:53:29 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"olTy6Hz4\"; dkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1779274409; cv=none;\n\td=google.com; s=arc-20240605;\n\tb=eh9SVgSiSqadLPc7H6tkm5HSdMY75NizJ4kHGoS9Ifbm8OM9M7BZPKFEuNtd25iWD6\n\thzPgB3zvAh7ZATQKSpu0JouYBrYPTs/BzFJr/18Qg8J45uOik9gdUbfjJtfFBd6KjQtX\n\tPutHsfBbwinhf5YcNC4Ru0SfOgrkdw+qUEXlU49y/Gw4Kk1ipX3m5bhutFBQUplN/xZ5\n\t0SwczJi3rqzUr3UUoQlkNR7X2XBqFUFCjoodYEy3TTv5BXCK1Mq1TKadTO7MSZ+STMtj\n\tx06nmPXyyOMR//v+lzbN/QLE7N2rziV3mE126QG4lILwK5t8nO3Orb2AFbsTxoWLsxJV\n\tEb0w==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20240605; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:dkim-signature;\n\tbh=71RFmWdUbJMQEsonmhyUlbXPDcZ0pfYRXTcNzG0UkfY=;\n\tfh=VFdHAEGNXrKKdErRMtq9MBk1lQ8QOpL4Pw2ugcGVg9c=;\n\tb=bNq0JeHbw6Nw0kLLrhlAjS/F14VgkKgwG1xDvxTzWU2NHMxcxPa0wQV0UW4NozRkZH\n\tSoJ2Hh9aZ+OiCpo6Eiu1bkhxyVk5/vOfXsFSgPtEyHAv96NY9k04H7Nmi6lAEi5d9HCC\n\tvLk6ACgg3demC7rjbxYYNea7F7L1M/dAmUn59Ufl928q/UGHHr0wYpBJA4oDvQLRRYKp\n\t+HGbFKDM0vV1qzUdicuTFij7em8w5Mwx70WpD5dhER0sdgOhUqFiSuRxwIFwXgpg3CQn\n\tHBYa6K3IjVBefol9Uoq7Cj7GSjSc5lJMoadCgPRultCGk5z8ojQ11T6i17xar1hwt1gn\n\tw9mw==; darn=lists.libcamera.org","ARC-Authentication-Results":"i=1; mx.google.com; arc=none","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1779274409; x=1779879209;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=71RFmWdUbJMQEsonmhyUlbXPDcZ0pfYRXTcNzG0UkfY=;\n\tb=olTy6Hz4uqvjYZo+4S+qWx8KjRhMaj55/wA/6s+oiyn098Zz2xyHecMqahQggD3wfy\n\tv4s1gijQkJJyVanpcVWESUxx90v7sJP0jMRyc4cjNuhmlW735OMonWHG3CyexrW1XVB9\n\tmSDy1du5d1/1C1lhcs1iCPFUCZyOVhBGedgV5yZD+m5W0IBDn2DWl/GPemyrA3o/G/mV\n\toKOTFJuF5nuTkZqI6R0YgUrkHvQL4dkeXc6vXCcseqVVzO0A9p5Y1JTV0WL+u+LDOWdo\n\td3QBInNxzp9VoGCnnUE3GRM2NgGlK9zQYvBXZRyllcf5vFu2OlMIwG69H0JYB2N2UjGn\n\tVWhg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1779274409; x=1779879209;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=71RFmWdUbJMQEsonmhyUlbXPDcZ0pfYRXTcNzG0UkfY=;\n\tb=XdQC/DDVt0slYGmiqG3cqti4qki/znk6Oe/rKAK0kaQzRDpLAqtuy46ruzvx7+zjB1\n\tOV1RmrEwVBrzpi37Vlbc1KybCd1D5J2c6P2uuQcX3u0pn4K6xxSprDl2ZqBAt+3Ycj6+\n\tVlY9XucUNxcDbJCOpn/HjL7u/RrggxyZtrXis6uDy4xks9Kl5f+uxsDQtaf+O4KnihEy\n\t9DF9C9HblC02O8grRwYiCTb0Ax2oNV7ftSyLafF4B9077uB67rgBIjjlNBAXiyZE2fQe\n\tpQh/n/QkKDWWz55rrycQEnuS8HoA4VzpQQQF7zl8E95voxI6NKnSwJyyDUyzrqT+OWFN\n\ttJaQ==","X-Gm-Message-State":"AOJu0YycD+3K7LkqXNI05fti7NfGzsbiBczCWHaFufCXlT0xRWHg5/oL\n\tFBjdvwb3j0fASB36KUsWm+mBCN4TwqNfCDuc7WDsH+ynxT5XtyzSuCl7Sc0Et6vXS/wcr0L0/Nd\n\tW6KaJoXiGM8yySZLbbRei1a1y0YtuG92qGddXSRL3ZQ==","X-Gm-Gg":"Acq92OHJMbm5CWw+QIlxPRQlkUv/6e9BcFT/aJ8YRcaaPKTUu7Xri1JwjEQYTb5vqco\n\tW53nbWqnUdZmM8ta+6kaqd/Ti5tTIwr/fiGA5kUqA1NNiEyPv1AlymLyk4iQF2zwTe/bpcODf/h\n\tAapyotKzxd17lf8wdfoOYdxtfo5P+Z0fR9zd6EztXNtt9/tpapfl7oxFDfOZPiZnST2PdOnL1ul\n\tZFKBv8hpue5XiuM5KsRdsVBoHEYUtdpI//T+9kpWKkkQM+Nyg1Dvdeq7Yoo9kyxh/X5oroZS58L\n\tNoIGMorMWf16jJhE6TGZLtp288Fdfww8x3PX3n7BFz9nBUCvGI57B5fyQjeH+2ZXgX/9DTx4VN4\n\tttCiqjoT+onkxGoqd5qQCMfGN","X-Received":"by 2002:a17:907:1c22:b0:bd9:cf0c:93c0 with SMTP id\n\ta640c23a62f3a-bd9cf0c9783mr340818966b.1.1779274408734;\n\tWed, 20 May 2026 03:53:28 -0700 (PDT)","MIME-Version":"1.0","References":"<20260520084631.3440-1-david.plowman@raspberrypi.com>\n\t<9f2d8c0c-5cb3-4a7d-b1eb-94c23f5f9bfe@ideasonboard.com>","In-Reply-To":"<9f2d8c0c-5cb3-4a7d-b1eb-94c23f5f9bfe@ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Wed, 20 May 2026 11:53:18 +0100","X-Gm-Features":"AVHnY4JiNSzCbeFQHfXfMr1JXc1R7pAsUlnG1amkN-TW74CBtfevNVWpUP7pSSY","Message-ID":"<CAHW6GYJvC9hpg9KqrV3fWV5z5uzChs3K5+F03dQYuTNsNJEuwg@mail.gmail.com>","Subject":"Re: [PATCH v1] ipa: rpi: agc: Clamp digital gain to avoid saturation\n\tissues","To":"Alen Karnil <alen.karnil@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","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":38939,"web_url":"https://patchwork.libcamera.org/comment/38939/","msgid":"<177927616181.908105.654952141672299395@ping.linuxembedded.co.uk>","date":"2026-05-20T11:22:41","subject":"Re: [PATCH v1] ipa: rpi: agc: Clamp digital gain to avoid saturation\n\tissues","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting David Plowman (2026-05-20 11:53:18)\n> Hi Alen\n> \n> Thanks for the review, and sorry if there's been some duplicated work there.\n\nNo worries, it's all a team effort.\n\n> On Wed, 20 May 2026 at 11:47, Alen Karnil <alen.karnil@ideasonboard.com> wrote:\n> >\n> > Hi David,\n> >\n> > Thanks for the patch,\n> >\n> > On 20/05/2026 09:44, David Plowman wrote:\n> > > Digital gain is used to adjust overall image exposure when the target\n> > > exposure cannot be achieved (for example, cannot go high enough). But\n> > > when the target exposure is lower than we can achieve, the digital\n> > > gain was being set to values less than unity, causing saturation\n> > > problems.\n> > >\n> > > The fix is simply to clamp the digital gain at the bottom to 1.0,\n> > > resulting in images that, while \"too bright\", saturate correctly.\n> > >\n> >\n> > I've tested this on the OV64A40 and can confirm this fixes the issue seen.\n> >\n> > I think it needs a fixes tag:\n> > Fixes: 17f9912cff (ipa: rpi: agc: Calculate digital gain in process())\n> >\n> > Reviewed-by: Alen Karnil <alen.karnil@ideasonboard.com>\n> > Tested-by: Alen Karnil <alen.karnil@ideasonboard.com>\n> \n> I'm hoping all those tags can be added while merging the patch?\n> Otherwise I can always send an update.\n\nAbsolutely, I can handle that while applying. I think this one is\nnow well tested which I've seen with my own eyes, and I believe this is\naccurate for all sensors:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nAnd I'll kick the ci for test and merge.\n\nThanks all.\n\n--\nRegards\n\nKieran\n\n\n> \n> Thanks!\n> \n> David\n> \n> >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >   src/ipa/rpi/controller/rpi/agc_channel.cpp | 4 ++--\n> > >   1 file changed, 2 insertions(+), 2 deletions(-)\n> > >\n> > > diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> > > index cf0e77bd..c9462eed 100644\n> > > --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> > > +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n> > > @@ -941,8 +941,8 @@ void AgcChannel::divideUpExposure()\n> > >       /* Finally work out the digital gain that we will need. */\n> > >       filtered_.totalExposureNoDG = analogueGain * exposureTime;\n> > >       double digitalGain = filtered_.totalExposure / filtered_.totalExposureNoDG;\n> > > -     /* Limit dg by what is allowed. */\n> > > -     digitalGain = std::min(digitalGain, config_.maxDigitalGain);\n> > > +     /* Limit dg by what is allowed (and to 1.0 to avoid saturation issues). */\n> > > +     digitalGain = std::clamp(digitalGain, 1.0, config_.maxDigitalGain);\n> > >       /* Update total exposure, in case the dg went down. */\n> > >       filtered_.totalExposure = filtered_.totalExposureNoDG * digitalGain;\n> > >\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 CFBB9BDCBC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 May 2026 11:22:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1EDC62FEA;\n\tWed, 20 May 2026 13:22:46 +0200 (CEST)","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 EC44262FD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 May 2026 13:22:44 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 40DC2E9C;\n\tWed, 20 May 2026 13:22:31 +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=\"Bm0zWItY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1779276151;\n\tbh=DbESZJPw7Z/274KRuZeskHDeamjCM4n81j8ZR82ydMA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Bm0zWItYI4/Hruex/yaqrIAmKN/Cx8DJXuDWxoNeeWCWPPAqo7fghXI2SJm9JVXb5\n\tviphUM9nS56ic6wmMU1cgXWmujznZ+AzT+WH4bLhszNLHeqmJGn48MLi2GJCZ1nXWc\n\t5TVgOwnG8e1onviqfzKgvKPdFJI/YUy9Mawm+8/0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<CAHW6GYJvC9hpg9KqrV3fWV5z5uzChs3K5+F03dQYuTNsNJEuwg@mail.gmail.com>","References":"<20260520084631.3440-1-david.plowman@raspberrypi.com>\n\t<9f2d8c0c-5cb3-4a7d-b1eb-94c23f5f9bfe@ideasonboard.com>\n\t<CAHW6GYJvC9hpg9KqrV3fWV5z5uzChs3K5+F03dQYuTNsNJEuwg@mail.gmail.com>","Subject":"Re: [PATCH v1] ipa: rpi: agc: Clamp digital gain to avoid saturation\n\tissues","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Alen Karnil <alen.karnil@ideasonboard.com>,\n\tDavid Plowman <david.plowman@raspberrypi.com>","Date":"Wed, 20 May 2026 12:22:41 +0100","Message-ID":"<177927616181.908105.654952141672299395@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]