[libcamera-devel,v2,5/6] ipu3: Run AIQ for the first frame to avoid blanking
diff mbox series

Message ID 20211029120001.2469018-5-hanlinchen@chromium.org
State Superseded
Headers show
Series
  • [libcamera-devel,v2,1/6] ipu3: Use ia_aiq_frame_use_preview as default mode for AIQ
Related show

Commit Message

Hanlin Chen Oct. 29, 2021, noon UTC
The start() function set the first exposure time and analog gain to maximum.
In result, the first frame might be over bright and the user may see a
bright blank when changing the camera in application. Run AIQ to get an
initial exposure time and analog gain in start() to smooth the AE
process.

Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
---
 ipu3.cpp | 45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

Comments

Kieran Bingham Nov. 3, 2021, 10:27 p.m. UTC | #1
Quoting Han-Lin Chen (2021-10-29 13:00:00)
> The start() function set the first exposure time and analog gain to maximum.
> In result, the first frame might be over bright and the user may see a
> bright blank when changing the camera in application. Run AIQ to get an
> initial exposure time and analog gain in start() to smooth the AE
> process.

Splitting the AIQ run to it's own function looks a lot better too

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
> ---
>  ipu3.cpp | 45 ++++++++++++++++++++++++++-------------------
>  1 file changed, 26 insertions(+), 19 deletions(-)
> 
> diff --git a/ipu3.cpp b/ipu3.cpp
> index c2dc754..2232e07 100644
> --- a/ipu3.cpp
> +++ b/ipu3.cpp
> @@ -56,6 +56,7 @@ private:
>                             const ControlInfoMap &sensorControls,
>                             ControlInfoMap *ipaControls);
>         void processControls(unsigned int frame, const ControlList &metadata);
> +       void runAiq(unsigned int frame);
>         void fillParams(unsigned int frame, ipu3_uapi_params *params);
>         void parseStatistics(unsigned int frame,
>                              int64_t frameTimestamp,
> @@ -221,6 +222,7 @@ int IPAIPU3::init(const IPASettings &settings,
>  
>  int IPAIPU3::start()
>  {
> +       runAiq(0);
>         setControls(0);
>  
>         return 0;
> @@ -370,29 +372,11 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame,
>         /* \todo Start processing for 'frame' based on 'controls'. */
>  }
>  
> -void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
> +void IPAIPU3::runAiq(unsigned int frame)
>  {
> -       /* Prepare parameters buffer. */
> -       memset(params, 0, sizeof(*params));
> -
> -       /*
> -       * Call into the AIQ object, and set up the library with any requested
> -       * controls or settings from the incoming request.
> -       *
> -       * (statistics are fed into the library as a separate event
> -       *  when available)
> -       *
> -       * - Run algorithms
> -       *
> -       * - Fill params buffer with the results of the algorithms.
> -       */
> -
>         /* Run algorithms into/using this context structure */
>         aiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_);
>  
> -       aic_.updateRuntimeParams(results_);
> -       aic_.run(params);
> -
>         exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time;
>         gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
>  
> @@ -410,6 +394,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
>         lensPosition_ = results_.af()->next_lens_position;
>  
>         resultsHistory_.Push(results_);
> +}
> +
> +void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
> +{
> +       /* Prepare parameters buffer. */
> +       memset(params, 0, sizeof(*params));
> +
> +       /*
> +       * Call into the AIQ object, and set up the library with any requested
> +       * controls or settings from the incoming request.
> +       *
> +       * (statistics are fed into the library as a separate event
> +       *  when available)
> +       *
> +       * - Run algorithms
> +       *
> +       * - Fill params buffer with the results of the algorithms.
> +       */
> +
> +       runAiq(frame);
> +
> +       aic_.updateRuntimeParams(results_);
> +       aic_.run(params);
>  
>         setControls(frame);
>  
> -- 
> 2.33.1.1089.g2158813163f-goog
>

Patch
diff mbox series

diff --git a/ipu3.cpp b/ipu3.cpp
index c2dc754..2232e07 100644
--- a/ipu3.cpp
+++ b/ipu3.cpp
@@ -56,6 +56,7 @@  private:
 			    const ControlInfoMap &sensorControls,
 			    ControlInfoMap *ipaControls);
 	void processControls(unsigned int frame, const ControlList &metadata);
+	void runAiq(unsigned int frame);
 	void fillParams(unsigned int frame, ipu3_uapi_params *params);
 	void parseStatistics(unsigned int frame,
 			     int64_t frameTimestamp,
@@ -221,6 +222,7 @@  int IPAIPU3::init(const IPASettings &settings,
 
 int IPAIPU3::start()
 {
+	runAiq(0);
 	setControls(0);
 
 	return 0;
@@ -370,29 +372,11 @@  void IPAIPU3::processControls([[maybe_unused]] unsigned int frame,
 	/* \todo Start processing for 'frame' based on 'controls'. */
 }
 
-void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
+void IPAIPU3::runAiq(unsigned int frame)
 {
-	/* Prepare parameters buffer. */
-	memset(params, 0, sizeof(*params));
-
-	/*
-	* Call into the AIQ object, and set up the library with any requested
-	* controls or settings from the incoming request.
-	*
-	* (statistics are fed into the library as a separate event
-	*  when available)
-	*
-	* - Run algorithms
-	*
-	* - Fill params buffer with the results of the algorithms.
-	*/
-
 	/* Run algorithms into/using this context structure */
 	aiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_);
 
-	aic_.updateRuntimeParams(results_);
-	aic_.run(params);
-
 	exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time;
 	gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
 
@@ -410,6 +394,29 @@  void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
 	lensPosition_ = results_.af()->next_lens_position;
 
 	resultsHistory_.Push(results_);
+}
+
+void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
+{
+	/* Prepare parameters buffer. */
+	memset(params, 0, sizeof(*params));
+
+	/*
+	* Call into the AIQ object, and set up the library with any requested
+	* controls or settings from the incoming request.
+	*
+	* (statistics are fed into the library as a separate event
+	*  when available)
+	*
+	* - Run algorithms
+	*
+	* - Fill params buffer with the results of the algorithms.
+	*/
+
+	runAiq(frame);
+
+	aic_.updateRuntimeParams(results_);
+	aic_.run(params);
 
 	setControls(frame);