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