[RFC,v3,26/50] ipa: libipa: agc: Store digital gain
diff mbox series

Message ID 20260803131435.153927-27-barnabas.pocze@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: libipa: agc rework
Related show

Commit Message

Barnabás Pőcze Aug. 3, 2026, 1:14 p.m. UTC
While digital gain support is not implemented yet, start by storing
the suggested digital gain in the active state.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/libipa/agc.cpp | 7 ++++++-
 src/ipa/libipa/agc.h   | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Jacopo Mondi Aug. 5, 2026, 2:57 p.m. UTC | #1
Hi Barnabás

On Mon, Aug 03, 2026 at 03:14:11PM +0200, Barnabás Pőcze wrote:
> While digital gain support is not implemented yet, start by storing
> the suggested digital gain in the active state.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/ipa/libipa/agc.cpp | 7 ++++++-
>  src/ipa/libipa/agc.h   | 1 +
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
> index 5273c1f64b..e9055ddd7b 100644
> --- a/src/ipa/libipa/agc.cpp
> +++ b/src/ipa/libipa/agc.cpp
> @@ -100,6 +100,9 @@ LOG_DEFINE_CATEGORY(Agc)
>   * \var agc::ActiveState::automatic.quantizationGain
>   * \brief Automatic quantization gain multiplier
>   *
> + * \var agc::ActiveState::automatic.digitalGain
> + * \brief Automatic digital gain multiplier

with a \todo note about supporting it

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

Thanks
  j

> + *
>   * \var agc::ActiveState::automatic.yTarget
>   * \brief Automatically determined luminance target
>   *
> @@ -322,6 +325,7 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
>  	state.automatic.gain = session.minAnalogueGain;
>  	state.automatic.exposure = defExposure;
>  	state.automatic.quantizationGain = 1;
> +	state.automatic.digitalGain = 1;
>  	state.automatic.yTarget = impl_.effectiveYTarget(0, 1);
>  	state.manual.gain = state.automatic.gain;
>  	state.manual.exposure = state.automatic.exposure;
> @@ -598,6 +602,7 @@ void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,
>  		state.automatic.exposure = newEv.exposureTime / lineDuration;
>  		state.automatic.gain = newEv.analogueGain;
>  		state.automatic.quantizationGain = newEv.quantizationGain;
> +		state.automatic.digitalGain = newEv.digitalGain;
>  		state.automatic.yTarget = newEv.yTarget;
>
>  		newExposureTime = newEv.exposureTime;
> @@ -606,7 +611,7 @@ void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,
>  			<< "exposure-time:" << utils::Duration(state.automatic.exposure * lineDuration)
>  			<< " analogue-gain:" << state.automatic.gain
>  			<< " quantization-gain:" << state.automatic.quantizationGain
> -			<< " digital-gain:" << newEv.digitalGain;
> +			<< " digital-gain:" << state.automatic.digitalGain;
>  	}
>
>  	/*
> diff --git a/src/ipa/libipa/agc.h b/src/ipa/libipa/agc.h
> index ab85d9a3bd..b0f811e93d 100644
> --- a/src/ipa/libipa/agc.h
> +++ b/src/ipa/libipa/agc.h
> @@ -74,6 +74,7 @@ struct ActiveState {
>  		uint32_t exposure;
>  		double gain;
>  		double quantizationGain;
> +		double digitalGain;
>  		double yTarget;
>  	} automatic;
>
> --
> 2.55.0
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
index 5273c1f64b..e9055ddd7b 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -100,6 +100,9 @@  LOG_DEFINE_CATEGORY(Agc)
  * \var agc::ActiveState::automatic.quantizationGain
  * \brief Automatic quantization gain multiplier
  *
+ * \var agc::ActiveState::automatic.digitalGain
+ * \brief Automatic digital gain multiplier
+ *
  * \var agc::ActiveState::automatic.yTarget
  * \brief Automatically determined luminance target
  *
@@ -322,6 +325,7 @@  int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
 	state.automatic.gain = session.minAnalogueGain;
 	state.automatic.exposure = defExposure;
 	state.automatic.quantizationGain = 1;
+	state.automatic.digitalGain = 1;
 	state.automatic.yTarget = impl_.effectiveYTarget(0, 1);
 	state.manual.gain = state.automatic.gain;
 	state.manual.exposure = state.automatic.exposure;
@@ -598,6 +602,7 @@  void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,
 		state.automatic.exposure = newEv.exposureTime / lineDuration;
 		state.automatic.gain = newEv.analogueGain;
 		state.automatic.quantizationGain = newEv.quantizationGain;
+		state.automatic.digitalGain = newEv.digitalGain;
 		state.automatic.yTarget = newEv.yTarget;
 
 		newExposureTime = newEv.exposureTime;
@@ -606,7 +611,7 @@  void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,
 			<< "exposure-time:" << utils::Duration(state.automatic.exposure * lineDuration)
 			<< " analogue-gain:" << state.automatic.gain
 			<< " quantization-gain:" << state.automatic.quantizationGain
-			<< " digital-gain:" << newEv.digitalGain;
+			<< " digital-gain:" << state.automatic.digitalGain;
 	}
 
 	/*
diff --git a/src/ipa/libipa/agc.h b/src/ipa/libipa/agc.h
index ab85d9a3bd..b0f811e93d 100644
--- a/src/ipa/libipa/agc.h
+++ b/src/ipa/libipa/agc.h
@@ -74,6 +74,7 @@  struct ActiveState {
 		uint32_t exposure;
 		double gain;
 		double quantizationGain;
+		double digitalGain;
 		double yTarget;
 	} automatic;