[libcamera-devel] [PATCH v3 22/23] libcamera: camera_lens: Expose libcamera control limits
Jacopo Mondi
jacopo at jmondi.org
Thu Jun 30 15:39:01 CEST 2022
The CameraLens class exposes the list of V4L2 controls through
the CameraLens::controls() function.
Modify the implementation to expose the newly introduced
LensFocusAbsolute control limits.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/internal/camera_lens.h | 5 +++-
src/libcamera/camera_lens.cpp | 33 ++++++++++++++++++------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h
index 277417daffed..ea98379ecc62 100644
--- a/include/libcamera/internal/camera_lens.h
+++ b/include/libcamera/internal/camera_lens.h
@@ -30,7 +30,7 @@ public:
const std::string &model() const { return model_; }
- const ControlInfoMap &controls() const;
+ const ControlInfoMap &controls() const { return controls_; }
protected:
std::string logPrefix() const override;
@@ -39,11 +39,14 @@ private:
LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraLens)
int validateLensDriver();
+ void updateControls();
const MediaEntity *entity_;
std::unique_ptr<V4L2Subdevice> subdev_;
std::string model_;
+
+ ControlInfoMap controls_;
};
} /* namespace libcamera */
diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp
index b3d48199ec3b..08c2c42a9cfa 100644
--- a/src/libcamera/camera_lens.cpp
+++ b/src/libcamera/camera_lens.cpp
@@ -9,6 +9,7 @@
#include <libcamera/base/utils.h>
+#include "libcamera/internal/control_ids.h"
#include "libcamera/internal/v4l2_subdevice.h"
/**
@@ -73,6 +74,9 @@ int CameraLens::init()
return ret;
model_ = subdev_->model();
+
+ updateControls();
+
return 0;
}
@@ -124,6 +128,13 @@ int CameraLens::validateLensDriver()
return ret;
}
+/**
+ * \fn CameraLens::controls()
+ * \brief Retrieve the CameraLens controls limits
+ *
+ * \return The ControlInfoMap with the CameraLens controls limits
+ */
+
/**
* \fn CameraLens::model()
* \brief Retrieve the lens model name
@@ -139,15 +150,21 @@ std::string CameraLens::logPrefix() const
return "'" + entity_->name() + "'";
}
-/**
- * \fn CameraLens::controls()
- * \brief Retrieve the V4L2 controls of the lens' subdev
- *
- * \return A map of the V4L2 controls supported by the lens' driver
- */
-const ControlInfoMap &CameraLens::controls() const
+void CameraLens::updateControls()
{
- return subdev_->controls();
+ ControlInfoMap::Map controls;
+
+ /* The lens driver has been validate, the control is there. */
+ const ControlInfoMap &lensControls = subdev_->controls();
+ const ControlInfo &focusAbsolute = lensControls.at(V4L2_CID_FOCUS_ABSOLUTE);
+
+ controls[&controls::internal::draft::LensFocusAbsolute] =
+ ControlInfo(focusAbsolute.min().get<int32_t>(),
+ focusAbsolute.max().get<int32_t>(),
+ focusAbsolute.def().get<int32_t>());
+
+ controls_ = ControlInfoMap(std::move(controls),
+ controls::internal::controls);
}
} /* namespace libcamera */
--
2.36.1
More information about the libcamera-devel
mailing list