[libcamera-devel] [IPAIPU3 PATCH v4 6/6] ipa: ipu3: Inlink parseStatistics() into processStatsBuffer()

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Apr 6 00:59:08 CEST 2022


Hi Umang,

Thank you for the patch.

s/Inlink/Inline/

On Thu, Mar 31, 2022 at 10:00:58PM +0530, Umang Jain via libcamera-devel wrote:
> Since we have moved away from switch/case on the operation ID,
> there's little reason to split the operation in two functions.
> 
> Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  ipu3.cpp | 74 ++++++++++++++++++++++++--------------------------------
>  1 file changed, 31 insertions(+), 43 deletions(-)
> 
> diff --git a/ipu3.cpp b/ipu3.cpp
> index a435005..9063d7e 100644
> --- a/ipu3.cpp
> +++ b/ipu3.cpp
> @@ -61,10 +61,6 @@ private:
>  			    const ControlInfoMap &sensorControls,
>  			    ControlInfoMap *ipaControls);
>  	void runAiq(unsigned int frame);
> -	void parseStatistics(unsigned int frame,
> -			     int64_t frameTimestamp,
> -			     const ipu3_uapi_stats_3a *stats,
> -			     const ControlList& sensorCtrls);
>  
>  	void setControls(unsigned int frame);
>  
> @@ -380,43 +376,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimest
>  	const ipu3_uapi_stats_3a *stats =
>  		reinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());
>  
> -	parseStatistics(frame, frameTimestamp, stats, sensorControls);
> -}
> -
> -void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
> -{
> -	/* Run algorithms into/using this context structure */
> -	resultsHistory_.extendOne();
> -	aiq::AiqResults& latestResults = resultsHistory_.latest();
> -
> -	/* Todo: Refactor AiqInputParameters interface to set following parameters. */
> -	aiqInputParams_.afParams.lens_position = lensPosition_;
> -	aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;
> -
> -	aiq_.run2a(frame, aiqInputParams_, latestResults);
> -
> -	exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;
> -	gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
> -
> -	/*
> -	 * Af algorithm compares the timestamp of start of the lens movement and
> -	 * that of the statistics generated to estimate whether next lens
> -	 * position should be produced.
> -	 * \todo use the lens movement start time reported by the pipeline handler.
> -	 */
> -	if (lensPosition_ != latestResults.af()->next_lens_position) {
> -		utils::time_point time = utils::clock::now();
> -		uint64_t usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();
> -		lensMovementStartTime_ = usecs;
> -	}
> -	lensPosition_ = latestResults.af()->next_lens_position;
> -}
> -
> -void IPAIPU3::parseStatistics(unsigned int frame,
> -			      int64_t frameTimestamp,
> -			      const ipu3_uapi_stats_3a *stats,
> -			      const ControlList& sensorCtrls)
> -{
>  	ControlList ctrls(controls::controls);
>  
>  	/* \todo React to statistics and update internal state machine. */
> @@ -439,11 +398,11 @@ void IPAIPU3::parseStatistics(unsigned int frame,
>  	int32_t effectiveGain = 0;
>  	ControlValue ctrlValue;
>  
> -	ctrlValue = sensorCtrls.get(V4L2_CID_EXPOSURE);
> +	ctrlValue = sensorControls.get(V4L2_CID_EXPOSURE);
>  	if (!ctrlValue.isNone())
>  		effectiveExpo = ctrlValue.get<int32_t>();
>  
> -	ctrlValue = sensorCtrls.get(V4L2_CID_ANALOGUE_GAIN);
> +	ctrlValue = sensorControls.get(V4L2_CID_ANALOGUE_GAIN);
>  	if (!ctrlValue.isNone())
>  		effectiveGain = ctrlValue.get<int32_t>();
>  
> @@ -473,6 +432,35 @@ void IPAIPU3::parseStatistics(unsigned int frame,
>  	metadataReady.emit(frame, ctrls);
>  }
>  
> +void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
> +{
> +	/* Run algorithms into/using this context structure */
> +	resultsHistory_.extendOne();
> +	aiq::AiqResults& latestResults = resultsHistory_.latest();
> +
> +	/* Todo: Refactor AiqInputParameters interface to set following parameters. */
> +	aiqInputParams_.afParams.lens_position = lensPosition_;
> +	aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;
> +
> +	aiq_.run2a(frame, aiqInputParams_, latestResults);
> +
> +	exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;
> +	gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
> +
> +	/*
> +	 * Af algorithm compares the timestamp of start of the lens movement and
> +	 * that of the statistics generated to estimate whether next lens
> +	 * position should be produced.
> +	 * \todo use the lens movement start time reported by the pipeline handler.
> +	 */
> +	if (lensPosition_ != latestResults.af()->next_lens_position) {
> +		utils::time_point time = utils::clock::now();
> +		uint64_t usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();
> +		lensMovementStartTime_ = usecs;
> +	}
> +	lensPosition_ = latestResults.af()->next_lens_position;
> +}
> +
>  void IPAIPU3::setControls(unsigned int frame)
>  {
>  	ControlList sensorCtrls(ctrls_);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list