[RFC,v3,05/19] ipa: libipa: exposure_mode_helper: Handle no stages
diff mbox series

Message ID 20261019184526.252977-6-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • ipa: libipa: agc: Take exposure margin into account
Related show

Commit Message

Barnabás Pőcze Oct. 19, 2026, 6:45 p.m. UTC
Make the handling of the "no stage" explicit.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/libipa/exposure_mode_helper.cpp | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp
index 51f4be98e2..7a810a3673 100644
--- a/src/ipa/libipa/exposure_mode_helper.cpp
+++ b/src/ipa/libipa/exposure_mode_helper.cpp
@@ -240,7 +240,22 @@  ExposureModeHelper::splitExposure(utils::Duration exposure) const
 			 exposure / (exposureTime * gain * quantGain) };
 	}
 
-	double lastStageGain = clampGain(1.0);
+	const double unitGain = clampGain(1.0);
+
+	/*
+	 * If no stages are present, max out the exposure time, then the
+	 * analogue gain, and use digital gain for the rest.
+	 */
+	if (stages_.empty()) {
+		exposureTime = clampExposureTime(exposure / unitGain, &quantGain);
+		gain = clampGain(exposure / exposureTime, &quantGain2);
+		quantGain *= quantGain2;
+
+		return { exposureTime, gain, quantGain,
+			 exposure / (exposureTime * gain * quantGain) };
+	}
+
+	double lastStageGain = unitGain;
 
 	for (const auto &stage : stages_) {
 		utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime,
@@ -282,9 +297,7 @@  ExposureModeHelper::splitExposure(utils::Duration exposure) const
 	/*
 	 * From here on all we can do is max out the exposure time, followed by
 	 * the analogue gain. If we still haven't achieved the target we send
-	 * the rest of the exposure time to digital gain. If we were given no
-	 * stages to use then the default gain of 1.0 is used so that exposure
-	 * time is maxed before gain is touched at all.
+	 * the rest of the exposure time to digital gain.
 	 */
 	exposureTime = clampExposureTime(exposure / lastStageGain, &quantGain);
 	gain = clampGain(exposure / exposureTime, &quantGain2);