[RFC,v4,22/23] ipa: libipa: agc: Do not run slower than 15fps by default
diff mbox series

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

Commit Message

Barnabás Pőcze Oct. 26, 2026, 1:20 p.m. UTC
If the tuning file defines no exposure modes, then the "Maximize" mode will
be implicitly instantiated and used. But in this case, do not let the camera
run slower than 15fps, by default, unless the user explicitly requests it
using `FrameDurationLimits`.

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

Comments

Jacopo Mondi Oct. 27, 2026, 9 a.m. UTC | #1
Hi Barnabás

On Mon, Oct 26, 2026 at 02:20:44PM +0100, Barnabás Pőcze wrote:
> If the tuning file defines no exposure modes, then the "Maximize" mode will
> be implicitly instantiated and used. But in this case, do not let the camera
> run slower than 15fps, by default, unless the user explicitly requests it
> using `FrameDurationLimits`.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/ipa/libipa/agc.cpp | 8 ++++++++
>  src/ipa/libipa/agc.h   | 4 ++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
> index 416178177e..90f51ff035 100644
> --- a/src/ipa/libipa/agc.cpp
> +++ b/src/ipa/libipa/agc.cpp
> @@ -568,6 +568,8 @@ int AgcAlgorithm::init(const ValueNode &tuningData, CameraSensorHelper *sensor,
>  		if (ret)
>  			return ret;
>
> +		tuning_.hasExposureStages = !agcMLconfig.exposureModeHelpers.empty();
> +
>  		fillMissing(agcMLconfig);
>
>  		impl_.emplace<AgcMeanLuminance>(std::move(agcMLconfig));
> @@ -737,6 +739,12 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
>  		state.minFrameDuration = std::clamp(
>  			utils::Duration(1.0s / 30),
>  			session.minFrameDuration, session.maxFrameDuration);
> +
> +		if (!tuning_.hasExposureStages) {
> +			state.maxFrameDuration = std::clamp(
> +				utils::Duration(1.0s / 15),
> +				state.minFrameDuration, session.maxFrameDuration);
> +		}

state.maxFrameDuration is initialized to session.maxFrameDuration
durig ::configure().

session.maxFrameDuration is initialized as:

	session.maxFrameDuration = config.sensorInfo.maxFrameLength * session.lineDuration;

a bit before, in ::configure() as well.

One question for clarification:

1) What is the max frame duration if we have exposure modes ? Will it
be the sensor's maximum and the actual VBLANK will be the one required
by exposure ?


>  	}
>
>  	/* \todo Move this to the `Camera` class. */
> diff --git a/src/ipa/libipa/agc.h b/src/ipa/libipa/agc.h
> index 3ca36aea64..44f5218b0c 100644
> --- a/src/ipa/libipa/agc.h
> +++ b/src/ipa/libipa/agc.h
> @@ -163,6 +163,10 @@ private:
>
>  	std::variant<AgcMSV, AgcMeanLuminance> impl_;
>  	CameraSensorHelper *sensor_ = nullptr;
> +
> +	struct {
> +		bool hasExposureStages = false;
> +	} tuning_;
>  };
>
>  } /* namespace ipa */
> --
> 2.56.0
>
Barnabás Pőcze Oct. 27, 2026, 11:13 a.m. UTC | #2
2026. 10. 27. 10:00 keltezéssel, Jacopo Mondi írta:
> Hi Barnabás
> 
> On Mon, Oct 26, 2026 at 02:20:44PM +0100, Barnabás Pőcze wrote:
>> If the tuning file defines no exposure modes, then the "Maximize" mode will
>> be implicitly instantiated and used. But in this case, do not let the camera
>> run slower than 15fps, by default, unless the user explicitly requests it
>> using `FrameDurationLimits`.
>>
>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
>> ---
>>   src/ipa/libipa/agc.cpp | 8 ++++++++
>>   src/ipa/libipa/agc.h   | 4 ++++
>>   2 files changed, 12 insertions(+)
>>
>> diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
>> index 416178177e..90f51ff035 100644
>> --- a/src/ipa/libipa/agc.cpp
>> +++ b/src/ipa/libipa/agc.cpp
>> @@ -568,6 +568,8 @@ int AgcAlgorithm::init(const ValueNode &tuningData, CameraSensorHelper *sensor,
>>   		if (ret)
>>   			return ret;
>>
>> +		tuning_.hasExposureStages = !agcMLconfig.exposureModeHelpers.empty();
>> +
>>   		fillMissing(agcMLconfig);
>>
>>   		impl_.emplace<AgcMeanLuminance>(std::move(agcMLconfig));
>> @@ -737,6 +739,12 @@ int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
>>   		state.minFrameDuration = std::clamp(
>>   			utils::Duration(1.0s / 30),
>>   			session.minFrameDuration, session.maxFrameDuration);
>> +
>> +		if (!tuning_.hasExposureStages) {
>> +			state.maxFrameDuration = std::clamp(
>> +				utils::Duration(1.0s / 15),
>> +				state.minFrameDuration, session.maxFrameDuration);
>> +		}
> 
> state.maxFrameDuration is initialized to session.maxFrameDuration
> durig ::configure().
> 
> session.maxFrameDuration is initialized as:
> 
> 	session.maxFrameDuration = config.sensorInfo.maxFrameLength * session.lineDuration;
> 
> a bit before, in ::configure() as well.
> 
> One question for clarification:
> 
> 1) What is the max frame duration if we have exposure modes ? Will it
> be the sensor's maximum and the actual VBLANK will be the one required
> by exposure ?

