1 .. SPDX-License-Identifier: GPL-2.0 1 .. SPDX-License-Identifier: GPL-2.0 2 2 3 .. _transmitter-receiver: 3 .. _transmitter-receiver: 4 4 5 Pixel data transmitter and receiver drivers 5 Pixel data transmitter and receiver drivers 6 =========================================== 6 =========================================== 7 7 8 V4L2 supports various devices that transmit an 8 V4L2 supports various devices that transmit and receive pixel data. Examples of 9 these devices include a camera sensor, a TV tu !! 9 these devices include a camera sensor, a TV tuner and a parallel or a CSI-2 10 CSI-2 receiver in an SoC. !! 10 receiver in an SoC. 11 11 12 Bus types 12 Bus types 13 --------- 13 --------- 14 14 15 The following busses are the most common. This 15 The following busses are the most common. This section discusses these two only. 16 16 17 MIPI CSI-2 17 MIPI CSI-2 18 ^^^^^^^^^^ 18 ^^^^^^^^^^ 19 19 20 CSI-2 is a data bus intended for transferring 20 CSI-2 is a data bus intended for transferring images from cameras to 21 the host SoC. It is defined by the `MIPI allia 21 the host SoC. It is defined by the `MIPI alliance`_. 22 22 23 .. _`MIPI alliance`: https://www.mipi.org/ 23 .. _`MIPI alliance`: https://www.mipi.org/ 24 24 25 Parallel and BT.656 !! 25 Parallel 26 ^^^^^^^^^^^^^^^^^^^ !! 26 ^^^^^^^^ 27 27 28 The parallel and `BT.656`_ buses transport one !! 28 `BT.601`_ and `BT.656`_ are the most common parallel busses. 29 per data line. The parallel bus uses synchroni << 30 signals whereas BT.656 embeds synchronisation. << 31 29 >> 30 .. _`BT.601`: https://en.wikipedia.org/wiki/Rec._601 32 .. _`BT.656`: https://en.wikipedia.org/wiki/IT 31 .. _`BT.656`: https://en.wikipedia.org/wiki/ITU-R_BT.656 33 32 34 Transmitter drivers 33 Transmitter drivers 35 ------------------- 34 ------------------- 36 35 37 Transmitter drivers generally need to provide 36 Transmitter drivers generally need to provide the receiver drivers with the 38 configuration of the transmitter. What is requ 37 configuration of the transmitter. What is required depends on the type of the 39 bus. These are common for both busses. 38 bus. These are common for both busses. 40 39 41 Media bus pixel code 40 Media bus pixel code 42 ^^^^^^^^^^^^^^^^^^^^ 41 ^^^^^^^^^^^^^^^^^^^^ 43 42 44 See :ref:`v4l2-mbus-pixelcode`. 43 See :ref:`v4l2-mbus-pixelcode`. 45 44 46 Link frequency 45 Link frequency 47 ^^^^^^^^^^^^^^ 46 ^^^^^^^^^^^^^^ 48 47 49 The :ref:`V4L2_CID_LINK_FREQ <v4l2-cid-link-fr 48 The :ref:`V4L2_CID_LINK_FREQ <v4l2-cid-link-freq>` control is used to tell the 50 receiver the frequency of the bus (i.e. it is 49 receiver the frequency of the bus (i.e. it is not the same as the symbol rate). 51 50 52 ``.s_stream()`` callback 51 ``.s_stream()`` callback 53 ^^^^^^^^^^^^^^^^^^^^^^^^ 52 ^^^^^^^^^^^^^^^^^^^^^^^^ 54 53 55 The struct struct v4l2_subdev_video_ops->s_str 54 The struct struct v4l2_subdev_video_ops->s_stream() callback is used by the 56 receiver driver to control the transmitter dri 55 receiver driver to control the transmitter driver's streaming state. 57 56 58 57 59 CSI-2 transmitter drivers 58 CSI-2 transmitter drivers 60 ------------------------- 59 ------------------------- 61 60 62 Pixel rate 61 Pixel rate 63 ^^^^^^^^^^ 62 ^^^^^^^^^^ 64 63 65 The pixel rate on the bus is calculated as fol 64 The pixel rate on the bus is calculated as follows:: 66 65 67 pixel_rate = link_freq * 2 * nr_of_lan 66 pixel_rate = link_freq * 2 * nr_of_lanes * 16 / k / bits_per_sample 68 67 69 where 68 where 70 69 71 .. list-table:: variables in pixel rate calcul 70 .. list-table:: variables in pixel rate calculation 72 :header-rows: 1 71 :header-rows: 1 73 72 74 * - variable or constant 73 * - variable or constant 75 - description 74 - description 76 * - link_freq 75 * - link_freq 77 - The value of the ``V4L2_CID_LINK_FREQ`` 76 - The value of the ``V4L2_CID_LINK_FREQ`` integer64 menu item. 78 * - nr_of_lanes 77 * - nr_of_lanes 79 - Number of data lanes used on the CSI-2 78 - Number of data lanes used on the CSI-2 link. This can 80 be obtained from the OF endpoint config 79 be obtained from the OF endpoint configuration. 81 * - 2 80 * - 2 82 - Data is transferred on both rising and 81 - Data is transferred on both rising and falling edge of the signal. 83 * - bits_per_sample 82 * - bits_per_sample 84 - Number of bits per sample. 83 - Number of bits per sample. 85 * - k 84 * - k 86 - 16 for D-PHY and 7 for C-PHY 85 - 16 for D-PHY and 7 for C-PHY 87 86 88 .. note:: 87 .. note:: 89 88 90 The pixel rate calculated this way is 89 The pixel rate calculated this way is **not** the same thing as the 91 pixel rate on the camera sensor's pixe 90 pixel rate on the camera sensor's pixel array which is indicated by the 92 :ref:`V4L2_CID_PIXEL_RATE <v4l2-cid-pi 91 :ref:`V4L2_CID_PIXEL_RATE <v4l2-cid-pixel-rate>` control. 93 92 94 LP-11 and LP-111 states !! 93 LP-11 and LP-111 modes 95 ^^^^^^^^^^^^^^^^^^^^^^^ !! 94 ^^^^^^^^^^^^^^^^^^^^^^ 96 95 97 As part of transitioning to high speed mode, a 96 As part of transitioning to high speed mode, a CSI-2 transmitter typically 98 briefly sets the bus to LP-11 or LP-111 state, 97 briefly sets the bus to LP-11 or LP-111 state, depending on the PHY. This period 99 may be as short as 100 µs, during which the r 98 may be as short as 100 µs, during which the receiver observes this state and 100 proceeds its own part of high speed mode trans 99 proceeds its own part of high speed mode transition. 101 100 102 Most receivers are capable of autonomously han 101 Most receivers are capable of autonomously handling this once the software has 103 configured them to do so, but there are receiv 102 configured them to do so, but there are receivers which require software 104 involvement in observing LP-11 or LP-111 state 103 involvement in observing LP-11 or LP-111 state. 100 µs is a brief period to hit 105 in software, especially when there is no inter 104 in software, especially when there is no interrupt telling something is 106 happening. 105 happening. 107 106 108 One way to address this is to configure the tr 107 One way to address this is to configure the transmitter side explicitly to LP-11 109 or LP-111 state, which requires support from t !! 108 or LP-111 mode, which requires support from the transmitter hardware. This is 110 not universally available. Many devices return 109 not universally available. Many devices return to this state once streaming is 111 stopped while the state after power-on is LP-0 110 stopped while the state after power-on is LP-00 or LP-000. 112 111 113 The ``.pre_streamon()`` callback may be used t 112 The ``.pre_streamon()`` callback may be used to prepare a transmitter for 114 transitioning to streaming state, but not yet 113 transitioning to streaming state, but not yet start streaming. Similarly, the 115 ``.post_streamoff()`` callback is used to undo 114 ``.post_streamoff()`` callback is used to undo what was done by the 116 ``.pre_streamon()`` callback. The caller of `` 115 ``.pre_streamon()`` callback. The caller of ``.pre_streamon()`` is thus required 117 to call ``.post_streamoff()`` for each success 116 to call ``.post_streamoff()`` for each successful call of ``.pre_streamon()``. 118 117 119 In the context of CSI-2, the ``.pre_streamon() 118 In the context of CSI-2, the ``.pre_streamon()`` callback is used to transition 120 the transmitter to the LP-11 or LP-111 state. !! 119 the transmitter to the LP-11 or LP-111 mode. This also requires powering on the 121 device, so this should be only done when it is 120 device, so this should be only done when it is needed. 122 121 123 Receiver drivers that do not need explicit LP- !! 122 Receiver drivers that do not need explicit LP-11 or LP-111 mode setup are waived 124 waived from calling the two callbacks. !! 123 from calling the two callbacks. 125 124 126 Stopping the transmitter 125 Stopping the transmitter 127 ^^^^^^^^^^^^^^^^^^^^^^^^ 126 ^^^^^^^^^^^^^^^^^^^^^^^^ 128 127 129 A transmitter stops sending the stream of imag 128 A transmitter stops sending the stream of images as a result of 130 calling the ``.s_stream()`` callback. Some tra 129 calling the ``.s_stream()`` callback. Some transmitters may stop the 131 stream at a frame boundary whereas others stop 130 stream at a frame boundary whereas others stop immediately, 132 effectively leaving the current frame unfinish 131 effectively leaving the current frame unfinished. The receiver driver 133 should not make assumptions either way, but fu 132 should not make assumptions either way, but function properly in both 134 cases. 133 cases.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.