[RFC,v1,2/8] ipa: libipa: agc: Retrieve `FrameDurationLimits` earlier
diff mbox series

Message ID 20260827104108.1432632-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 Aug. 27, 2026, 10:41 a.m. UTC
The frame duration limits will be used to clamp the manually provided
exposure time, so load them earlier so that they are available.

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

Comments

Stefan Klug Aug. 27, 2026, 11:58 a.m. UTC | #1
Hi Barnabás,

Quoting Barnabás Pőcze (2026-08-27 12:41:02)
> The frame duration limits will be used to clamp the manually provided
> exposure time, so load them earlier so that they are available.

Maybe 
s/, so load/. Handle/

Up to you.

> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>

Best regards,
Stefan

> ---
>  src/ipa/libipa/agc.cpp | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
> index f9edd9295a..fab34152cc 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;
>  }
>  
>  /**
> -- 
> 2.55.0
>
Jacopo Mondi Aug. 27, 2026, 3:04 p.m. UTC | #2
Hi Barnabás

On Thu, Aug 27, 2026 at 12:41:02PM +0200, Barnabás Pőcze wrote:
> The frame duration limits will be used to clamp the manually provided
> exposure time, so load them earlier so that they are available.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

> ---
>  src/ipa/libipa/agc.cpp | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
> index f9edd9295a..fab34152cc 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;
>  }
>
>  /**
> --
> 2.55.0
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
index f9edd9295a..fab34152cc 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;
 }
 
 /**