[v1,23/35] ipa: rkisp1: Lazy initialise frame context
diff mbox series

Message ID 20251024085130.995967-24-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • rkisp1: pipeline rework for PFC
Related show

Commit Message

Stefan Klug Oct. 24, 2025, 8:50 a.m. UTC
For per frame control we want to tick the IPA by the sensor frame
sequence instead of the request frame sequence. This has the side effect
that the IPA must be able to cope with situations where a frame context
is required for a frame that was not queued before (computeParams is
called without a corresponding request) or processStats is called for an
unexpected sequence number (because a scratch buffer was used on kernel
side)

Prepare for that by allowing the frame context to be initialized on demand.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/awb.cpp | 2 ++
 src/ipa/rkisp1/ipa_context.h      | 2 ++
 src/ipa/rkisp1/rkisp1.cpp         | 6 ++++++
 3 files changed, 10 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index 399fb51be414..27109478c340 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -172,6 +172,8 @@  void Awb::queueRequest(IPAContext &context,
 	awbAlgo_->handleControls(controls);
 
 	frameContext.awb.autoEnabled = awb.autoEnabled;
+	frameContext.awb.gains = awb.automatic.gains;
+	frameContext.awb.temperatureK = awb.automatic.temperatureK;
 
 	if (awb.autoEnabled)
 		return;
diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
index f85a130d9c23..185951fb8286 100644
--- a/src/ipa/rkisp1/ipa_context.h
+++ b/src/ipa/rkisp1/ipa_context.h
@@ -214,6 +214,8 @@  struct IPAFrameContext : public FrameContext {
 		double strength;
 		double gain;
 	} wdr;
+
+	bool initialised;
 };
 
 struct IPAContext {
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 01b30c947a0a..23d80bc43c5d 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -343,6 +343,10 @@  void IPARkISP1::initializeFrameContext(const uint32_t frame,
 				       IPAFrameContext &frameContext,
 				       const ControlList &controls)
 {
+	if (frameContext.initialised)
+		return;
+
+	frameContext.initialised = true;
 	for (auto const &a : algorithms()) {
 		Algorithm *algo = static_cast<Algorithm *>(a.get());
 		if (algo->disabled_)
@@ -354,6 +358,7 @@  void IPARkISP1::initializeFrameContext(const uint32_t frame,
 void IPARkISP1::computeParams(const uint32_t frame, const uint32_t bufferId)
 {
 	IPAFrameContext &frameContext = context_.frameContexts.get(frame);
+	initializeFrameContext(frame, frameContext, {});
 
 	/*
 	 * \todo: This needs discussion. In raw mode, computeParams is
@@ -383,6 +388,7 @@  void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId,
 			     const ControlList &sensorControls)
 {
 	IPAFrameContext &frameContext = context_.frameContexts.get(frame);
+	initializeFrameContext(frame, frameContext, {});
 
 	/*
 	 * In raw capture mode, the ISP is bypassed and no statistics buffer is