[libcamera-devel,IPAIPU3,v5,5/6] ipu3: Inline fillParams() in fillParamsBuffer()
diff mbox series

Message ID 20220406141709.164794-6-umang.jain@ideasonboard.com
State Accepted
Headers show
Series
  • ipa: ipu3: Replace event-based ops with dedicated functions
Related show

Commit Message

Umang Jain April 6, 2022, 2:17 p.m. UTC
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@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 ipu3.cpp | 52 +++++++++++++++++++++++-----------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)

Comments

Kieran Bingham April 7, 2022, 10:19 p.m. UTC | #1
Quoting Umang Jain via libcamera-devel (2022-04-06 15:17:08)
> 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@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  ipu3.cpp | 52 +++++++++++++++++++++++-----------------------------
>  1 file changed, 23 insertions(+), 29 deletions(-)
> 
> diff --git a/ipu3.cpp b/ipu3.cpp
> index b6d2129..0543a2e 100644
> --- a/ipu3.cpp
> +++ b/ipu3.cpp
> @@ -60,7 +60,6 @@ private:
>                             const ControlInfoMap &sensorControls,
>                             ControlInfoMap *ipaControls);
>         void runAiq(unsigned int frame);
> -       void fillParams(unsigned int frame, ipu3_uapi_params *params);
>         void parseStatistics(unsigned int frame,
>                              int64_t frameTimestamp,
>                              const ipu3_uapi_stats_3a *stats,
> @@ -342,7 +341,29 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
>         ipu3_uapi_params *params =
>                 reinterpret_cast<ipu3_uapi_params *>(mem.data());
>  
> -       fillParams(frame, 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);
> +
> +       aiq::AiqResults& latestResults = resultsHistory_.latest();
> +       aic_.updateRuntimeParams(latestResults);
> +       aic_.run(params);
> +
> +       setControls(frame);
> +
> +       paramsBufferReady.emit(frame);
>  }
>  
>  void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp,
> @@ -390,33 +411,6 @@ void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
>         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
> -        * 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);
> -
> -       paramsBufferReady.emit(frame);
> -}
> -
>  void IPAIPU3::parseStatistics(unsigned int frame,
>                               int64_t frameTimestamp,
>                               const ipu3_uapi_stats_3a *stats,
> -- 
> 2.31.0
>
Nicolas Dufresne via libcamera-devel April 8, 2022, 7:18 a.m. UTC | #2
Hi Umang,

On Wed, Apr 06, 2022 at 07:47:08PM +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@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  ipu3.cpp | 52 +++++++++++++++++++++++-----------------------------
>  1 file changed, 23 insertions(+), 29 deletions(-)
> 
> diff --git a/ipu3.cpp b/ipu3.cpp
> index b6d2129..0543a2e 100644
> --- a/ipu3.cpp
> +++ b/ipu3.cpp
> @@ -60,7 +60,6 @@ private:
>  			    const ControlInfoMap &sensorControls,
>  			    ControlInfoMap *ipaControls);
>  	void runAiq(unsigned int frame);
> -	void fillParams(unsigned int frame, ipu3_uapi_params *params);
>  	void parseStatistics(unsigned int frame,
>  			     int64_t frameTimestamp,
>  			     const ipu3_uapi_stats_3a *stats,
> @@ -342,7 +341,29 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
>  	ipu3_uapi_params *params =
>  		reinterpret_cast<ipu3_uapi_params *>(mem.data());
>  
> -	fillParams(frame, 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);
> +
> +	aiq::AiqResults& latestResults = resultsHistory_.latest();
> +	aic_.updateRuntimeParams(latestResults);
> +	aic_.run(params);
> +
> +	setControls(frame);
> +
> +	paramsBufferReady.emit(frame);
>  }
>  
>  void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp,
> @@ -390,33 +411,6 @@ void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
>  	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
> -	 * 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);
> -
> -	paramsBufferReady.emit(frame);
> -}
> -
>  void IPAIPU3::parseStatistics(unsigned int frame,
>  			      int64_t frameTimestamp,
>  			      const ipu3_uapi_stats_3a *stats,
> -- 
> 2.31.0
>

Patch
diff mbox series

diff --git a/ipu3.cpp b/ipu3.cpp
index b6d2129..0543a2e 100644
--- a/ipu3.cpp
+++ b/ipu3.cpp
@@ -60,7 +60,6 @@  private:
 			    const ControlInfoMap &sensorControls,
 			    ControlInfoMap *ipaControls);
 	void runAiq(unsigned int frame);
-	void fillParams(unsigned int frame, ipu3_uapi_params *params);
 	void parseStatistics(unsigned int frame,
 			     int64_t frameTimestamp,
 			     const ipu3_uapi_stats_3a *stats,
@@ -342,7 +341,29 @@  void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
 	ipu3_uapi_params *params =
 		reinterpret_cast<ipu3_uapi_params *>(mem.data());
 
-	fillParams(frame, 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);
+
+	aiq::AiqResults& latestResults = resultsHistory_.latest();
+	aic_.updateRuntimeParams(latestResults);
+	aic_.run(params);
+
+	setControls(frame);
+
+	paramsBufferReady.emit(frame);
 }
 
 void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp,
@@ -390,33 +411,6 @@  void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
 	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
-	 * 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);
-
-	paramsBufferReady.emit(frame);
-}
-
 void IPAIPU3::parseStatistics(unsigned int frame,
 			      int64_t frameTimestamp,
 			      const ipu3_uapi_stats_3a *stats,