Re: RFC: MEDIA: Driver for ON Semi AR0521 camera sensor

From: Krzysztof Hałasa
Date: Wed Apr 28 2021 - 08:35:39 EST


Hi,

I'm working on AR0521 MIPI camera sensor driver update and I'm still not
sure how the timings should be programmed. V4L2 has:

- V4L2_CID_LINK_FREQ
I understand it's a menu with fixed integers (frequencies in Hz).
Documentation/driver-api/media/camera-sensor.rst:
"For camera sensors that are connected to a bus where transmitter and receiver
require common configuration set by drivers, such as CSI-2 or parallel (BT.601
or BT.656) bus, the ``V4L2_CID_LINK_FREQ`` control is mandatory on transmitter
drivers. Receiver drivers can use the ``V4L2_CID_LINK_FREQ`` to query the
frequency used on the bus."

How (and if) do I use the above when the sensor in question uses PLLs
and can generate arbitrary link frequencies?

- V4L2_CID_VBLANK and V4L2_CID_HBLANK
These are fine for setting the timings (and the AR0521 can use them).
There is, however, another value needed for precise timing control, the
so called "extra" timing (a hw register), specified in pixels.
The calculated frame rate is thus:
fr = pixel_clock / (width + hblank) * (height + vblank) + extra.

How do I specify the "extra"?

Currently, I'm using the [sg]_frame_interval() functions, should it stay
this way (so there are [HV]BLANK controls AND [sg]_frame_interval() in
parallel on the same device)?

It appears the userspace should be able to set, in addition to *BLANK,
the pixel clock. How do I do that? The V4L2_CID_PIXEL_RATE appears to be
a good candidate, but v4l2_ctrl_fill() sets a read-only flag on it.

Any ideas?

At present I'm about to use two (orthogonal) interfaces (frame interval
based and the - incomplete - [hv]blank-based) - but perhaps I'm missing
something important?
--
Krzysztof Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa