[libcamera-devel] [IPU3-IPA PATCH v3 5/6] ipu3: Run AIQ for the first frame to avoid blanking

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Nov 19 17:39:53 CET 2021


Quoting Han-Lin Chen (2021-11-11 10:49:07)
> 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 at chromium.org>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
>  ipu3.cpp | 44 ++++++++++++++++++++++++++------------------
>  1 file changed, 26 insertions(+), 18 deletions(-)
> 
> diff --git a/ipu3.cpp b/ipu3.cpp
> index f38440d..ffa78b3 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,
> @@ -220,6 +221,7 @@ int IPAIPU3::init(const IPASettings &settings,
>  
>  int IPAIPU3::start()
>  {
> +       runAiq(0);
>         setControls(0);
>  
>         return 0;
> @@ -369,23 +371,8 @@ 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([[maybe_unused]] 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 */
>         resultsHistory_.extendOne();
>         aiq::AiqResults& latestResults = resultsHistory_.latest();
> @@ -395,8 +382,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
>         aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;
>  
>         aiq_.run2a(frame, aiqInputParams_, latestResults);
> -       aic_.updateRuntimeParams(latestResults);
> -       aic_.run(params);
>  
>         exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;
>         gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
> @@ -413,6 +398,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
>                 lensMovementStartTime_ = msecs;
>         }
>         lensPosition_ = latestResults.af()->next_lens_position;
> +}
> +
> +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

Minor: The indentation is wrong here, but it was in the original. Could
be fixed while applying.

If I can fix the apply issues from leaving the lens change out, I'll
merge this one too with the indentation fixed. It doesn't look like
there would be any trouble to fix this up now.



> +       * 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);
> +
> +       aiq::AiqResults& latestResults = resultsHistory_.latest();
> +       aic_.updateRuntimeParams(latestResults);
> +       aic_.run(params);
>  
>         setControls(frame);
>  
> -- 
> 2.34.0.rc1.387.gb447b232ab-goog
>


More information about the libcamera-devel mailing list