io_uring: io_uring_complete() trace should take an integer
[linux-2.6-microblaze.git] / Documentation / driver-api / media / csi2.rst
1 .. SPDX-License-Identifier: GPL-2.0
2
3 .. _MIPI_CSI_2:
4
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
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
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 V4L2_CID_PIXEL_RATE
32 control may be used by the receiver to obtain the pixel rate the transmitter
33 uses. The :c:type:`v4l2_subdev_video_ops`->s_stream() callback provides an
34 ability to start and stop the stream.
35
36 The value of the V4L2_CID_PIXEL_RATE is calculated as follows::
37
38         pixel_rate = link_freq * 2 * nr_of_lanes * 16 / k / bits_per_sample
39
40 where
41
42 .. list-table:: variables in pixel rate calculation
43    :header-rows: 1
44
45    * - variable or constant
46      - description
47    * - link_freq
48      - The value of the V4L2_CID_LINK_FREQ integer64 menu item.
49    * - nr_of_lanes
50      - Number of data lanes used on the CSI-2 link. This can
51        be obtained from the OF endpoint configuration.
52    * - 2
53      - Two bits are transferred per clock cycle per lane.
54    * - bits_per_sample
55      - Number of bits per sample.
56    * - k
57      - 16 for D-PHY and 7 for C-PHY
58
59 The transmitter drivers must, if possible, configure the CSI-2
60 transmitter to *LP-11 mode* whenever the transmitter is powered on but
61 not active, and maintain *LP-11 mode* until stream on. Only at stream
62 on should the transmitter activate the clock on the clock lane and
63 transition to *HS mode*.
64
65 Some transmitters do this automatically but some have to be explicitly
66 programmed to do so, and some are unable to do so altogether due to
67 hardware constraints.
68
69 Stopping the transmitter
70 ^^^^^^^^^^^^^^^^^^^^^^^^
71
72 A transmitter stops sending the stream of images as a result of
73 calling the ``.s_stream()`` callback. Some transmitters may stop the
74 stream at a frame boundary whereas others stop immediately,
75 effectively leaving the current frame unfinished. The receiver driver
76 should not make assumptions either way, but function properly in both
77 cases.
78
79 Receiver drivers
80 ----------------
81
82 Before the receiver driver may enable the CSI-2 transmitter by using
83 the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered
84 the transmitter up by using the
85 :c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take
86 place either indirectly by using :c:func:`v4l2_pipeline_pm_get` or
87 directly.
88
89 Formats
90 -------
91
92 The media bus pixel codes document parallel formats. Should the pixel data be
93 transported over a serial bus, the media bus pixel code that describes a
94 parallel format that transfers a sample on a single clock cycle is used.