[libcamera-devel,v1,3/4] ipa: rkisp1: Fill AGC and AWB metadata
diff mbox series

Message ID 20221019110434.17767-4-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • ipa: Fill metadata in individual algorithms
Related show

Commit Message

Laurent Pinchart Oct. 19, 2022, 11:04 a.m. UTC
Fill the frame metadata in the AGC and AWB algorithm's prepare()
function. Additional metadata for other algorithms will be addressed
later.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/agc.cpp | 9 ++++++++-
 src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

Comments

Kieran Bingham Oct. 19, 2022, 11:41 a.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2022-10-19 12:04:33)
> Fill the frame metadata in the AGC and AWB algorithm's prepare()
> function. Additional metadata for other algorithms will be addressed
> later.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/agc.cpp | 9 ++++++++-
>  src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++++-
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> index 9de11a2a3bca..a909d8aa59ea 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -16,6 +16,8 @@
>  
>  #include <libcamera/ipa/core_ipa_interface.h>
>  
> +#include <libcamera/control_ids.h>
> +
>  #include "libipa/histogram.h"
>  
>  /**
> @@ -289,7 +291,7 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const
>   */
>  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>                   IPAFrameContext &frameContext,
> -                 [[maybe_unused]] ControlList &metadata,
> +                 ControlList &metadata,
>                   const rkisp1_stat_buffer *stats)
>  {
>         /*
> @@ -333,6 +335,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>  
>         computeExposure(context, frameContext, yGain, iqMeanGain);
>         frameCount_++;
> +
> +       utils::Duration exposureTime = context.configuration.sensor.lineDuration
> +                                    * frameContext.sensor.exposure;
> +       metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
> +       metadata.set(controls::ExposureTime, exposureTime.get<std::micro>());
>  }
>  
>  /**
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index 9b97db7d5c5a..93888a8e7412 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -208,7 +208,7 @@ void Awb::queueRequest(IPAContext &context,
>  void Awb::process(IPAContext &context,
>                   [[maybe_unused]] const uint32_t frame,
>                   IPAFrameContext &frameContext,
> -                 [[maybe_unused]] ControlList &metadata,
> +                 ControlList &metadata,
>                   const rkisp1_stat_buffer *stats)
>  {
>         const rkisp1_cif_isp_stat *params = &stats->params;
> @@ -307,6 +307,12 @@ void Awb::process(IPAContext &context,
>  
>         frameContext.awb.temperatureK = activeState.awb.temperatureK;

Can you add this one here too please?

	metadata.set(controls::ColourTemperature,
		     frameContext.awb.temperatureK);

With that

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

> +       metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled);
> +       metadata.set(controls::ColourGains, {
> +                       static_cast<float>(frameContext.awb.gains.red),
> +                       static_cast<float>(frameContext.awb.gains.blue)
> +               });
> +
>         LOG(RkISP1Awb, Debug) << std::showpoint
>                 << "Means [" << redMean << ", " << greenMean << ", " << blueMean
>                 << "], gains [" << activeState.awb.gains.automatic.red << ", "
> -- 
> Regards,
> 
> Laurent Pinchart
>
Jacopo Mondi Oct. 19, 2022, 11:51 a.m. UTC | #2
With the question on 2/4 pending, this one in isolation is fine

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

On Wed, Oct 19, 2022 at 02:04:33PM +0300, Laurent Pinchart via libcamera-devel wrote:
> Fill the frame metadata in the AGC and AWB algorithm's prepare()
> function. Additional metadata for other algorithms will be addressed
> later.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/agc.cpp | 9 ++++++++-
>  src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++++-
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> index 9de11a2a3bca..a909d8aa59ea 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -16,6 +16,8 @@
>
>  #include <libcamera/ipa/core_ipa_interface.h>
>
> +#include <libcamera/control_ids.h>
> +
>  #include "libipa/histogram.h"
>
>  /**
> @@ -289,7 +291,7 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const
>   */
>  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>  		  IPAFrameContext &frameContext,
> -		  [[maybe_unused]] ControlList &metadata,
> +		  ControlList &metadata,
>  		  const rkisp1_stat_buffer *stats)
>  {
>  	/*
> @@ -333,6 +335,11 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
>
>  	computeExposure(context, frameContext, yGain, iqMeanGain);
>  	frameCount_++;
> +
> +	utils::Duration exposureTime = context.configuration.sensor.lineDuration
> +				     * frameContext.sensor.exposure;
> +	metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
> +	metadata.set(controls::ExposureTime, exposureTime.get<std::micro>());
>  }
>
>  /**
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index 9b97db7d5c5a..93888a8e7412 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -208,7 +208,7 @@ void Awb::queueRequest(IPAContext &context,
>  void Awb::process(IPAContext &context,
>  		  [[maybe_unused]] const uint32_t frame,
>  		  IPAFrameContext &frameContext,
> -		  [[maybe_unused]] ControlList &metadata,
> +		  ControlList &metadata,
>  		  const rkisp1_stat_buffer *stats)
>  {
>  	const rkisp1_cif_isp_stat *params = &stats->params;
> @@ -307,6 +307,12 @@ void Awb::process(IPAContext &context,
>
>  	frameContext.awb.temperatureK = activeState.awb.temperatureK;
>
> +	metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled);
> +	metadata.set(controls::ColourGains, {
> +			static_cast<float>(frameContext.awb.gains.red),
> +			static_cast<float>(frameContext.awb.gains.blue)
> +		});
> +
>  	LOG(RkISP1Awb, Debug) << std::showpoint
>  		<< "Means [" << redMean << ", " << greenMean << ", " << blueMean
>  		<< "], gains [" << activeState.awb.gains.automatic.red << ", "
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 9de11a2a3bca..a909d8aa59ea 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -16,6 +16,8 @@ 
 
 #include <libcamera/ipa/core_ipa_interface.h>
 
+#include <libcamera/control_ids.h>
+
 #include "libipa/histogram.h"
 
 /**
@@ -289,7 +291,7 @@  double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const
  */
 void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 		  IPAFrameContext &frameContext,
-		  [[maybe_unused]] ControlList &metadata,
+		  ControlList &metadata,
 		  const rkisp1_stat_buffer *stats)
 {
 	/*
@@ -333,6 +335,11 @@  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 
 	computeExposure(context, frameContext, yGain, iqMeanGain);
 	frameCount_++;
+
+	utils::Duration exposureTime = context.configuration.sensor.lineDuration
+				     * frameContext.sensor.exposure;
+	metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
+	metadata.set(controls::ExposureTime, exposureTime.get<std::micro>());
 }
 
 /**
diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index 9b97db7d5c5a..93888a8e7412 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -208,7 +208,7 @@  void Awb::queueRequest(IPAContext &context,
 void Awb::process(IPAContext &context,
 		  [[maybe_unused]] const uint32_t frame,
 		  IPAFrameContext &frameContext,
-		  [[maybe_unused]] ControlList &metadata,
+		  ControlList &metadata,
 		  const rkisp1_stat_buffer *stats)
 {
 	const rkisp1_cif_isp_stat *params = &stats->params;
@@ -307,6 +307,12 @@  void Awb::process(IPAContext &context,
 
 	frameContext.awb.temperatureK = activeState.awb.temperatureK;
 
+	metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled);
+	metadata.set(controls::ColourGains, {
+			static_cast<float>(frameContext.awb.gains.red),
+			static_cast<float>(frameContext.awb.gains.blue)
+		});
+
 	LOG(RkISP1Awb, Debug) << std::showpoint
 		<< "Means [" << redMean << ", " << greenMean << ", " << blueMean
 		<< "], gains [" << activeState.awb.gains.automatic.red << ", "