{"id":25059,"url":"https://patchwork.libcamera.org/api/patches/25059/?format=json","web_url":"https://patchwork.libcamera.org/patch/25059/","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":"<20251114-exposure-limits-v3-7-b7c07feba026@ideasonboard.com>","date":"2025-11-14T14:17:02","name":"[v3,07/19] ipa: camera_sensor_helper: Introduce minFrameDuration()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"954183bb989154b718e9b9b1ba021a40ec10f35c","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/25059/mbox/","series":[{"id":5590,"url":"https://patchwork.libcamera.org/api/series/5590/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5590","date":"2025-11-14T14:16:55","name":"libipa: agc: Calculate exposure limits","version":3,"mbox":"https://patchwork.libcamera.org/series/5590/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25059/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25059/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 C268CC3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 14:17:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 519F760B0C;\n\tFri, 14 Nov 2025 15:17:29 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 626B0606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 15:17:20 +0100 (CET)","from [192.168.1.101] (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6BA4516A8;\n\tFri, 14 Nov 2025 15:15:19 +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=\"fGbxdtTd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763129719;\n\tbh=fNhOjrRZ0+5i+LCbzY00gFZZx32gNfi6ytAYY93//5Y=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=fGbxdtTdWkFUW8Dq5eq7KVwzyJVm9mSDofb9U0WKTrqmt/qGI8SUF3VCOyWwucMd3\n\tbV5PS7WFQArBkM3kCH3Uy16cdj7ysLm2Oat7ZfBkZ2q/GfQS2rR1ia71vn5l9UcdGS\n\tPy5u4htiDt28laG9MzdOXlXhbr0uRtKwvkMBRjZI=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Fri, 14 Nov 2025 15:17:02 +0100","Subject":"[PATCH v3 07/19] ipa: camera_sensor_helper: Introduce\n\tminFrameDuration()","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20251114-exposure-limits-v3-7-b7c07feba026@ideasonboard.com>","References":"<20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com>","In-Reply-To":"<20251114-exposure-limits-v3-0-b7c07feba026@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=3332;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=fNhOjrRZ0+5i+LCbzY00gFZZx32gNfi6ytAYY93//5Y=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpFznriHKLuoteRA/oX9HiveLoN0B4nbqTNYnig\n\tPOhdRNQ/taJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaRc56wAKCRByNAaPFqFW\n\tPOm8D/97fthPNErIDv8KE2BD2C0Lkq0IocUJEkRT1l91qInraR6/APwpLDFuFD6uhqVAJhOod2O\n\t7Zl+r6241S/fQc+0xoaCUg0PcmLMGZl50XyvtslB53HTA6MCpcFEqaFcMaAqeb7myE17aT6y29c\n\tDjILXJIIXMeh3RctDqQlzUMi15HuyPojJoFSAzEc5hRn9jxiot4VHydUylVVyJMkLZMU1qyakPv\n\tcqBuETVjHZZegb3Osg1e7IiEom5bL7KEr42OG1kWeAZnCMXTeH7+qgCL+Oul9yQPneSGmGQWnXD\n\tYY25iTw7iE9ENTsSCLlZFvAQWeQ4oPqqZdtpdIfToNTylw2ykjYFkhBgfGWeQR6o3bTAbCKH3kv\n\tK4QihJisaxMqtS4dk8BiqChjMnBVuzvQhwpj8WF7rv6scLDfZhWBGHR2y01C+4N9uuPsOuVwbAp\n\tFyvIZQ4Z2EcGdkHZGtrYY0WDunk6F1+Um51WSXg84hgBAzkJ1augTJXKT19BXFv/RYbsiukPe2/\n\tBGzP/lY5FSoQ1FIu8XyIOkujjm5HsG9YsaDsTzLYe4cFs3ZOCTKMuWMzbonVjk3Y4T1ih9RvfOb\n\tn/qHZ8LLZ0tyTj7CzPyVnStCb2aTkILahsHx9lNDBmpLwN2V+wEgk+xiVb+8SJourCqv3YCR2NF\n\tgBAhC8g3psnwjJw==","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":"After having introduced CameraSensorHelper::maxShutterTime() which\ncalculates the maximum shutter time which can be achieved given\na frame duration, this patch introduces the opposite operation, that\ngiven a desired shutter time calculates what is the minimum frame\nduration required to achieve it.\n\nThe intended users of this function are IPA modules that after having\ncalculated a new exposure time need to regulate the frame duration to\nachieve it.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/libipa/camera_sensor_helper.cpp | 33 +++++++++++++++++++++++++++++++++\n src/ipa/libipa/camera_sensor_helper.h   |  2 ++\n 2 files changed, 35 insertions(+)","diff":"diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\nindex 3c3e24c1cdefa4bca059352482bb29654a37b42f..a38f1eb40446b98a0db4642f086742674a13854f 100644\n--- a/src/ipa/libipa/camera_sensor_helper.cpp\n+++ b/src/ipa/libipa/camera_sensor_helper.cpp\n@@ -184,6 +184,39 @@ utils::Duration CameraSensorHelper::maxShutterTime(utils::Duration maxFrameDurat\n \treturn maxFrameDuration - exposureMargin * lineDuration;\n }\n \n+/**\n+ * \\brief Compute the minimum frame duration required for a desired exposure\n+ * \\param[in] shutterTime The shutter time\n+ * \\param[in] lineDuration The current sensor line duration\n+ *\n+ * This function returns the minimum frame duration required to achieve the\n+ * desired \\a shutterTime. The frame duration is calculated by adding to\n+ * \\a shutterTime the difference between the frame length and the maximum\n+ * achievable integration time.\n+ *\n+ * The intended users of this function are IPA modules that want to calculate\n+ * the minium required frame duration give a newly calculated shutter time.\n+ *\n+ * \\todo The line duration should be a property of the CameraSensorHelper class\n+ * instead of being provided by the IPA.\n+ *\n+ * \\return The minimum frame duration required to achieve the desired shutter\n+ * time\n+ */\n+utils::Duration CameraSensorHelper::minFrameDuration(utils::Duration shutterTime,\n+\t\t\t\t\t\t     utils::Duration lineDuration) const\n+{\n+\t/* Use a static to rate-limit the error message. */\n+\tstatic uint32_t exposureMargin = exposureMargin_.has_value()\n+\t\t\t\t       ? exposureMargin_.value() : 0;\n+\tif (!exposureMargin_.has_value() && !exposureMargin) {\n+\t\tLOG(CameraSensorHelper, Warning)\n+\t\t\t<< \"Exposure margin not known. Default to 4\";\n+\t\texposureMargin = 4;\n+\t}\n+\n+\treturn shutterTime + exposureMargin * lineDuration;\n+}\n /**\n  * \\struct CameraSensorHelper::AnalogueGainLinear\n  * \\brief Analogue gain constants for the linear gain model\ndiff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\nindex a1cf4bc334ad3b9a51d26b345bd5f0630c7ae87c..e9b53f183e8e6d305b50b5f3b46dc0199efee018 100644\n--- a/src/ipa/libipa/camera_sensor_helper.h\n+++ b/src/ipa/libipa/camera_sensor_helper.h\n@@ -33,6 +33,8 @@ public:\n \tdouble quantizeGain(double gain, double *quantizationGain) const;\n \tutils::Duration maxShutterTime(utils::Duration maxFrameDuration,\n \t\t\t\t       utils::Duration lineDuration) const;\n+\tutils::Duration minFrameDuration(utils::Duration exposureTime,\n+\t\t\t\t\t utils::Duration lineDuration) const;\n \n protected:\n \tstruct AnalogueGainLinear {\n","prefixes":["v3","07/19"]}