[libcamera-devel,v3,4/4] ipa: ipu3: af: Remove hardcoded maximum VCM steps
diff mbox series

Message ID 20220426055830.8999-5-hpa@redhat.com
State New
Headers show
Series
  • Enabling AF algorithm to get the VCM attributes from the device driver
Related show

Commit Message

Kate Hsuan April 26, 2022, 5:58 a.m. UTC
The hardcoded VCM step variable was removed and was replaced by the
configInfo.

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

Patch
diff mbox series

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. */