[5/5] ipa: libipa: awb: Add AwbTrigger control
diff mbox series

Message ID 20260928-awb-state-v1-5-9b1bb8b9e51b@ideasonboard.com
State New
Headers show
Series
  • Add AwbState metadata and AwbTrigger control
Related show

Commit Message

Dan Scally Sept. 28, 2026, 11:14 a.m. UTC
Add the AwbTrigger control, which works when AwbEnable == false and
allows the algorithm to settle into the Converged state before
updating the manual gains and applying them.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
 src/ipa/libipa/awb.cpp | 18 +++++++++++++++++-
 src/ipa/libipa/awb.h   |  1 +
 2 files changed, 18 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/awb.cpp b/src/ipa/libipa/awb.cpp
index 0c6a01bd780ce00d21c1f7fdd8ba2ed468c4f4a1..2001275fc82c91172a86c5bda5925bb624da414d 100644
--- a/src/ipa/libipa/awb.cpp
+++ b/src/ipa/libipa/awb.cpp
@@ -235,6 +235,7 @@  int AwbAlgorithmBase::init(const ValueNode &tuningData)
 		ControlInfo(kMinColourTemperature, kMaxColourTemperature,
 			    kDefaultColourTemperature);
 	controls_[&controls::AwbEnable] = ControlInfo(false, true);
+	controls_[&controls::AwbTrigger] = ControlInfo(false, true);
 
 	return parseModeConfigs(tuningData, controls::AwbAuto);
 }
@@ -308,6 +309,13 @@  void AwbAlgorithmBase::queueRequest(awb::ActiveState &state,
 		currentMode_ = &it->second;
 	}
 
+	auto trigger = controls.get(controls::AwbTrigger);
+	if (trigger && *trigger && !state.autoEnabled) {
+		lockedCount_ = 0;
+		convergedState_ = controls::AwbStateEnum::AwbStateSearching;
+		rescanning_ = true;
+	}
+
 	frameContext.autoEnabled = state.autoEnabled;
 
 	if (frameContext.autoEnabled)
@@ -447,13 +455,21 @@  void AwbAlgorithmBase::process(awb::ActiveState &state,
 
 	RGB<double> newGains = awbResult.gains * speed +
 			       state.automatic.gains * (1 - speed);
-	updateConvergedState(state.automatic.gains, newGains);
+	if (state.autoEnabled || rescanning_)
+		updateConvergedState(state.automatic.gains, newGains);
 	state.automatic.colourTemperature = awbResult.colourTemperature;
 	state.automatic.gains = newGains;
 
 	if (state.autoEnabled)
 		state.manual.gains = newGains;
 
+	if (rescanning_ &&
+	    convergedState_ == controls::AwbStateEnum::AwbStateConverged) {
+		state.manual.gains = newGains;
+		rescanning_ = false;
+		convergedState_ = controls::AwbStateEnum::AwbStateLocked;
+	}
+
 	/* Populate metadata. */
 	metadata.set(controls::AwbEnable, frameContext.autoEnabled);
 	metadata.set(controls::ColourGains, { static_cast<float>(frameContext.gains.r()),
diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h
index 5d80f241ec92280e867af5f9724471c5784683d1..588d8c5a9fb179a0c7a11143659fa400befa60b0 100644
--- a/src/ipa/libipa/awb.h
+++ b/src/ipa/libipa/awb.h
@@ -112,6 +112,7 @@  private:
 	controls::AwbStateEnum convergedState_;
 	RGB<double> convergedGains_;
 	unsigned int lockedCount_;
+	bool rescanning_;
 };
 
 template<typename Q>