[01/20] ipa: softisp: Emit setSensorControls from computeParams()
diff mbox series

Message ID 20261203195647.18475-1-johannes.goede@oss.qualcomm.com
State Not Applicable
Headers show
Series
  • [01/20] ipa: softisp: Emit setSensorControls from computeParams()
Related show

Commit Message

Hans de Goede Dec. 3, 2026, 7:56 p.m. UTC
The agc::prepareControls() call to prepare the controls to pass to
the setSensorControls signal takes frameContext.agc.[exposure,gain] as
parameters.

These are updated by the prepare() call of the agc algorithm. Doing
the agc::prepareControls() call + setSensorControls.emit() in
processStats() leads to previous or uninitialized (0) values being
used.

Move these calls to computeParams() after the prepare() calls. This also
nicely groups the agc::prepareControls() call together with the other
prepare() calls.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
 src/ipa/softisp/softisp.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Hans de Goede Dec. 3, 2026, 8:52 p.m. UTC | #1
Hi all,

Please ignore the 1/20 part of the subject, my bad.

This is a standalone fix.

Regards,

Hans



On 3-Dec-26 20:56, Hans de Goede wrote:
> The agc::prepareControls() call to prepare the controls to pass to
> the setSensorControls signal takes frameContext.agc.[exposure,gain] as
> parameters.
> 
> These are updated by the prepare() call of the agc algorithm. Doing
> the agc::prepareControls() call + setSensorControls.emit() in
> processStats() leads to previous or uninitialized (0) values being
> used.
> 
> Move these calls to computeParams() after the prepare() calls. This also
> nicely groups the agc::prepareControls() call together with the other
> prepare() calls.
> 
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
>  src/ipa/softisp/softisp.cpp | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/ipa/softisp/softisp.cpp b/src/ipa/softisp/softisp.cpp
> index 00249a300..96056865d 100644
> --- a/src/ipa/softisp/softisp.cpp
> +++ b/src/ipa/softisp/softisp.cpp
> @@ -237,6 +237,11 @@ void IPASoftIsp::computeParams(const uint32_t frame)
>  	params_->combinedMatrix = context_.activeState.combinedMatrix;
>  
>  	paramsComputed.emit(frame);
> +
> +	ControlList ctrls(context_.sensorControls);
> +	agc::prepareControls(ctrls, context_.camHelper.get(),
> +			     frameContext.agc.exposure, frameContext.agc.gain);
> +	setSensorControls.emit(ctrls);
>  }
>  
>  void IPASoftIsp::processStats(const uint32_t frame,
> @@ -252,11 +257,6 @@ void IPASoftIsp::processStats(const uint32_t frame,
>  	for (const auto &algo : algorithms())
>  		algo->process(context_, frame, frameContext, stats_, metadata);
>  	metadataReady.emit(frame, metadata);
> -
> -	ControlList ctrls(context_.sensorControls);
> -	agc::prepareControls(ctrls, context_.camHelper.get(),
> -			     frameContext.agc.exposure, frameContext.agc.gain);
> -	setSensorControls.emit(ctrls);
>  }
>  
>  std::string IPASoftIsp::logPrefix() const
Barnabás Pőcze Dec. 4, 2026, 10:10 a.m. UTC | #2
Hi

2026. 12. 03. 20:56 keltezéssel, Hans de Goede írta:
> The agc::prepareControls() call to prepare the controls to pass to
> the setSensorControls signal takes frameContext.agc.[exposure,gain] as
> parameters.
> 
> These are updated by the prepare() call of the agc algorithm. Doing
> the agc::prepareControls() call + setSensorControls.emit() in
> processStats() leads to previous or uninitialized (0) values being
> used.
> 
> Move these calls to computeParams() after the prepare() calls. This also
> nicely groups the agc::prepareControls() call together with the other
> prepare() calls.

Sensor control is way off in all pipeline handlers (except likely rpi). But
I'm afraid this is based on an old libcamera commit, and it is not applicable
anymore. And it cannot be rebased either because vblank is only finalized in
`AgcAlgorithm::process()` (which is of course completely wrong, but that is
not trivial to fix yet).


> 
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
>   src/ipa/softisp/softisp.cpp | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/ipa/softisp/softisp.cpp b/src/ipa/softisp/softisp.cpp
> index 00249a300..96056865d 100644
> --- a/src/ipa/softisp/softisp.cpp
> +++ b/src/ipa/softisp/softisp.cpp
> @@ -237,6 +237,11 @@ void IPASoftIsp::computeParams(const uint32_t frame)
>   	params_->combinedMatrix = context_.activeState.combinedMatrix;
>   
>   	paramsComputed.emit(frame);
> +
> +	ControlList ctrls(context_.sensorControls);
> +	agc::prepareControls(ctrls, context_.camHelper.get(),
> +			     frameContext.agc.exposure, frameContext.agc.gain);
> +	setSensorControls.emit(ctrls);
>   }
>   
>   void IPASoftIsp::processStats(const uint32_t frame,
> @@ -252,11 +257,6 @@ void IPASoftIsp::processStats(const uint32_t frame,
>   	for (const auto &algo : algorithms())
>   		algo->process(context_, frame, frameContext, stats_, metadata);
>   	metadataReady.emit(frame, metadata);
> -
> -	ControlList ctrls(context_.sensorControls);
> -	agc::prepareControls(ctrls, context_.camHelper.get(),
> -			     frameContext.agc.exposure, frameContext.agc.gain);
> -	setSensorControls.emit(ctrls);
>   }
>   
>   std::string IPASoftIsp::logPrefix() const

Patch
diff mbox series

diff --git a/src/ipa/softisp/softisp.cpp b/src/ipa/softisp/softisp.cpp
index 00249a300..96056865d 100644
--- a/src/ipa/softisp/softisp.cpp
+++ b/src/ipa/softisp/softisp.cpp
@@ -237,6 +237,11 @@  void IPASoftIsp::computeParams(const uint32_t frame)
 	params_->combinedMatrix = context_.activeState.combinedMatrix;
 
 	paramsComputed.emit(frame);
+
+	ControlList ctrls(context_.sensorControls);
+	agc::prepareControls(ctrls, context_.camHelper.get(),
+			     frameContext.agc.exposure, frameContext.agc.gain);
+	setSensorControls.emit(ctrls);
 }
 
 void IPASoftIsp::processStats(const uint32_t frame,
@@ -252,11 +257,6 @@  void IPASoftIsp::processStats(const uint32_t frame,
 	for (const auto &algo : algorithms())
 		algo->process(context_, frame, frameContext, stats_, metadata);
 	metadataReady.emit(frame, metadata);
-
-	ControlList ctrls(context_.sensorControls);
-	agc::prepareControls(ctrls, context_.camHelper.get(),
-			     frameContext.agc.exposure, frameContext.agc.gain);
-	setSensorControls.emit(ctrls);
 }
 
 std::string IPASoftIsp::logPrefix() const