Commit | Line | Data |
---|---|---|
f2ac8ce8 MCC |
1 | .. SPDX-License-Identifier: GPL-2.0 |
2 | ||
e4cf8c58 SA |
3 | .. _MIPI_CSI_2: |
4 | ||
bb16d21c SA |
5 | MIPI CSI-2 |
6 | ========== | |
7 | ||
8 | CSI-2 is a data bus intended for transferring images from cameras to | |
9 | the host SoC. It is defined by the `MIPI alliance`_. | |
10 | ||
11 | .. _`MIPI alliance`: http://www.mipi.org/ | |
12 | ||
938b29db SA |
13 | Media bus formats |
14 | ----------------- | |
15 | ||
16 | See :ref:`v4l2-mbus-pixelcode` for details on which media bus formats should | |
17 | be used for CSI-2 interfaces. | |
18 | ||
bb16d21c SA |
19 | Transmitter drivers |
20 | ------------------- | |
21 | ||
22 | CSI-2 transmitter, such as a sensor or a TV tuner, drivers need to | |
23 | provide the CSI-2 receiver with information on the CSI-2 bus | |
24 | configuration. These include the V4L2_CID_LINK_FREQ and | |
25 | V4L2_CID_PIXEL_RATE controls and | |
26 | (:c:type:`v4l2_subdev_video_ops`->s_stream() callback). These | |
27 | interface elements must be present on the sub-device represents the | |
28 | CSI-2 transmitter. | |
29 | ||
30 | The V4L2_CID_LINK_FREQ control is used to tell the receiver driver the | |
31 | frequency (and not the symbol rate) of the link. The | |
32 | V4L2_CID_PIXEL_RATE is may be used by the receiver to obtain the pixel | |
33 | rate the transmitter uses. The | |
34 | :c:type:`v4l2_subdev_video_ops`->s_stream() callback provides an | |
35 | ability to start and stop the stream. | |
36 | ||
37 | The value of the V4L2_CID_PIXEL_RATE is calculated as follows:: | |
38 | ||
39 | pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample | |
40 | ||
41 | where | |
42 | ||
43 | .. list-table:: variables in pixel rate calculation | |
44 | :header-rows: 1 | |
45 | ||
46 | * - variable or constant | |
47 | - description | |
48 | * - link_freq | |
49 | - The value of the V4L2_CID_LINK_FREQ integer64 menu item. | |
50 | * - nr_of_lanes | |
51 | - Number of data lanes used on the CSI-2 link. This can | |
52 | be obtained from the OF endpoint configuration. | |
53 | * - 2 | |
54 | - Two bits are transferred per clock cycle per lane. | |
55 | * - bits_per_sample | |
56 | - Number of bits per sample. | |
57 | ||
30b2db31 SA |
58 | The transmitter drivers must, if possible, configure the CSI-2 |
59 | transmitter to *LP-11 mode* whenever the transmitter is powered on but | |
9bf656e1 SL |
60 | not active, and maintain *LP-11 mode* until stream on. Only at stream |
61 | on should the transmitter activate the clock on the clock lane and | |
62 | transition to *HS mode*. | |
63 | ||
64 | Some transmitters do this automatically but some have to be explicitly | |
65 | programmed to do so, and some are unable to do so altogether due to | |
66 | hardware constraints. | |
bb16d21c | 67 | |
3cdb977e SA |
68 | Stopping the transmitter |
69 | ^^^^^^^^^^^^^^^^^^^^^^^^ | |
70 | ||
71 | A transmitter stops sending the stream of images as a result of | |
72 | calling the ``.s_stream()`` callback. Some transmitters may stop the | |
73 | stream at a frame boundary whereas others stop immediately, | |
74 | effectively leaving the current frame unfinished. The receiver driver | |
75 | should not make assumptions either way, but function properly in both | |
76 | cases. | |
77 | ||
bb16d21c SA |
78 | Receiver drivers |
79 | ---------------- | |
80 | ||
81 | Before the receiver driver may enable the CSI-2 transmitter by using | |
82 | the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered | |
83 | the transmitter up by using the | |
84 | :c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take | |
8fd390b8 | 85 | place either indirectly by using :c:func:`v4l2_pipeline_pm_get` or |
bb16d21c | 86 | directly. |
50435d8d SA |
87 | |
88 | Formats | |
89 | ------- | |
90 | ||
91 | The media bus pixel codes document parallel formats. Should the pixel data be | |
92 | transported over a serial bus, the media bus pixel code that describes a | |
93 | parallel format that transfers a sample on a single clock cycle is used. |