1MIPI CSI-2 2========== 3 4CSI-2 is a data bus intended for transferring images from cameras to 5the host SoC. It is defined by the `MIPI alliance`_. 6 7.. _`MIPI alliance`: http://www.mipi.org/ 8 9Transmitter drivers 10------------------- 11 12CSI-2 transmitter, such as a sensor or a TV tuner, drivers need to 13provide the CSI-2 receiver with information on the CSI-2 bus 14configuration. These include the V4L2_CID_LINK_FREQ and 15V4L2_CID_PIXEL_RATE controls and 16(:c:type:`v4l2_subdev_video_ops`->s_stream() callback). These 17interface elements must be present on the sub-device represents the 18CSI-2 transmitter. 19 20The V4L2_CID_LINK_FREQ control is used to tell the receiver driver the 21frequency (and not the symbol rate) of the link. The 22V4L2_CID_PIXEL_RATE is may be used by the receiver to obtain the pixel 23rate the transmitter uses. The 24:c:type:`v4l2_subdev_video_ops`->s_stream() callback provides an 25ability to start and stop the stream. 26 27The value of the V4L2_CID_PIXEL_RATE is calculated as follows:: 28 29 pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample 30 31where 32 33.. list-table:: variables in pixel rate calculation 34 :header-rows: 1 35 36 * - variable or constant 37 - description 38 * - link_freq 39 - The value of the V4L2_CID_LINK_FREQ integer64 menu item. 40 * - nr_of_lanes 41 - Number of data lanes used on the CSI-2 link. This can 42 be obtained from the OF endpoint configuration. 43 * - 2 44 - Two bits are transferred per clock cycle per lane. 45 * - bits_per_sample 46 - Number of bits per sample. 47 48The transmitter drivers must, if possible, configure the CSI-2 49transmitter to *LP-11 mode* whenever the transmitter is powered on but 50not active. Some transmitters do this automatically but some have to 51be explicitly programmed to do so, and some are unable to do so 52altogether due to hardware constraints. 53 54Stopping the transmitter 55^^^^^^^^^^^^^^^^^^^^^^^^ 56 57A transmitter stops sending the stream of images as a result of 58calling the ``.s_stream()`` callback. Some transmitters may stop the 59stream at a frame boundary whereas others stop immediately, 60effectively leaving the current frame unfinished. The receiver driver 61should not make assumptions either way, but function properly in both 62cases. 63 64Receiver drivers 65---------------- 66 67Before the receiver driver may enable the CSI-2 transmitter by using 68the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered 69the transmitter up by using the 70:c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take 71place either indirectly by using :c:func:`v4l2_pipeline_pm_use` or 72directly. 73