[v2,1/4] ipa: rkisp1: agc: Use better defaults for analogue gain and exposure
diff mbox series

Message ID 20241020152821.240726-2-mike.rudenko@gmail.com
State New
Headers show
Series
  • Reduce rkisp1 flicker on first start
Related show

Commit Message

Mikhail Rudenko Oct. 20, 2024, 3:28 p.m. UTC
At present, analogue gain in IPA context is initialized to the minimum
sensor gain in configure(). Many sensors report minimum analogue gain
of 0, which is by no means a sane default. Use a reasonable default of
1.0 instead. Also, set default exposure to maximum. In the common case
when no gain stages are configured and no gain/exposure constraints
are set, these defaults result in having right gain or exposure from
the start, since AGC either sets 1.0 gain and steers exposure (lighter
scenes), or sets max exposure and steers gain (darker scenes).

Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com>
---
 src/ipa/rkisp1/algorithms/agc.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 17d074d9..2b36d7aa 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -30,9 +30,12 @@ 
 namespace libcamera {
 
 using namespace std::literals::chrono_literals;
+using utils::Duration;
 
 namespace ipa::rkisp1::algorithms {
 
+constexpr double defaultAnalogueGain = 1.0;
+
 /**
  * \class Agc
  * \brief A mean-based auto-exposure algorithm
@@ -164,9 +167,9 @@  int Agc::init(IPAContext &context, const YamlObject &tuningData)
 int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)
 {
 	/* Configure the default exposure and gain. */
-	context.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain;
+	context.activeState.agc.automatic.gain = defaultAnalogueGain;
 	context.activeState.agc.automatic.exposure =
-		10ms / context.configuration.sensor.lineDuration;
+		context.configuration.sensor.maxShutterSpeed / context.configuration.sensor.lineDuration;
 	context.activeState.agc.manual.gain = context.activeState.agc.automatic.gain;
 	context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure;
 	context.activeState.agc.autoEnabled = !context.configuration.raw;