[libcamera-devel,v2,2/3] ipa: ipu3: af: Trigger AF after AGC is stable
diff mbox series

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

Commit Message

Kate Hsuan May 6, 2022, 5:18 a.m. UTC
AGC stable status is used to determine that AF is triggered or paused.
If AGC is ready, AF can start to evaluate the lens position.

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

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
index f700b01f..8cabd064 100644
--- a/src/ipa/ipu3/algorithms/af.cpp
+++ b/src/ipa/ipu3/algorithms/af.cpp
@@ -403,6 +403,16 @@  bool Af::afIsOutOfFocus(IPAContext context)
 		return false;
 }
 
+void Af::pause(IPAContext &context)
+{
+	context.frameContext.af.focus = focus_;
+}
+
+bool Af::isAgcStable(IPAContext context)
+{
+	return context.frameContext.agc.stable;
+}
+
 /**
  * \brief Determine the max contrast image and lens position.
  * \param[in] context The IPA context.
@@ -421,6 +431,8 @@  bool Af::afIsOutOfFocus(IPAContext context)
  */
 void Af::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
 {
+	if (!isAgcStable(context))
+		pause(context);
 	/* Evaluate the AF buffer length */
 	uint32_t afRawBufferLen = context.configuration.af.afGrid.width *
 				  context.configuration.af.afGrid.height;
diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h
index b85cf941..c1c9d39e 100644
--- a/src/ipa/ipu3/algorithms/af.h
+++ b/src/ipa/ipu3/algorithms/af.h
@@ -44,6 +44,8 @@  private:
 	double afEstimateVariance(Span<const y_table_item_t> y_items, bool isY1);
 
 	bool afIsOutOfFocus(IPAContext context);
+	bool isAgcStable(IPAContext context);
+	void pause(IPAContext &context);
 
 	/* VCM step configuration. It is the current setting of the VCM step. */
 	uint32_t focus_;