[libcamera-devel,2/4] ipa: ipu3: af: AE and AWE lock request flow when performing AF
diff mbox series

Message ID 20220322024155.6528-3-hpa@redhat.com
State Superseded
Headers show
Series
  • ipa: ipu3: af: Temporarily suspend AWB and AE during AF scanning
Related show

Commit Message

Kate Hsuan March 22, 2022, 2:41 a.m. UTC
When AF start to work, it requests to lock the AE and AWB to stabilize
the estimated variance of the AF scene. After the algorithm determinesthe
lens position, the lock will be released immediately.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
---
 src/ipa/ipu3/algorithms/af.cpp | 22 ++++++++++++++++++++++
 src/ipa/ipu3/algorithms/af.h   |  2 ++
 2 files changed, 24 insertions(+)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
index 40a8ddae..7b9cfd05 100644
--- a/src/ipa/ipu3/algorithms/af.cpp
+++ b/src/ipa/ipu3/algorithms/af.cpp
@@ -197,6 +197,26 @@  int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)
 	return 0;
 }
 
+/**
+ * \brief Lock AE and AWB
+ * \param[in] context The shared IPA context
+ */
+void Af::afLockAeAwb(IPAContext &context)
+{
+	if (!context.frameContext.af.stable && ignoreCounter_ == 0)
+		context.configuration.af.requireAeAwbLock = true;
+}
+
+/**
+ * \brief Unlock AE and AWB
+ * \param[in] context The shared IPA context
+ */
+void Af::afUnlockAeAwb(IPAContext &context)
+{
+	if (context.frameContext.af.stable)
+		context.configuration.af.requireAeAwbLock = false;
+}
+
 /**
  * \brief AF coarse scan
  *
@@ -451,8 +471,10 @@  void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
 		currentVariance_ = afEstimateVariance(y_item, afRawBufferLen, true);
 
 	if (!context.frameContext.af.stable) {
+		afLockAeAwb(context);
 		afCoarseScan(context);
 		afFineScan(context);
+		afUnlockAeAwb(context);
 	} else {
 		if (afIsOutOfFocus(context))
 			afReset(context);
diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h
index 13c7e0e8..c03a163f 100644
--- a/src/ipa/ipu3/algorithms/af.h
+++ b/src/ipa/ipu3/algorithms/af.h
@@ -55,6 +55,8 @@  private:
 	double afEstimateVariance(y_table_item_t *y_item, uint32_t len,
 				  bool isY1);
 	bool afIsOutOfFocus(IPAContext context);
+	void afLockAeAwb(IPAContext &context);
+	void afUnlockAeAwb(IPAContext &context);
 
 	/* VCM step configuration. It is the current setting of the VCM step. */
 	uint32_t focus_;