[RFC,6/7] ipa: softipa: Move camhelper to context
diff mbox series

Message ID 20251011160335.50578-7-kieran.bingham@ideasonboard.com
State New
Headers show
Series
  • Preparatory cleanup for libipa rework.
Related show

Commit Message

Kieran Bingham Oct. 11, 2025, 4:03 p.m. UTC
Move the camhelper to the context structure so that it can be accessible
for algorithms to use directly where needed.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/simple/ipa_context.h   |  3 +++
 src/ipa/simple/soft_simple.cpp | 21 ++++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
index c3081e3069b5..3d6a8b72861f 100644
--- a/src/ipa/simple/ipa_context.h
+++ b/src/ipa/simple/ipa_context.h
@@ -16,6 +16,7 @@ 
 #include "libcamera/internal/matrix.h"
 #include "libcamera/internal/vector.h"
 
+#include <libipa/camera_sensor_helper.h>
 #include <libipa/fc_queue.h>
 
 #include "core_ipa_interface.h"
@@ -103,6 +104,8 @@  struct IPAContext {
 	FCQueue<IPAFrameContext> frameContexts;
 	ControlInfoMap::Map ctrlMap;
 	bool ccmEnabled = false;
+
+	std::unique_ptr<CameraSensorHelper> camHelper;
 };
 
 } /* namespace ipa::soft */
diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp
index 0821d214815f..68ddf71e9f24 100644
--- a/src/ipa/simple/soft_simple.cpp
+++ b/src/ipa/simple/soft_simple.cpp
@@ -76,7 +76,6 @@  private:
 
 	DebayerParams *params_;
 	SwIspStats *stats_;
-	std::unique_ptr<CameraSensorHelper> camHelper_;
 	ControlInfoMap sensorInfoMap_;
 
 	/* Local parameter storage */
@@ -99,8 +98,8 @@  int IPASoftSimple::init(const IPASettings &settings,
 			ControlInfoMap *ipaControls,
 			bool *ccmEnabled)
 {
-	camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);
-	if (!camHelper_) {
+	context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);
+	if (!context_.camHelper) {
 		LOG(IPASoft, Warning)
 			<< "Failed to create camera sensor helper for "
 			<< settings.sensorModel;
@@ -220,15 +219,15 @@  int IPASoftSimple::configure(const IPAConfigInfo &configInfo,
 	int32_t againMax = gainInfo.max().get<int32_t>();
 	int32_t againDef = gainInfo.def().get<int32_t>();
 
-	if (camHelper_) {
-		context_.configuration.agc.againMin = camHelper_->gain(againMin);
-		context_.configuration.agc.againMax = camHelper_->gain(againMax);
-		context_.configuration.agc.again10 = camHelper_->gain(1.0);
+	if (context_.camHelper) {
+		context_.configuration.agc.againMin = context_.camHelper->gain(againMin);
+		context_.configuration.agc.againMax = context_.camHelper->gain(againMax);
+		context_.configuration.agc.again10 = context_.camHelper->gain(1.0);
 		context_.configuration.agc.againMinStep =
 			(context_.configuration.agc.againMax -
 			 context_.configuration.agc.againMin) /
 			100.0;
-		if (camHelper_->blackLevel().has_value()) {
+		if (context_.camHelper->blackLevel().has_value()) {
 			/*
 			 * The black level from camHelper_ is a 16 bit value, software ISP
 			 * works with 8 bit pixel values, both regardless of the actual
@@ -236,7 +235,7 @@  int IPASoftSimple::configure(const IPAConfigInfo &configInfo,
 			 * by dividing the value from the helper by 256.
 			 */
 			context_.configuration.black.level =
-				camHelper_->blackLevel().value() / 256;
+				context_.camHelper->blackLevel().value() / 256;
 		}
 	} else {
 		/*
@@ -313,7 +312,7 @@  void IPASoftSimple::processStats(const uint32_t frame,
 	frameContext.sensor.exposure =
 		sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();
 	int32_t again = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>();
-	frameContext.sensor.gain = camHelper_ ? camHelper_->gain(again) : again;
+	frameContext.sensor.gain = context_.camHelper ? context_.camHelper->gain(again) : again;
 
 	ControlList metadata(controls::controls);
 	for (auto const &algo : algorithms())
@@ -332,7 +331,7 @@  void IPASoftSimple::processStats(const uint32_t frame,
 	auto &againNew = frameContext.sensor.gain;
 	ctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure);
 	ctrls.set(V4L2_CID_ANALOGUE_GAIN,
-		  static_cast<int32_t>(camHelper_ ? camHelper_->gainCode(againNew) : againNew));
+		  static_cast<int32_t>(context_.camHelper ? context_.camHelper->gainCode(againNew) : againNew));
 
 	setSensorControls.emit(ctrls);
 }