brintos

brintos / linux-shallow public Read only

0
0
Text · 4.5 KiB · 29d66a4 Raw
135 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3.. _transmitter-receiver:4 5Pixel data transmitter and receiver drivers6===========================================7 8V4L2 supports various devices that transmit and receive pixel data. Examples of9these devices include a camera sensor, a TV tuner and a parallel, a BT.656 or a10CSI-2 receiver in an SoC.11 12Bus types13---------14 15The following busses are the most common. This section discusses these two only.16 17MIPI CSI-218^^^^^^^^^^19 20CSI-2 is a data bus intended for transferring images from cameras to21the host SoC. It is defined by the `MIPI alliance`_.22 23.. _`MIPI alliance`: https://www.mipi.org/24 25Parallel and BT.65626^^^^^^^^^^^^^^^^^^^27 28The parallel and `BT.656`_ buses transport one bit of data on each clock cycle29per data line. The parallel bus uses synchronisation and other additional30signals whereas BT.656 embeds synchronisation.31 32.. _`BT.656`: https://en.wikipedia.org/wiki/ITU-R_BT.65633 34Transmitter drivers35-------------------36 37Transmitter drivers generally need to provide the receiver drivers with the38configuration of the transmitter. What is required depends on the type of the39bus. These are common for both busses.40 41Media bus pixel code42^^^^^^^^^^^^^^^^^^^^43 44See :ref:`v4l2-mbus-pixelcode`.45 46Link frequency47^^^^^^^^^^^^^^48 49The :ref:`V4L2_CID_LINK_FREQ <v4l2-cid-link-freq>` control is used to tell the50receiver the frequency of the bus (i.e. it is not the same as the symbol rate).51 52``.s_stream()`` callback53^^^^^^^^^^^^^^^^^^^^^^^^54 55The struct struct v4l2_subdev_video_ops->s_stream() callback is used by the56receiver driver to control the transmitter driver's streaming state.57 58 59CSI-2 transmitter drivers60-------------------------61 62Pixel rate63^^^^^^^^^^64 65The pixel rate on the bus is calculated as follows::66 67	pixel_rate = link_freq * 2 * nr_of_lanes * 16 / k / bits_per_sample68 69where70 71.. list-table:: variables in pixel rate calculation72   :header-rows: 173 74   * - variable or constant75     - description76   * - link_freq77     - The value of the ``V4L2_CID_LINK_FREQ`` integer64 menu item.78   * - nr_of_lanes79     - Number of data lanes used on the CSI-2 link. This can80       be obtained from the OF endpoint configuration.81   * - 282     - Data is transferred on both rising and falling edge of the signal.83   * - bits_per_sample84     - Number of bits per sample.85   * - k86     - 16 for D-PHY and 7 for C-PHY87 88.. note::89 90	The pixel rate calculated this way is **not** the same thing as the91	pixel rate on the camera sensor's pixel array which is indicated by the92	:ref:`V4L2_CID_PIXEL_RATE <v4l2-cid-pixel-rate>` control.93 94LP-11 and LP-111 states95^^^^^^^^^^^^^^^^^^^^^^^96 97As part of transitioning to high speed mode, a CSI-2 transmitter typically98briefly sets the bus to LP-11 or LP-111 state, depending on the PHY. This period99may be as short as 100 µs, during which the receiver observes this state and100proceeds its own part of high speed mode transition.101 102Most receivers are capable of autonomously handling this once the software has103configured them to do so, but there are receivers which require software104involvement in observing LP-11 or LP-111 state. 100 µs is a brief period to hit105in software, especially when there is no interrupt telling something is106happening.107 108One way to address this is to configure the transmitter side explicitly to LP-11109or LP-111 state, which requires support from the transmitter hardware. This is110not universally available. Many devices return to this state once streaming is111stopped while the state after power-on is LP-00 or LP-000.112 113The ``.pre_streamon()`` callback may be used to prepare a transmitter for114transitioning to streaming state, but not yet start streaming. Similarly, the115``.post_streamoff()`` callback is used to undo what was done by the116``.pre_streamon()`` callback. The caller of ``.pre_streamon()`` is thus required117to call ``.post_streamoff()`` for each successful call of ``.pre_streamon()``.118 119In the context of CSI-2, the ``.pre_streamon()`` callback is used to transition120the transmitter to the LP-11 or LP-111 state. This also requires powering on the121device, so this should be only done when it is needed.122 123Receiver drivers that do not need explicit LP-11 or LP-111 state setup are124waived from calling the two callbacks.125 126Stopping the transmitter127^^^^^^^^^^^^^^^^^^^^^^^^128 129A transmitter stops sending the stream of images as a result of130calling the ``.s_stream()`` callback. Some transmitters may stop the131stream at a frame boundary whereas others stop immediately,132effectively leaving the current frame unfinished. The receiver driver133should not make assumptions either way, but function properly in both134cases.135