ipa: simple: fix minimal analog gain init

On most imx sensors the formula seems to be:

again_float = 512.0 / (512.0 - again_ctrl_value)

So the minimum again of 0 makes sense and actually translates to a gain of 1.0.
And the max gain of 400 leads to 512.0 / 112.0 = 4.57 which is about typical for
a maximum again. Since a minimum again value of 0 is actually normal, the special
handling of againMin == 0 is undesirable and this is actually causing problems
on these IMX sensors. again10 correctly gets set to 0 which is less than the
adjusted againMin which causes the AGC code to not work properly.

Fix this by dropping the special handling of againMin == 0.

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Vasiliy Doylov
2026-01-05 16:57:44 +03:00
committed by Kieran Bingham
parent 2861817f09
commit 98e5e56150

View File

@@ -237,26 +237,9 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo)
camHelper_->blackLevel().value() / 256;
}
} else {
/*
* The camera sensor gain (g) is usually not equal to the value written
* into the gain register (x). But the way how the AGC algorithm changes
* the gain value to make the total exposure closer to the optimum
* assumes that g(x) is not too far from linear function. If the minimal
* gain is 0, the g(x) is likely to be far from the linear, like
* g(x) = a / (b * x + c). To avoid unexpected changes to the gain by
* the AGC algorithm (abrupt near one edge, and very small near the
* other) we limit the range of the gain values used.
*/
context_.configuration.agc.againMax = againMax;
context_.configuration.agc.again10 = againDef;
if (againMin) {
context_.configuration.agc.againMin = againMin;
} else {
LOG(IPASoft, Warning)
<< "Minimum gain is zero, that can't be linear";
context_.configuration.agc.againMin =
std::min(100, againMin / 2 + againMax / 2);
}
context_.configuration.agc.againMin = againMin;
context_.configuration.agc.againMinStep = 1.0;
}