[libcamera-devel] [RFC v1 2/5] libcamera: camera_lens: Get maximum VCM steps
Kate Hsuan
hpa at redhat.com
Fri Apr 15 05:01:18 CEST 2022
Hi Jacopo,
On Thu, Apr 14, 2022 at 4:22 PM Jacopo Mondi <jacopo at jmondi.org> wrote:
>
> Hi Kate,
>
> On Thu, Apr 14, 2022 at 03:43:39PM +0800, Kate Hsuan via libcamera-devel wrote:
> > It allows other components to get the maximum VCM steps. It first creates
> > a control list and set V4L2_CID_FOCUS_ABSOLUTE control to it. Then, it
> > calls a lower layer call, getAttributes() to get the maximum VCM steps
> > from the kernel.
>
> I might have missed something here.
>
> V4L2Device::controls() returns you a ControlInfoMap for all the
> controls registered on the lens subdevice, with the controls' min, max
> and default values collected at subdev open time with
> V4L2Device::listControls()
>
> Is there a reason I have missed about why you need to re-fetch the
> control's limits again ?
>
Ah. I might miss this V4L2Device::listControls(). I could try this in
my v2 patch.
Thank you.
> If you need to collect the V4L2_CID_FOCUS_ABSOLUTE control maximum
> value I think you could very well do so at validateLensDriver() time.
>
> Thanks
> j
>
> >
> > Signed-off-by: Kate Hsuan<hpa at redhat.com>
> > ---
> > include/libcamera/internal/camera_lens.h | 1 +
> > src/libcamera/camera_lens.cpp | 18 ++++++++++++++++++
> > 2 files changed, 19 insertions(+)
> >
> > diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h
> > index 277417da..48761d68 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 getFocusCapabilityies();
> >
> > const std::string &model() const { return model_; }
> >
> > diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp
> > index b3d48199..5d00652d 100644
> > --- a/src/libcamera/camera_lens.cpp
> > +++ b/src/libcamera/camera_lens.cpp
> > @@ -73,6 +73,10 @@ int CameraLens::init()
> > return ret;
> >
> > model_ = subdev_->model();
> > +
> > + ControlList lensCtrls(subdev_->controls());
> > + subdev_->getAttributes(&lensCtrls);
> > +
> > return 0;
> > }
> >
> > @@ -95,6 +99,20 @@ int CameraLens::setFocusPosition(int32_t position)
> > return 0;
> > }
> >
> > +int CameraLens::getFocusCapabilityies()
> > +{
> > + ControlValue retVal;
> > + ControlList lensCtrls(subdev_->controls());
> > + int32_t ret = 2023;
> > +
> > + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, static_cast<int32_t>(ret));
> > + subdev_->getAttributes(&lensCtrls);
> > + retVal = lensCtrls.get(V4L2_CID_FOCUS_ABSOLUTE);
> > + ret = retVal.get<int32_t>();
> > +
> > + return ret;
> > +}
> > +
> > int CameraLens::validateLensDriver()
> > {
> > int ret = 0;
> > --
> > 2.35.1
> >
>
--
BR,
Kate
More information about the libcamera-devel
mailing list