6. MIPI CSI-2

CSI-2 is a data bus intended for transferring images from cameras tothe host SoC. It is defined by theMIPI alliance.

6.1. Media bus formats

SeeMedia Bus Pixel Codes for details on which media bus formats shouldbe used for CSI-2 interfaces.

6.2. Transmitter drivers

CSI-2 transmitter, such as a sensor or a TV tuner, drivers need toprovide the CSI-2 receiver with information on the CSI-2 busconfiguration. These include the V4L2_CID_LINK_FREQ andV4L2_CID_PIXEL_RATE controls and(v4l2_subdev_video_ops->s_stream() callback). Theseinterface elements must be present on the sub-device represents theCSI-2 transmitter.

The V4L2_CID_LINK_FREQ control is used to tell the receiver driver thefrequency (and not the symbol rate) of the link. TheV4L2_CID_PIXEL_RATE is may be used by the receiver to obtain the pixelrate the transmitter uses. Thev4l2_subdev_video_ops->s_stream() callback provides anability to start and stop the stream.

The value of the V4L2_CID_PIXEL_RATE is calculated as follows:

pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample

where

variables in pixel rate calculation
variable or constantdescription
link_freqThe value of the V4L2_CID_LINK_FREQ integer64 menu item.
nr_of_lanesNumber of data lanes used on the CSI-2 link. This canbe obtained from the OF endpoint configuration.
2Two bits are transferred per clock cycle per lane.
bits_per_sampleNumber of bits per sample.

The transmitter drivers must, if possible, configure the CSI-2transmitter toLP-11 mode whenever the transmitter is powered on butnot active, and maintainLP-11 mode until stream on. Only at streamon should the transmitter activate the clock on the clock lane andtransition toHS mode.

Some transmitters do this automatically but some have to be explicitlyprogrammed to do so, and some are unable to do so altogether due tohardware constraints.

6.2.1. Stopping the transmitter

A transmitter stops sending the stream of images as a result ofcalling the.s_stream() callback. Some transmitters may stop thestream at a frame boundary whereas others stop immediately,effectively leaving the current frame unfinished. The receiver drivershould not make assumptions either way, but function properly in bothcases.

6.3. Receiver drivers

Before the receiver driver may enable the CSI-2 transmitter by usingthev4l2_subdev_video_ops->s_stream(), it must have poweredthe transmitter up by using thev4l2_subdev_core_ops->s_power() callback. This may takeplace either indirectly by usingv4l2_pipeline_pm_get() ordirectly.

6.4. Formats

The media bus pixel codes document parallel formats. Should the pixel data betransported over a serial bus, the media bus pixel code that describes aparallel format that transfers a sample on a single clock cycle is used.