[libcamera-devel] [RFC PATCH 3/4] libcamera: lens: Add a helper to get the fixed range lens values
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Jun 9 11:34:27 CEST 2022
On Thu, Jun 09, 2022 at 08:03:05AM +0200, Jean-Michel Hautbois via libcamera-devel wrote:
> When the focus algorithm runs, it can be asked to go to a specific
> position, through the controls::LensPosition control. Those controls
> need specific values to be known, in particular the minimum and maximum
> value the driver can set to the lens to make it move to a given
> position.
>
> Add a new helper on the camera lens side to get this range or a default
> nulled structure if it is not available. This particular value needs to
> be taken into account by the caller and it shall use the minimum and
> maximum reported by the driver.
>
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
> ---
> include/libcamera/internal/camera_lens.h | 1 +
> .../internal/camera_lens_properties.h | 2 ++
> src/libcamera/camera_lens.cpp | 19 +++++++++++++++++++
> src/libcamera/camera_lens_properties.cpp | 9 ++++++++-
> 4 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h
> index 523a1481..f6daff01 100644
> --- a/include/libcamera/internal/camera_lens.h
> +++ b/include/libcamera/internal/camera_lens.h
> @@ -29,6 +29,7 @@ public:
>
> int init();
> int setFocusPosition(int32_t position);
> + const Size &getLensRange();
>
> const std::string &model() const { return model_; }
>
> diff --git a/include/libcamera/internal/camera_lens_properties.h b/include/libcamera/internal/camera_lens_properties.h
> index 73982550..7424b375 100644
> --- a/include/libcamera/internal/camera_lens_properties.h
> +++ b/include/libcamera/internal/camera_lens_properties.h
> @@ -17,6 +17,8 @@ namespace libcamera {
>
> struct CameraLensProperties {
> static const CameraLensProperties *get(const std::string &lens);
> +
> + Size lensFocusRange;
> };
>
> } /* namespace libcamera */
> diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp
> index d4d44bc7..abec5a27 100644
> --- a/src/libcamera/camera_lens.cpp
> +++ b/src/libcamera/camera_lens.cpp
> @@ -79,6 +79,25 @@ int CameraLens::init()
> return 0;
> }
>
> +/**
> + * \brief Retrieve the lens position range
> + * \return The minimum and maximum positions for the given lens or a default
> + * nulled Size reference
> + *
> + * If a lens has no static properties associated, a special value is returned,
> + * where the minimum and maximum are set to 0. The caller may then chose the
> + * ones returned by the V4L2_CID_FOCUS_ABSOLUTE call.
> + */
> +const Size &CameraLens::getLensRange()
> +{
> + static const Size defaultLensFocusRange = { 0, 0 };
> + if (!staticProps_ || staticProps_->lensFocusRange.isNull())
> + return defaultLensFocusRange;
> +
> + return staticProps_->lensFocusRange;
> +}
> +
> +
> /**
> * \brief This function sets the focal point of the lens to a specific position.
> * \param[in] position The focal point of the lens
> diff --git a/src/libcamera/camera_lens_properties.cpp b/src/libcamera/camera_lens_properties.cpp
> index dee73b43..225546ae 100644
> --- a/src/libcamera/camera_lens_properties.cpp
> +++ b/src/libcamera/camera_lens_properties.cpp
> @@ -32,6 +32,9 @@ LOG_DEFINE_CATEGORY(CameraLensProperties)
> /**
> * \struct CameraLensProperties
> * \brief Database of camera lens properties
> + *
> + * \var CameraLensProperties::lensFocusRange
> + * \brief The limits for the sensor position, stored as a min and a max.
> */
>
> /**
> @@ -42,7 +45,11 @@ LOG_DEFINE_CATEGORY(CameraLensProperties)
> */
> const CameraLensProperties *CameraLensProperties::get(const std::string &lens)
> {
> - static const std::map<std::string, const CameraLensProperties> lensProps = {};
> + static const std::map<std::string, const CameraLensProperties> lensProps = {
> + { "dw9714", {
> + .lensFocusRange = { 150, 800 },
> + } },
> + };
This partly answers the question I asked in a reply to the cover letter.
What makes you think the lens focus range is an intrinsic property of
the VCM driver ?
>
> const auto it = lensProps.find(lens);
> if (it == lensProps.end()) {
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list