7. Pixel data transmitter and receiver drivers¶
V4L2 supports various devices that transmit and receiver pixel data. Examples of these devices include a camera sensor, a TV tuner and a parallel or a CSI-2 receiver in an SoC.
7.1. Bus types¶
The following busses are the most common. This section discusses these two only.
7.1.1. MIPI CSI-2¶
CSI-2 is a data bus intended for transferring images from cameras to the host SoC. It is defined by the MIPI alliance.
7.2. Transmitter drivers¶
Transmitter drivers generally need to provide the receiver drivers with the configuration of the transmitter. What is required depends on the type of the bus. These are common for both busses.
7.2.1. Media bus pixel code¶
7.2.2. Link frequency¶
The V4L2_CID_LINK_FREQ control is used to tell the receiver the frequency of the bus (i.e. it is not the same as the symbol rate).
7.2.3. .s_stream()
callback¶
The struct struct v4l2_subdev_video_ops->s_stream() callback is used by the receiver driver to control the transmitter driver’s streaming state.
7.3. CSI-2 transmitter drivers¶
7.3.1. Pixel rate¶
The pixel rate on the bus is calculated as follows:
pixel_rate = link_freq * 2 * nr_of_lanes * 16 / k / bits_per_sample
where
variable or constant |
description |
---|---|
link_freq |
The value of the |
nr_of_lanes |
Number of data lanes used on the CSI-2 link. This can be obtained from the OF endpoint configuration. |
2 |
Data is transferred on both rising and falling edge of the signal. |
bits_per_sample |
Number of bits per sample. |
k |
16 for D-PHY and 7 for C-PHY |
Note
The pixel rate calculated this way is not the same thing as the pixel rate on the camera sensor’s pixel array which is indicated by the V4L2_CID_PIXEL_RATE control.
7.3.2. LP-11 and LP-111 modes¶
The transmitter drivers must, if possible, configure the CSI-2 transmitter to LP-11 or LP-111 mode whenever the transmitter is powered on but not active, and maintain LP-11 or LP-111 mode until stream on. Only at stream on should the transmitter activate the clock on the clock lane and transition to HS mode.
Some transmitters do this automatically but some have to be explicitly programmed to do so, and some are unable to do so altogether due to hardware constraints.
The receiver thus need to be configured to expect LP-11 or LP-111 mode from the
transmitter before the transmitter driver’s .s_stream()
op is called.
7.3.3. Stopping the transmitter¶
A transmitter stops sending the stream of images as a result of
calling the .s_stream()
callback. Some transmitters may stop the
stream at a frame boundary whereas others stop immediately,
effectively leaving the current frame unfinished. The receiver driver
should not make assumptions either way, but function properly in both
cases.