[libcamera-devel] [PATCH v3 4/4] ipa: ipu3: af: Remove hardcoded maximum VCM steps

Kate Hsuan hpa at redhat.com
Tue Apr 26 07:58:30 CEST 2022


The hardcoded VCM step variable was removed and was replaced by the
configInfo.

Signed-off-by: Kate Hsuan<hpa at redhat.com>
---
 src/ipa/ipu3/algorithms/af.cpp | 13 ++++---------
 src/ipa/ipu3/algorithms/af.h   |  2 ++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
index f700b01f..4faf0bd8 100644
--- a/src/ipa/ipu3/algorithms/af.cpp
+++ b/src/ipa/ipu3/algorithms/af.cpp
@@ -62,12 +62,6 @@ namespace ipa::ipu3::algorithms {
 
 LOG_DEFINE_CATEGORY(IPU3Af)
 
-/**
- * Maximum focus steps of the VCM control
- * \todo should be obtained from the VCM driver
- */
-static constexpr uint32_t kMaxFocusSteps = 1023;
-
 /* Minimum focus step for searching appropriate focus */
 static constexpr uint32_t kCoarseSearchStep = 30;
 static constexpr uint32_t kFineSearchStep = 1;
@@ -179,7 +173,8 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo)
 	grid.y_start |= IPU3_UAPI_GRID_Y_START_EN;
 
 	/* Initial max focus step */
-	maxStep_ = kMaxFocusSteps;
+	maxStep_ = configInfo.sensorInfo.maxVcmSteps;
+	maxFocusSteps_ = configInfo.sensorInfo.maxVcmSteps;
 
 	/* Initial frame ignore counter */
 	afIgnoreFrameReset();
@@ -217,7 +212,7 @@ void Af::afCoarseScan(IPAContext &context)
 		context.frameContext.af.focus = focus_;
 		previousVariance_ = 0;
 		maxStep_ = std::clamp(focus_ + static_cast<uint32_t>((focus_ * kFineRange)),
-				      0U, kMaxFocusSteps);
+				      0U, maxFocusSteps_);
 	}
 }
 
@@ -262,7 +257,7 @@ void Af::afReset(IPAContext &context)
 	previousVariance_ = 0.0;
 	coarseCompleted_ = false;
 	fineCompleted_ = false;
-	maxStep_ = kMaxFocusSteps;
+	maxStep_ = maxFocusSteps_;
 }
 
 /**
diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h
index b85cf941..a1cf561c 100644
--- a/src/ipa/ipu3/algorithms/af.h
+++ b/src/ipa/ipu3/algorithms/af.h
@@ -45,6 +45,8 @@ private:
 
 	bool afIsOutOfFocus(IPAContext context);
 
+	/* Maximum VCM steps */
+	uint32_t maxFocusSteps_;
 	/* VCM step configuration. It is the current setting of the VCM step. */
 	uint32_t focus_;
 	/* The best VCM step. It is a local optimum VCM step during scanning. */
-- 
2.35.1



More information about the libcamera-devel mailing list