From 9c90e56733311a1cdabf2554e3b82f7e177e735d Mon Sep 17 00:00:00 2001 From: David Plowman Date: Fri, 13 Oct 2023 08:48:37 +0100 Subject: ipa: rpi: agc: Add an AGC stable region Add a small "stable region" parameter (defaulting to 2%) within which the AGC will not adjust the exposure it requests. It allows applications to configure the AGC to avoid continual micro-adjustments of exposure values if they are somehow sensitive to it. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/ipa/rpi/controller/rpi/agc_channel.cpp | 7 +++++++ src/ipa/rpi/controller/rpi/agc_channel.h | 1 + 2 files changed, 8 insertions(+) (limited to 'src/ipa/rpi') diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index 3957dbc3..1e7eae06 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -251,6 +251,8 @@ int AgcConfig::read(const libcamera::YamlObject ¶ms) defaultExposureTime = params["default_exposure_time"].get(1000) * 1us; defaultAnalogueGain = params["default_analogue_gain"].get(1.0); + stableRegion = params["stable_region"].get(0.02); + return 0; } @@ -871,6 +873,8 @@ bool AgcChannel::applyDigitalGain(double gain, double targetY, bool channelBound void AgcChannel::filterExposure() { double speed = config_.speed; + double stableRegion = config_.stableRegion; + /* * AGC adapts instantly if both shutter and gain are directly specified * or we're in the startup phase. @@ -880,6 +884,9 @@ void AgcChannel::filterExposure() speed = 1.0; if (!filtered_.totalExposure) { filtered_.totalExposure = target_.totalExposure; + } else if (filtered_.totalExposure * (1.0 - stableRegion) < target_.totalExposure && + filtered_.totalExposure * (1.0 + stableRegion) > target_.totalExposure) { + /* Total exposure must change by more than this or we leave it alone. */ } else { /* * If close to the result go faster, to save making so many diff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h index ae826fa8..c1808422 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.h +++ b/src/ipa/rpi/controller/rpi/agc_channel.h @@ -75,6 +75,7 @@ struct AgcConfig { double baseEv; libcamera::utils::Duration defaultExposureTime; double defaultAnalogueGain; + double stableRegion; }; class AgcChannel -- cgit v1.2.1