[libcamera-devel] Problems with getControls() and listControls()

Naushir Patuck naush at raspberrypi.com
Fri Mar 5 10:11:10 CET 2021


Hi Kieran,

On Thu, 4 Mar 2021 at 20:05, Kieran Bingham <kieran.bingham at ideasonboard.com>
wrote:

> Hi David,
>
> On 03/03/2021 15:57, David Plowman wrote:
> > Hi everyone
> >
> > I've been chasing down problems with a camera driver (sometimes) not
> > running at the correct framerates. It seems that I've tracked it down
> > to libcamera's control list mechanism. Please correct me if I've got
> > anything wrong in my explanation below.
> >
> > V4L2 devices produce a list of all their controls, including min and
> > max values, when they are opened - as the V4L2Device constructor calls
> > the private listControls() method.
> >
> > The CameraInfo::sensorInfo() method calculates the minimum and maximum
> > frame lengths using the min and max vblank values. These values were
> > read and stored when the device was opened. Since then, however, the
> > format requested from the sensor may well have changed which may mean
> > these values are now wrong.
>
> This sounds troublesome indeed.
>
> > So firstly, have I understood this correctly? And secondly, what do
> > you think would be the preferred way to fix it? Perhaps the
> > listControls() method should be made "protected" and called at the end
> > of V4L2Subdevice::setFormat? Or should getControls() always update the
> > ranges..?
>
> I suspect the 'right' way to do this is to get the kernel to tell us if
> the control has changed. V4L2 devices can expose events:
>
> https://www.kernel.org/doc/html/latest/driver-api/media/v4l2-event.html
>
> We should be able to receive events for control changes through
> V4L2_EVENT_CTRL:
>
>
> https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-dqevent.html#event-type
>
> We already have a means to subscribe to events in our V4L2Device and
> V4L2VideoDevice classes, so handling control updates there should be a
> case of extending from there.
>
> However, I have one concern on your reports above.
>
> It seems it's not the value that has changed, but the minimum and
> maximums? It looks like the events are reported when the 'value'
> changes, but I don't know if the min/max can be changed? I thought those
> were initialised at control creation time. But perhaps I've just never
> done it ;-)
>

This is correct.  The VBLANK min/max limits change when we change
sensor modes.  When we call V4L2Subdevice::getControl(VBLANK), it
does return the correct "value", but the min/max remain unchanged.
In the current codebase, the min/max values are only updated on a
V4L2Device:listControl() call, which only happens when you open the device.

Regards,
Naush


>
> Hope this helps (or at least bumps the discussions).
>
> Kieran
>
>
> > Thanks!
> > David
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel at lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
> >
>
> --
> Regards
> --
> Kieran
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210305/397142bf/attachment-0001.htm>


More information about the libcamera-devel mailing list