cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

tx-rx.rst (4512B)


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