[{"id":36863,"web_url":"https://patchwork.libcamera.org/comment/36863/","msgid":"<3a8b549d-fbb1-461a-9813-424aa4393725@ideasonboard.com>","date":"2025-11-17T12:49:12","subject":"Re: [PATCH v3 09/19] ipa: libipa: agc: Store sensor configuration\n\tparameters","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 11. 14. 15:17 keltezéssel, Jacopo Mondi írta:\n> To prepare for changing the configure() and setLimits() functions\n> of the ExposureModeHelper class, introduce the sensor configuration\n> parameters that will remain valid for a streaming session, and separate\n> them from the run-time configuration parameters used by the exposure\n> helper to split shutter time and gains.\n> \n> Only introduce the type in this patch but do not make use of it yet.\n> \n> This change also prepares to centralize the sensor configuration\n> paramters in the CameraHelper.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> ---\n>   src/ipa/libipa/exposure_mode_helper.cpp | 43 ++++++++++++++++++++++++++++-----\n>   src/ipa/libipa/exposure_mode_helper.h   | 18 ++++++++++++--\n>   2 files changed, 53 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\n> index 962ce1b1b7503e0f86f3857b484b249cb6383fde..c3ed1601939bd28435bbbc540d9b8c9d92b81912 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.cpp\n> +++ b/src/ipa/libipa/exposure_mode_helper.cpp\n> @@ -21,8 +21,6 @@\n>   \n>   namespace libcamera {\n>   \n> -using namespace std::literals::chrono_literals;\n\nCan't this stay in the source file instead of the header?\nI don't really see why it needs to be moved.\n\n\n> -\n>   LOG_DEFINE_CATEGORY(ExposureModeHelper)\n>   \n>   namespace ipa {\n> @@ -59,6 +57,40 @@ namespace ipa {\n>    * used.\n>    */\n>   \n> +/**\n> + * \\struct ExposureModeHelper::SensorConfiguration\n> + * \\brief The sensor configuration parameters\n> + *\n> + * This struct represents the sensor configuration paramters. Sensor\n> + * configuration parameters are set at configure() time and remain valid for\n> + * the duration of the streaming session.\n> + *\n> + * \\todo Remove it once all the information are available from the\n> + * CameraSensorHelper.\n> + *\n> + * \\var SensorConfiguration::lineDuration_\n> + * \\brief The sensor line duration\n> + *\n> + * \\var SensorConfiguration::minExposureTime_\n> + * \\brief The sensor min exposure time in microseconds\n> + *\n> + * \\var SensorConfiguration::maxExposureTime_\n> + * \\brief The sensor max exposure time in microseconds\n> + * \\todo Remove the max exposure time and calculcate it from the frame duration\n> + *\n> + * \\var SensorConfiguration::minFrameDuration_\n> + * \\brief The sensor min frame duration in microseconds\n> + *\n> + * \\var SensorConfiguration::maxFrameDuration_\n> + * \\brief The sensor max frame duration in microseconds\n> + *\n> + * \\var SensorConfiguration::minGain_\n> + * \\brief The sensor minimum analogue gain value\n> + *\n> + * \\var SensorConfiguration::maxGain_\n> + * \\brief The sensor maximum analogue gain value\n> + */\n> +\n>   /**\n>    * \\brief Construct an ExposureModeHelper instance\n>    * \\param[in] stages The vector of paired exposure time and gain limits\n> @@ -70,8 +102,6 @@ namespace ipa {\n>    * the runtime limits set through setLimits() instead.\n>    */\n>   ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages)\n> -\t: lineDuration_(1us), minExposureTime_(0us), maxExposureTime_(0us),\n> -\t  minGain_(0), maxGain_(0), sensorHelper_(nullptr)\n>   {\n>   \tfor (const auto &[s, g] : stages) {\n>   \t\texposureTimes_.push_back(s);\n> @@ -97,7 +127,7 @@ ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, dou\n>   void ExposureModeHelper::configure(utils::Duration lineDuration,\n>   \t\t\t\t   const CameraSensorHelper *sensorHelper)\n>   {\n> -\tlineDuration_ = lineDuration;\n> +\tsensor_.lineDuration_ = lineDuration;\n>   \tsensorHelper_ = sensorHelper;\n>   }\n>   \n> @@ -134,7 +164,8 @@ utils::Duration ExposureModeHelper::clampExposureTime(utils::Duration exposureTi\n>   \tutils::Duration exp;\n>   \n>   \tclamped = std::clamp(exposureTime, minExposureTime_, maxExposureTime_);\n> -\texp = static_cast<long>(clamped / lineDuration_) * lineDuration_;\n> +\texp = static_cast<long>(clamped / sensor_.lineDuration_)\n> +\t    * sensor_.lineDuration_;\n>   \tif (quantizationGain)\n>   \t\t*quantizationGain = clamped / exp;\n>   \n> diff --git a/src/ipa/libipa/exposure_mode_helper.h b/src/ipa/libipa/exposure_mode_helper.h\n> index f8b7a4aa4800b59459f8fc80f502b83647547f51..4971cfbf5b2be9ef0e3e95a64b815902833e93a4 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.h\n> +++ b/src/ipa/libipa/exposure_mode_helper.h\n> @@ -20,9 +20,21 @@ namespace libcamera {\n>   \n>   namespace ipa {\n>   \n> +using namespace std::literals::chrono_literals;\n> +\n>   class ExposureModeHelper\n>   {\n>   public:\n> +\tstruct SensorConfiguration {\n> +\t\tutils::Duration lineDuration_;\n> +\t\tutils::Duration minExposureTime_;\n> +\t\tutils::Duration maxExposureTime_;\n> +\t\tutils::Duration minFrameDuration_;\n> +\t\tutils::Duration maxFrameDuration_;\n> +\t\tdouble minGain_;\n> +\t\tdouble maxGain_;\n> +\t};\n> +\n>   \tExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages);\n>   \t~ExposureModeHelper() = default;\n>   \n> @@ -41,12 +53,14 @@ private:\n>   \tstd::vector<utils::Duration> exposureTimes_;\n>   \tstd::vector<double> gains_;\n>   \n> -\tutils::Duration lineDuration_;\n> +\tSensorConfiguration sensor_;\n\nI think this should probably have ` = {}`.\n\n\nRegards,\nBarnabás Pőcze\n\n> +\tconst CameraSensorHelper *sensorHelper_ = nullptr;\n> +\n> +\t/* Runtime parameters, used to split exposure. */\n>   \tutils::Duration minExposureTime_;\n>   \tutils::Duration maxExposureTime_;\n>   \tdouble minGain_;\n>   \tdouble maxGain_;\n> -\tconst CameraSensorHelper *sensorHelper_;\n>   };\n>   \n>   } /* namespace ipa */\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 1C013C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Nov 2025 12:49:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C6F3A60A86;\n\tMon, 17 Nov 2025 13:49:30 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED88A60856\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Nov 2025 13:49:28 +0100 (CET)","from [192.168.33.31] (185.221.143.100.nat.pool.zt.hu\n\t[185.221.143.100])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D9703FE;\n\tMon, 17 Nov 2025 13:47:25 +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=\"Wut8EW2L\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763383646;\n\tbh=D7Qr654wkZqgkjLieXsHxcoW/+bot/+6udEMHxrMlBA=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=Wut8EW2LVXjtR+B1VivELPLxYxLZTJKY7vsceNsLBe/LxzmPY/40d93dPl3xSBfIa\n\tCUrAOQuY/pwV8zzqwWUxa8IrInDPZ/0leikbDvyP2BvvEaoWsG5GjxhNBOyrzODY0R\n\tqH1s7KX5Rh5jk6codF8LYq1KGPRIRvq1TDcfdHz0=","Message-ID":"<3a8b549d-fbb1-461a-9813-424aa4393725@ideasonboard.com>","Date":"Mon, 17 Nov 2025 13:49:12 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 09/19] ipa: libipa: agc: Store sensor configuration\n\tparameters","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, =?utf-8?q?Niklas_S=C3=B6?=\n\t=?utf-8?q?derlund?= <niklas.soderlund@ragnatech.se>, Robert Mader\n\t<robert.mader@collabora.com>,  libcamera-devel@lists.libcamera.org","References":"<20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com>\n\t<20251114-exposure-limits-v3-9-b7c07feba026@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20251114-exposure-limits-v3-9-b7c07feba026@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":38123,"web_url":"https://patchwork.libcamera.org/comment/38123/","msgid":"<177039186185.607498.14538236491766046723@neptunite.rasen.tech>","date":"2026-02-06T15:31:01","subject":"Re: [PATCH v3 09/19] ipa: libipa: agc: Store sensor configuration\n\tparameters","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:04)\n> To prepare for changing the configure() and setLimits() functions\n> of the ExposureModeHelper class, introduce the sensor configuration\n> parameters that will remain valid for a streaming session, and separate\n> them from the run-time configuration parameters used by the exposure\n> helper to split shutter time and gains.\n> \n> Only introduce the type in this patch but do not make use of it yet.\n> \n> This change also prepares to centralize the sensor configuration\n> paramters in the CameraHelper.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/libipa/exposure_mode_helper.cpp | 43 ++++++++++++++++++++++++++++-----\n>  src/ipa/libipa/exposure_mode_helper.h   | 18 ++++++++++++--\n>  2 files changed, 53 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\n> index 962ce1b1b7503e0f86f3857b484b249cb6383fde..c3ed1601939bd28435bbbc540d9b8c9d92b81912 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.cpp\n> +++ b/src/ipa/libipa/exposure_mode_helper.cpp\n> @@ -21,8 +21,6 @@\n>  \n>  namespace libcamera {\n>  \n> -using namespace std::literals::chrono_literals;\n> -\n>  LOG_DEFINE_CATEGORY(ExposureModeHelper)\n>  \n>  namespace ipa {\n> @@ -59,6 +57,40 @@ namespace ipa {\n>   * used.\n>   */\n>  \n> +/**\n> + * \\struct ExposureModeHelper::SensorConfiguration\n> + * \\brief The sensor configuration parameters\n> + *\n> + * This struct represents the sensor configuration paramters. Sensor\n> + * configuration parameters are set at configure() time and remain valid for\n> + * the duration of the streaming session.\n> + *\n> + * \\todo Remove it once all the information are available from the\n> + * CameraSensorHelper.\n> + *\n> + * \\var SensorConfiguration::lineDuration_\n> + * \\brief The sensor line duration\n> + *\n> + * \\var SensorConfiguration::minExposureTime_\n> + * \\brief The sensor min exposure time in microseconds\n> + *\n> + * \\var SensorConfiguration::maxExposureTime_\n> + * \\brief The sensor max exposure time in microseconds\n> + * \\todo Remove the max exposure time and calculcate it from the frame duration\n> + *\n> + * \\var SensorConfiguration::minFrameDuration_\n> + * \\brief The sensor min frame duration in microseconds\n> + *\n> + * \\var SensorConfiguration::maxFrameDuration_\n> + * \\brief The sensor max frame duration in microseconds\n> + *\n> + * \\var SensorConfiguration::minGain_\n> + * \\brief The sensor minimum analogue gain value\n> + *\n> + * \\var SensorConfiguration::maxGain_\n> + * \\brief The sensor maximum analogue gain value\n> + */\n> +\n>  /**\n>   * \\brief Construct an ExposureModeHelper instance\n>   * \\param[in] stages The vector of paired exposure time and gain limits\n> @@ -70,8 +102,6 @@ namespace ipa {\n>   * the runtime limits set through setLimits() instead.\n>   */\n>  ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages)\n> -       : lineDuration_(1us), minExposureTime_(0us), maxExposureTime_(0us),\n> -         minGain_(0), maxGain_(0), sensorHelper_(nullptr)\n>  {\n>         for (const auto &[s, g] : stages) {\n>                 exposureTimes_.push_back(s);\n> @@ -97,7 +127,7 @@ ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, dou\n>  void ExposureModeHelper::configure(utils::Duration lineDuration,\n>                                    const CameraSensorHelper *sensorHelper)\n>  {\n> -       lineDuration_ = lineDuration;\n> +       sensor_.lineDuration_ = lineDuration;\n>         sensorHelper_ = sensorHelper;\n>  }\n>  \n> @@ -134,7 +164,8 @@ utils::Duration ExposureModeHelper::clampExposureTime(utils::Duration exposureTi\n>         utils::Duration exp;\n>  \n>         clamped = std::clamp(exposureTime, minExposureTime_, maxExposureTime_);\n> -       exp = static_cast<long>(clamped / lineDuration_) * lineDuration_;\n> +       exp = static_cast<long>(clamped / sensor_.lineDuration_)\n> +           * sensor_.lineDuration_;\n>         if (quantizationGain)\n>                 *quantizationGain = clamped / exp;\n>  \n> diff --git a/src/ipa/libipa/exposure_mode_helper.h b/src/ipa/libipa/exposure_mode_helper.h\n> index f8b7a4aa4800b59459f8fc80f502b83647547f51..4971cfbf5b2be9ef0e3e95a64b815902833e93a4 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.h\n> +++ b/src/ipa/libipa/exposure_mode_helper.h\n> @@ -20,9 +20,21 @@ namespace libcamera {\n>  \n>  namespace ipa {\n>  \n> +using namespace std::literals::chrono_literals;\n> +\n>  class ExposureModeHelper\n>  {\n>  public:\n> +       struct SensorConfiguration {\n> +               utils::Duration lineDuration_;\n> +               utils::Duration minExposureTime_;\n> +               utils::Duration maxExposureTime_;\n> +               utils::Duration minFrameDuration_;\n> +               utils::Duration maxFrameDuration_;\n> +               double minGain_;\n> +               double maxGain_;\n> +       };\n> +\n>         ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages);\n>         ~ExposureModeHelper() = default;\n>  \n> @@ -41,12 +53,14 @@ private:\n>         std::vector<utils::Duration> exposureTimes_;\n>         std::vector<double> gains_;\n>  \n> -       utils::Duration lineDuration_;\n> +       SensorConfiguration sensor_;\n> +       const CameraSensorHelper *sensorHelper_ = nullptr;\n> +\n> +       /* Runtime parameters, used to split exposure. */\n>         utils::Duration minExposureTime_;\n>         utils::Duration maxExposureTime_;\n>         double minGain_;\n>         double maxGain_;\n> -       const CameraSensorHelper *sensorHelper_;\n>  };\n>  \n>  } /* namespace ipa */\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 71A3DC31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Feb 2026 15:31:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 91658620B7;\n\tFri,  6 Feb 2026 16:31:10 +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 8930362089\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Feb 2026 16:31:09 +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 7DCB72E0;\n\tFri,  6 Feb 2026 16:30:25 +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=\"Ae61EYXp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770391826;\n\tbh=wdJqnVaNR6uyV8n/DtFD+RruEtDGZFqO/mEhSaY71Hw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Ae61EYXpqzkY8r+zc4VIrT6veHq67PKWmo/fXOBaPOcYziu5/lhmowxmCsD2Zuxt8\n\tMg1/FV5COFrVbKKsU9yUahWG/t9u/s71LRXzOlXznwIQtjabR5SM8ImwkrjE1OIuTZ\n\tRqgejlc6oY/qGZDJR+XBjLkz7Sp+tMxRYWvPXw7c=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251114-exposure-limits-v3-9-b7c07feba026@ideasonboard.com>","References":"<20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com>\n\t<20251114-exposure-limits-v3-9-b7c07feba026@ideasonboard.com>","Subject":"Re: [PATCH v3 09/19] ipa: libipa: agc: Store sensor configuration\n\tparameters","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:31:01 +0900","Message-ID":"<177039186185.607498.14538236491766046723@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>"}}]