{"id":24844,"url":"https://patchwork.libcamera.org/api/patches/24844/?format=json","web_url":"https://patchwork.libcamera.org/patch/24844/","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":"<20251028-exposure-limits-v2-6-a8b5a318323e@ideasonboard.com>","date":"2025-10-28T09:31:52","name":"[v2,06/10] ipa: libipa: agc: Initialize exposure with frame duration","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f7dd5633e334c4983e8fc8f7f165333b02e41d98","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24844/mbox/","series":[{"id":5536,"url":"https://patchwork.libcamera.org/api/series/5536/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5536","date":"2025-10-28T09:31:46","name":"libipa: agc: Calculate exposure limits","version":2,"mbox":"https://patchwork.libcamera.org/series/5536/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24844/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24844/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 6026CBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Oct 2025 09:32:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 905A1607E9;\n\tTue, 28 Oct 2025 10:32:21 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 436A8607AA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Oct 2025 10:32:10 +0100 (CET)","from [192.168.0.172] (mob-5-90-58-13.net.vodafone.it [5.90.58.13])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A0F004B34; \n\tTue, 28 Oct 2025 10:30:21 +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=\"HQmdQ2lt\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761643822;\n\tbh=hotdbwOYqkfu27YSExC1g/AWsdly5yABlmUf2Zw8aRE=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=HQmdQ2lt2Mqoazis40z54zsqLuIc0oY32rVDHHKCi5MCFdg5VBtiMIs/zn4X0JqAM\n\tcUe66vk+PrNX8zrdP+Ke40qC0hnOD6bCGhuQTCB+TH4UCk4SezEtxUvTCoZwCaMBal\n\tPHV22/gTIcAwD7K3m0Sc0bwsl3CLPQojHwud/aLk=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Tue, 28 Oct 2025 10:31:52 +0100","Subject":"[PATCH v2 06/10] ipa: libipa: agc: Initialize exposure with frame\n\tduration","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20251028-exposure-limits-v2-6-a8b5a318323e@ideasonboard.com>","References":"<20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com>","In-Reply-To":"<20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com>","To":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tRobert Mader <robert.mader@collabora.com>, \n\tlibcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","X-Mailer":"b4 0.14.2","X-Developer-Signature":"v=1; a=openpgp-sha256; l=1945;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=hotdbwOYqkfu27YSExC1g/AWsdly5yABlmUf2Zw8aRE=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpAI2V0Bi8e8LraYeVr4SpKdZcuxzsXkAbhqqi6\n\tJ/YBDShUx2JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaQCNlQAKCRByNAaPFqFW\n\tPL4ZD/wJgVts1J6cz9EqxXKhzsbQXLwnL309WPbHfPPsExgKsk+Firh3WeiWPabWKF+Fijw0EwL\n\tPgAWjdyAP0baQ6VRBKavWfP0SwIHtA21ffQZHveZdi22bcOXDSqzh4rXhqvSQWSplaBJ3Z+0N40\n\tWwmIYezyo++IuTdORgcv9Glt86bas0ybvj0AnMBAJcSbLTlbdcVReMwWFkpsvDyoi+Ukryn3kBt\n\t4cc5uSg78LWm+/5Zsj2jdyOJrMySqvp7fioNolyboG+VpKa8UvYD5tU9K+tWP18BstlCFgpp969\n\t4k0RGdCecpqknWKiTsv0UgEiI6ths0GP8t72XDq8zuPR20Fy6tYvIha0OMGvGvzugW9vBSAZvNk\n\t/0EXhHnHhhwIiIXYYdYO5hp7kJbcUK5jsZiNgd3tbNQ1ejyyVjmmgnVmi/eU8C5nKuBAONbDD9P\n\tRkjFBcSiMF3PETA3VOlOFE8B/AkThCXAPDee9NoYxzU6I6u/GQULgjt6p/Ow2PlLHCvK3OuKoZj\n\tXToJagW9QFi1zMkXkmWycOfQVHSl6gMjq+awTn12T2Svr1Tcq2RDxW5ghOwTtB3voEDp6mGoj2c\n\tT1bz1ZehLppnPWBnCoyofz838r51+G785NiGKMY+Pmg94b9jeNpdgfgxGJA1Thp3PZq6dBK1Ug4\n\tQ5Tb539YNI0/a2w==","X-Developer-Key":"i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B","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":"The maximum exposure time the AGC algorithm can achieve is, by\ndefinition, limited by the maximum programmed frame duration.\n\nWhen initializing the AGC algorithm, use the frame duration and the\nsensor's exposure margin to calculate the maximum exposure, unless\nthe IPA has asked for a fixed exposure by setting min == max.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/libipa/exposure_mode_helper.cpp | 25 +++++++++++++++++++++++--\n 1 file changed, 23 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\nindex edb8f04b245f01119d0d0b0917d10f98c7172dc0..8f40290959e24294ead008c7228e2f67ffc5adf8 100644\n--- a/src/ipa/libipa/exposure_mode_helper.cpp\n+++ b/src/ipa/libipa/exposure_mode_helper.cpp\n@@ -106,12 +106,33 @@ void ExposureModeHelper::configure(utils::Duration lineDuration,\n \t\t\t\t   const CameraSensorHelper *sensorHelper)\n {\n \tlineDuration_ = lineDuration;\n-\tminExposureTime_ = minExposureTime;\n-\tmaxExposureTime_ = maxExposureTime;\n \tmaxFrameDuration_ = maxFrameDuration;\n \tminGain_ = minGain;\n \tmaxGain_ = maxGain;\n \tsensorHelper_ = sensorHelper;\n+\n+\tminExposureTime_ = minExposureTime;\n+\n+\t/*\n+\t * Compute the maximum exposure time.\n+\t *\n+\t * If maxExposureTime is equal to minExposureTime then we use them\n+\t * to fix the exposure time.\n+\t *\n+\t * Otherwise, if the exposure can range between a min and max, use the\n+\t * maxFrameDuration minus the margin as upper limit for exposure\n+\t * (capped to the provided max exposure).\n+\t */\n+\tauto margin = sensorHelper_->exposureMargin();\n+\tif (!margin.has_value()) {\n+\t\tLOG(ExposureModeHelper, Warning)\n+\t\t\t<< \"Exposure margin not known. Default to 4\";\n+\t\tmargin = { 4 };\n+\t}\n+\n+\tmaxExposureTime_ = minExposureTime != maxExposureTime\n+\t\t\t ? maxFrameDuration - margin.value() * lineDuration\n+\t\t\t : minExposureTime;\n }\n \n /**\n","prefixes":["v2","06/10"]}