Yes, that's correct.

The 15fps limit is only applied if no exposure modes are defined in the tuning file,
otherwise it's effectively left up to the exposure modes to decide how much exposure
they want to allow. This roughly matches the rpi behaviour (i.e. essentially no additional
limit on top of what's determined by the exposure modes).


> 
> 
>>   	}
>>
>>   	/* \todo Move this to the `Camera` class. */
>> diff --git a/src/ipa/libipa/agc.h b/src/ipa/libipa/agc.h
>> index 3ca36aea64..44f5218b0c 100644
>> --- a/src/ipa/libipa/agc.h
>> +++ b/src/ipa/libipa/agc.h
>> @@ -163,6 +163,10 @@ private:
>>
>>   	std::variant<AgcMSV, AgcMeanLuminance> impl_;
>>   	CameraSensorHelper *sensor_ = nullptr;
>> +
>> +	struct {
>> +		bool hasExposureStages = false;
>> +	} tuning_;
>>   };
>>
>>   } /* namespace ipa */
>> --
>> 2.56.0
>>

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
index 416178177e..90f51ff035 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -568,6 +568,8 @@  int AgcAlgorithm::init(const ValueNode &tuningData, CameraSensorHelper *sensor,
 		if (ret)
 			return ret;
 
+		tuning_.hasExposureStages = !agcMLconfig.exposureModeHelpers.empty();
+
 		fillMissing(agcMLconfig);
 
 		impl_.emplace<AgcMeanLuminance>(std::move(agcMLconfig));
@@ -737,6 +739,12 @@  int AgcAlgorithm::configure(agc::Session &session, agc::ActiveState &state,
 		state.minFrameDuration = std::clamp(
 			utils::Duration(1.0s / 30),
 			session.minFrameDuration, session.maxFrameDuration);
+
+		if (!tuning_.hasExposureStages) {
+			state.maxFrameDuration = std::clamp(
+				utils::Duration(1.0s / 15),
+				state.minFrameDuration, session.maxFrameDuration);
+		}
 	}
 
 	/* \todo Move this to the `Camera` class. */
diff --git a/src/ipa/libipa/agc.h b/src/ipa/libipa/agc.h
index 3ca36aea64..44f5218b0c 100644
--- a/src/ipa/libipa/agc.h
+++ b/src/ipa/libipa/agc.h
@@ -163,6 +163,10 @@  private:
 
 	std::variant<AgcMSV, AgcMeanLuminance> impl_;
 	CameraSensorHelper *sensor_ = nullptr;
+
+	struct {
+		bool hasExposureStages = false;
+	} tuning_;
 };
 
 } /* namespace ipa */