[libcamera-devel] [PATCH v1 3/4] ipa: rkisp1: Fill AGC and AWB metadata

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Oct 19 13:04:33 CEST 2022


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 at 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



More information about the libcamera-devel mailing list