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

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Mar 4 21:05:22 CET 2021


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 ;-)

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


More information about the libcamera-devel mailing list