{"id":23056,"url":"https://patchwork.libcamera.org/api/1.1/patches/23056/?format=json","web_url":"https://patchwork.libcamera.org/patch/23056/","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":"<20250326134727.279393-3-stefan.klug@ideasonboard.com>","date":"2025-03-26T13:47:21","name":"[v2,2/3] ipa: libipa: agc_mean_luminance: Error out when effectiveExposureValue is zero","commit_ref":"03bae6b9248280a3edd9350061cc307d95ba1cd0","pull_url":null,"state":"accepted","archived":false,"hash":"5a479faee285c277388226eda5fbe0de26c0d6bf","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/23056/mbox/","series":[{"id":5086,"url":"https://patchwork.libcamera.org/api/1.1/series/5086/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5086","date":"2025-03-26T13:47:19","name":"rkisp1: Reduce oscillations on startup","version":2,"mbox":"https://patchwork.libcamera.org/series/5086/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23056/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23056/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 41EADC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Mar 2025 13:48:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F2B4E68970;\n\tWed, 26 Mar 2025 14:48:10 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A66468967\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Mar 2025 14:48:06 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:b21a:42f4:9f3:1df6])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 95BF699F;\n\tWed, 26 Mar 2025 14:46:18 +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=\"tnsDth5l\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742996778;\n\tbh=6luTqO35Q4YvGzgS3ENS17inTWGD0bIMd/vgI/zWHBk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=tnsDth5lpBrhdxYgbFHR8lpiLMoOldlzpdElwzH0qLEXjNJBxqn6FQ+lFB2fTpZug\n\tqlrMVfnv9nHMtHHjKrhdAsHFbJZSsOUvlS8EePDLnWpGPAdo6ntf+lLSdE8R9hkrlI\n\t14O4Md+wFIXAN3glrBZEoyfzicHZuOhzuArAFa3s=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>","Subject":"[PATCH v2 2/3] ipa: libipa: agc_mean_luminance: Error out when\n\teffectiveExposureValue is zero","Date":"Wed, 26 Mar 2025 14:47:21 +0100","Message-ID":"<20250326134727.279393-3-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20250326134727.279393-1-stefan.klug@ideasonboard.com>","References":"<20250326134727.279393-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":"In a proper system it never happens that the effectiveExposureValue\ndrops to zero. If that still happens due to a bug outside of\nagc_mean_luminance, the calculated gain goes towards infinity but the\nnewExposureValue is still 0 because it is the result of multiplying the\neffectiveExposureTime with the gain, leading to wild oscillations.\n\nCatch that condition, print an error message and set the new effective\nexposure value to an arbitrary 10ms.\n\nNote that in any case the underlying problem must be fixed. The\nimportant change is the added error message to be able to detect such a\nsituation.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\n---\n\nChanges in v2:\n- Collected tags\n- Improved log message wording\n- Added comment on the arbitrary exposure time\n---\n src/ipa/libipa/agc_mean_luminance.cpp | 12 ++++++++++++\n 1 file changed, 12 insertions(+)","diff":"diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex 02555a44d271..f617fde81101 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -541,6 +541,18 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n \tstd::shared_ptr<ExposureModeHelper> exposureModeHelper =\n \t\texposureModeHelpers_.at(exposureModeIndex);\n \n+\tif (effectiveExposureValue == 0s) {\n+\t\tLOG(AgcMeanLuminance, Error)\n+\t\t\t<< \"Effective exposure value is 0. This is a bug in AGC \"\n+\t\t\t   \"and must be fixed for proper operation.\";\n+\t\t/*\n+\t\t * Return an arbitrary exposure time > 0 to ensure regulation\n+\t\t * doesn't get stuck with 0 in case the sensor driver allows a\n+\t\t * min exposure of 0.\n+\t\t */\n+\t\treturn exposureModeHelper->splitExposure(10ms);\n+\t}\n+\n \tdouble gain = estimateInitialGain();\n \tgain = constraintClampGain(constraintModeIndex, yHist, gain);\n \n","prefixes":["v2","2/3"]}