[libcamera-devel,RFC,v2,2/4] libcamera: camera_lens: Get maximum VCM steps
diff mbox series

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

Commit Message

Kate Hsuan April 21, 2022, 7:28 a.m. UTC
It allows other components to get the maximum VCM steps. It get the device
information from subdev and return it's maximum value.

Signed-off-by: Kate Hsuan<hpa@redhat.com>
---
 include/libcamera/internal/camera_lens.h |  1 +
 src/libcamera/camera_lens.cpp            | 13 +++++++++++++
 2 files changed, 14 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h
index 277417da..84b3c884 100644
--- a/include/libcamera/internal/camera_lens.h
+++ b/include/libcamera/internal/camera_lens.h
@@ -27,6 +27,7 @@  public:
 
 	int init();
 	int setFocusPosition(int32_t position);
+	int getMaxFocusStep();
 
 	const std::string &model() const { return model_; }
 
diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp
index b3d48199..b9810551 100644
--- a/src/libcamera/camera_lens.cpp
+++ b/src/libcamera/camera_lens.cpp
@@ -95,6 +95,19 @@  int CameraLens::setFocusPosition(int32_t position)
 	return 0;
 }
 
+/**
+ * \brief Get maximum lens steps
+ * \return The maximum lens steps.
+ */
+int CameraLens::getMaxFocusStep()
+{
+	const ControlInfoMap &infoMap_ = subdev_->controls();
+	const ControlInfo devInfo = infoMap_.find(V4L2_CID_FOCUS_ABSOLUTE)->second;
+	int32_t maxFocus = devInfo.max().get<int32_t>();
+
+	return maxFocus;
+}
+
 int CameraLens::validateLensDriver()
 {
 	int ret = 0;