[{"id":38121,"web_url":"https://patchwork.libcamera.org/comment/38121/","msgid":"<177039184628.607498.1382127475085964976@neptunite.rasen.tech>","date":"2026-02-06T15:30:46","subject":"Re: [PATCH v3 07/19] ipa: camera_sensor_helper: Introduce\n\tminFrameDuration()","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2025-11-14 23:17:02)\n> After having introduced CameraSensorHelper::maxShutterTime() which\n> calculates the maximum shutter time which can be achieved given\n> a frame duration, this patch introduces the opposite operation, that\n> given a desired shutter time calculates what is the minimum frame\n> duration required to achieve it.\n> \n> The intended users of this function are IPA modules that after having\n> calculated a new exposure time need to regulate the frame duration to\n> achieve it.\n> \n> Signed-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(+)\n> \n> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\n> index 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>         return 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\ns/minium/minimum/\n\ns/give/given/\n\nOtherwise, looks good to me.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\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> +                                                    utils::Duration lineDuration) const\n> +{\n> +       /* Use a static to rate-limit the error message. */\n> +       static uint32_t exposureMargin = exposureMargin_.has_value()\n> +                                      ? exposureMargin_.value() : 0;\n> +       if (!exposureMargin_.has_value() && !exposureMargin) {\n> +               LOG(CameraSensorHelper, Warning)\n> +                       << \"Exposure margin not known. Default to 4\";\n> +               exposureMargin = 4;\n> +       }\n> +\n> +       return shutterTime + exposureMargin * lineDuration;\n> +}\n>  /**\n>   * \\struct CameraSensorHelper::AnalogueGainLinear\n>   * \\brief Analogue gain constants for the linear gain model\n> diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\n> index 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>         double quantizeGain(double gain, double *quantizationGain) const;\n>         utils::Duration maxShutterTime(utils::Duration maxFrameDuration,\n>                                        utils::Duration lineDuration) const;\n> +       utils::Duration minFrameDuration(utils::Duration exposureTime,\n> +                                        utils::Duration lineDuration) const;\n>  \n>  protected:\n>         struct AnalogueGainLinear {\n> \n> -- \n> 2.51.1\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 1EC93C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Feb 2026 15:30:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85354620A5;\n\tFri,  6 Feb 2026 16:30:53 +0100 (CET)","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 25A686209B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Feb 2026 16:30:52 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:5247:7b72:2b7:10da])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 09FF814C7; \n\tFri,  6 Feb 2026 16:30:07 +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=\"irmtPAvY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770391808;\n\tbh=1uKyrpCeDA1YPVkDNh60g1dGcXTPRebCCB9YLunZdn0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=irmtPAvYPMziLbyZYKzfV7o8RkIgQF8cwYGTWNqcdJomUaFJwHyMGSKYjtrgEkGwx\n\taKjjS1iutPDcpQBCoEiWItd9bjWsyqb5ptBhAh4JfYQXlE5jca9EWLYe3iGv8Tn5TO\n\tZ7BfV3qQ6V9xqePo6E9LmFYynO+axiatOgpTTNzA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251114-exposure-limits-v3-7-b7c07feba026@ideasonboard.com>","References":"<20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com>\n\t<20251114-exposure-limits-v3-7-b7c07feba026@ideasonboard.com>","Subject":"Re: [PATCH v3 07/19] ipa: camera_sensor_helper: Introduce\n\tminFrameDuration()","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, Niklas =?utf-8?b?U8O2?=\n\t=?utf-8?q?derlund?= <niklas.soderlund@ragnatech.se>, Robert Mader\n\t<robert.mader@collabora.com>, libcamera-devel@lists.libcamera.org","Date":"Sat, 07 Feb 2026 00:30:46 +0900","Message-ID":"<177039184628.607498.1382127475085964976@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]