From dadeb67fcc1c08f2de7ce314c3b9a4c57b98db71 Mon Sep 17 00:00:00 2001 From: Stefan Klug Date: Mon, 24 Nov 2025 20:52:41 +0100 Subject: [PATCH] libipa: exposure_mode_helper: Set quantizationGain in absence of a sensor helper In commit f077c58e087e ("libipa: exposure_mode_helper: Take exposure/gain quantization into account") calculation of the quantization gain was added to ExposureModeHelper::clampGain(). This works as expected when a sensor helper is configured but the gain is not reset to 1.0 in case the sensor helper is not configured. This leads to incorrect gain calculations in ExposureModeHelper::splitExposure() as that expects the quantization gain to be valid in any case. Fix that by setting the quantization gain to 1.0 in case no sensor helper is configured. Fixes: f077c58e087e ("libipa: exposure_mode_helper: Take exposure/gain quantization into account") Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/292 Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Tested-by: Jacopo Mondi --- src/ipa/libipa/exposure_mode_helper.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index 29e316d9..01c5cba8 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -144,9 +144,13 @@ utils::Duration ExposureModeHelper::clampExposureTime(utils::Duration exposureTi double ExposureModeHelper::clampGain(double gain, double *quantizationGain) const { double clamped = std::clamp(gain, minGain_, maxGain_); - if (!sensorHelper_) - return clamped; - return sensorHelper_->quantizeGain(clamped, quantizationGain); + if (sensorHelper_) + return sensorHelper_->quantizeGain(clamped, quantizationGain); + + if (quantizationGain) + *quantizationGain = 1.0; + + return clamped; } /**