[PATCH 2/3] ipa: libipa: agc_mean_luminance: Error out when effectiveExposureValue is zero

Dan Scally dan.scally at ideasonboard.com
Fri Feb 28 14:00:09 CET 2025


Hi Stefan

On 28/02/2025 12:55, Stefan Klug wrote:
> In a proper system it never happens that the effectiveExposureValue
> drops to zero. If that still happens due to a bug outside of
> agc_mean_luminance, the calculated gain goes towards infinity but the
> newExposureValue is still 0 because it is the result of multiplying the
> effectiveExposureTime with the gain, leading to wild oscillations.
>
> Catch that condition, print an error message and set the new effective
> exposure value to an arbitrary 10ms.
>
> Note that in any case the underlying problem must be fixed. The
> important change is the added error message to be able to detect such a
> situation.
>
> Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally at ideasonboard.com>
> ---
>   src/ipa/libipa/agc_mean_luminance.cpp | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp
> index 02555a44d271..a7343c18f5aa 100644
> --- a/src/ipa/libipa/agc_mean_luminance.cpp
> +++ b/src/ipa/libipa/agc_mean_luminance.cpp
> @@ -541,6 +541,13 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,
>   	std::shared_ptr<ExposureModeHelper> exposureModeHelper =
>   		exposureModeHelpers_.at(exposureModeIndex);
>   
> +	if (effectiveExposureValue == 0s) {
> +		LOG(AgcMeanLuminance, Error) << "Effective exposure value is 0."
> +					     << " Resetting exposure time and"
> +					     << " gain to arbitrary defaults.";
> +		return exposureModeHelper->splitExposure(10ms);
> +	}
> +
>   	double gain = estimateInitialGain();
>   	gain = constraintClampGain(constraintModeIndex, yHist, gain);
>   


More information about the libcamera-devel mailing list