[v2,2/9] ipa: libipa: agc: Retrieve `FrameDurationLimits` earlier
diff mbox series

Message ID 20260925102551.137108-3-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 Sept. 25, 2026, 10:25 a.m. UTC
The frame duration limits will be used to clamp the manually provided
exposure time. Handle them earlier so that they are available.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/agc.cpp | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
index c20d0ad2af..a177dba9d8 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -591,6 +591,20 @@  void AgcAlgorithm::queueRequest(const agc::Session &session, agc::ActiveState &s
 		}
 	}
 
+	const auto &frameDurationLimits = controls.get(controls::FrameDurationLimits);
+	if (frameDurationLimits) {
+		/* Limit the control value to the limits in ControlInfo */
+		state.minFrameDuration = std::clamp<utils::Duration>(
+			std::chrono::microseconds((*frameDurationLimits).front()),
+			session.minFrameDuration, session.maxFrameDuration);
+
+		state.maxFrameDuration = std::clamp<utils::Duration>(
+			std::chrono::microseconds((*frameDurationLimits).back()),
+			state.minFrameDuration, session.maxFrameDuration);
+	}
+	frameContext.minFrameDuration = state.minFrameDuration;
+	frameContext.maxFrameDuration = state.maxFrameDuration;
+
 	const auto &exposure = controls.get(controls::ExposureTime);
 	if (exposure && !state.autoExposureEnabled) {
 		state.manual.exposure = *exposure * 1.0us / session.lineDuration;
@@ -632,20 +646,6 @@  void AgcAlgorithm::queueRequest(const agc::Session &session, agc::ActiveState &s
 	if (exposureValue)
 		state.exposureValue = *exposureValue;
 	frameContext.exposureValue = state.exposureValue;
-
-	const auto &frameDurationLimits = controls.get(controls::FrameDurationLimits);
-	if (frameDurationLimits) {
-		/* Limit the control value to the limits in ControlInfo */
-		state.minFrameDuration = std::clamp<utils::Duration>(
-			std::chrono::microseconds((*frameDurationLimits).front()),
-			session.minFrameDuration, session.maxFrameDuration);
-
-		state.maxFrameDuration = std::clamp<utils::Duration>(
-			std::chrono::microseconds((*frameDurationLimits).back()),
-			state.minFrameDuration, session.maxFrameDuration);
-	}
-	frameContext.minFrameDuration = state.minFrameDuration;
-	frameContext.maxFrameDuration = state.maxFrameDuration;
 }
 
 /**