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

Message ID 20220426055830.8999-3-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
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;