[RFC,3/4] ipa: ipu3: agc: Do not derive from AgcMeanLuminance
diff mbox series

Message ID 20250818082909.2001635-4-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • libipa: agc_mean_luminance: Use composition instead of
Related show

Commit Message

Stefan Klug Aug. 18, 2025, 8:28 a.m. UTC
There is no need to derive from AgcMeanLuminance anymore. Use
composition for easier understanding.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 src/ipa/ipu3/algorithms/agc.cpp | 22 +++++++++++-----------
 src/ipa/ipu3/algorithms/agc.h   |  4 +++-
 2 files changed, 14 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index 98a034a47625..3a1d81734cad 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -77,11 +77,11 @@  int Agc::init(IPAContext &context, const YamlObject &tuningData)
 {
 	int ret;
 
-	ret = parseTuningData(tuningData);
+	ret = agc_.parseTuningData(tuningData);
 	if (ret)
 		return ret;
 
-	context.ctrlMap.merge(controls());
+	context.ctrlMap.merge(agc_.controls());
 
 	return 0;
 }
@@ -113,13 +113,13 @@  int Agc::configure(IPAContext &context,
 	activeState.agc.gain = minAnalogueGain_;
 	activeState.agc.exposure = 10ms / configuration.sensor.lineDuration;
 
-	context.activeState.agc.constraintMode = constraintModes().begin()->first;
-	context.activeState.agc.exposureMode = exposureModeHelpers().begin()->first;
+	context.activeState.agc.constraintMode = agc_.constraintModes().begin()->first;
+	context.activeState.agc.exposureMode = agc_.exposureModeHelpers().begin()->first;
 
 	/* \todo Run this again when FrameDurationLimits is passed in */
-	setLimits(minExposureTime_, maxExposureTime_, minAnalogueGain_,
-		  maxAnalogueGain_);
-	resetFrameCount();
+	agc_.setLimits(minExposureTime_, maxExposureTime_, minAnalogueGain_,
+		       maxAnalogueGain_);
+	agc_.resetFrameCount();
 
 	return 0;
 }
@@ -225,10 +225,10 @@  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 	utils::Duration newExposureTime;
 	double aGain, dGain;
 	std::tie(newExposureTime, aGain, dGain) =
-		calculateNewEv(std::bind(&Agc::estimateLuminance, this, _1),
-			       context.activeState.agc.constraintMode,
-			       context.activeState.agc.exposureMode, hist,
-			       effectiveExposureValue);
+		agc_.calculateNewEv(std::bind(&Agc::estimateLuminance, this, _1),
+				    context.activeState.agc.constraintMode,
+				    context.activeState.agc.exposureMode, hist,
+				    effectiveExposureValue);
 
 	LOG(IPU3Agc, Debug)
 		<< "Divided up exposure time, analogue gain and digital gain are "
diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h
index 8e182cd7cff3..a9ba78028251 100644
--- a/src/ipa/ipu3/algorithms/agc.h
+++ b/src/ipa/ipu3/algorithms/agc.h
@@ -24,7 +24,7 @@  struct IPACameraSensorInfo;
 
 namespace ipa::ipu3::algorithms {
 
-class Agc : public Algorithm, public AgcMeanLuminance
+class Agc : public Algorithm
 {
 public:
 	Agc();
@@ -42,6 +42,8 @@  private:
 	Histogram parseStatistics(const ipu3_uapi_stats_3a *stats,
 				  const ipu3_uapi_grid_config &grid);
 
+	AgcMeanLuminance agc_;
+
 	utils::Duration minExposureTime_;
 	utils::Duration maxExposureTime_;