Message ID | 20220630133902.321099-23-jacopo@jmondi.org |
---|---|
State | Not Applicable, archived |
Headers | show |
Series |
|
Related | show |
Quoting Jacopo Mondi via libcamera-devel (2022-06-30 14:39:01) > 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@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. */ /validate/validated/ This looks good to me, but has the corresponding functions for setting the control been updated? Now that we have libcamera controls in here, I expect the IPA can pass a single ControlList over, and the CameraLens can just extract only the controls it can handle... I.e. it would only set the LensFocusAbsolute control - after having converted it to any VCM specific V4L2 units required. But for this patch so far, I think Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > + 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 >
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 */
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@jmondi.org> --- include/libcamera/internal/camera_lens.h | 5 +++- src/libcamera/camera_lens.cpp | 33 ++++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-)