<div dir="ltr"><div dir="ltr">Hi Kieran,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 4 Mar 2021 at 20:05, Kieran Bingham <<a href="mailto:kieran.bingham@ideasonboard.com">kieran.bingham@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi David,<br>
<br>
On 03/03/2021 15:57, David Plowman wrote:<br>
> Hi everyone<br>
> <br>
> I've been chasing down problems with a camera driver (sometimes) not<br>
> running at the correct framerates. It seems that I've tracked it down<br>
> to libcamera's control list mechanism. Please correct me if I've got<br>
> anything wrong in my explanation below.<br>
> <br>
> V4L2 devices produce a list of all their controls, including min and<br>
> max values, when they are opened - as the V4L2Device constructor calls<br>
> the private listControls() method.<br>
> <br>
> The CameraInfo::sensorInfo() method calculates the minimum and maximum<br>
> frame lengths using the min and max vblank values. These values were<br>
> read and stored when the device was opened. Since then, however, the<br>
> format requested from the sensor may well have changed which may mean<br>
> these values are now wrong.<br>
<br>
This sounds troublesome indeed.<br>
<br>
> So firstly, have I understood this correctly? And secondly, what do<br>
> you think would be the preferred way to fix it? Perhaps the<br>
> listControls() method should be made "protected" and called at the end<br>
> of V4L2Subdevice::setFormat? Or should getControls() always update the<br>
> ranges..?<br>
<br>
I suspect the 'right' way to do this is to get the kernel to tell us if<br>
the control has changed. V4L2 devices can expose events:<br>
<br>
<a href="https://www.kernel.org/doc/html/latest/driver-api/media/v4l2-event.html" rel="noreferrer" target="_blank">https://www.kernel.org/doc/html/latest/driver-api/media/v4l2-event.html</a><br>
<br>
We should be able to receive events for control changes through<br>
V4L2_EVENT_CTRL:<br>
<br>
<a href="https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-dqevent.html#event-type" rel="noreferrer" target="_blank">https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-dqevent.html#event-type</a><br>
<br>
We already have a means to subscribe to events in our V4L2Device and<br>
V4L2VideoDevice classes, so handling control updates there should be a<br>
case of extending from there.<br>
<br>
However, I have one concern on your reports above.<br>
<br>
It seems it's not the value that has changed, but the minimum and<br>
maximums? It looks like the events are reported when the 'value'<br>
changes, but I don't know if the min/max can be changed? I thought those<br>
were initialised at control creation time. But perhaps I've just never<br>
done it ;-)<br></blockquote><div><br></div><div>This is correct.  The VBLANK min/max limits change when we change</div><div>sensor modes.  When we call V4L2Subdevice::getControl(VBLANK), it</div><div>does return the correct "value", but the min/max remain unchanged.</div><div>In the current codebase, the min/max values are only updated on a</div><div>V4L2Device:listControl() call, which only happens when you open the device.</div><div><br></div><div>Regards,</div><div>Naush</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Hope this helps (or at least bumps the discussions).<br>
<br>
Kieran<br>
<br>
<br>
> Thanks!<br>
> David<br>
> _______________________________________________<br>
> libcamera-devel mailing list<br>
> <a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a><br>
> <a href="https://lists.libcamera.org/listinfo/libcamera-devel" rel="noreferrer" target="_blank">https://lists.libcamera.org/listinfo/libcamera-devel</a><br>
> <br>
<br>
-- <br>
Regards<br>
--<br>
Kieran<br>
_______________________________________________<br>
libcamera-devel mailing list<br>
<a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a><br>
<a href="https://lists.libcamera.org/listinfo/libcamera-devel" rel="noreferrer" target="_blank">https://lists.libcamera.org/listinfo/libcamera-devel</a><br>
</blockquote></div></div>