Documentation/driver-api/media/tx-rx.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

Pixel data transmitter and receiver drivers

CSI-2·parallel·BT.656 bus, link frequency, stream callback, pixel rate와 LP state를 설명하는 전문 번역입니다.

Source pathDocumentation/driver-api/media/tx-rx.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

tx-rx.rst:1-144

Pixel transmitter와 receiver는 bus format·link frequency·streaming 생명주기를 합의해야 합니다. CSI-2에서는 PHY·lane·sample 폭을 반영해 bus pixel rate를 계산하고, 필요한 hardware에서는 짧은 LP-11·LP-111 상태를 명시적으로 준비합니다.

문서 구성
원문 줄내용
1-33CSI-2·parallel·BT.656 bus
34-58Transmitter 설정과 link frequency
59-77Stream enable·disable
78-113CSI-2 bus pixel rate
114-144LP state와 callback 대칭

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Pixel data transmitter·receiver bus

1-33

V4L2는 pixel data를 송수신하는 여러 장치를 지원합니다. Camera sensor, TV tuner, SoC 안의 parallel·BT.656·CSI-2 receiver가 대표적입니다.

MIPI CSI-2는 camera에서 host SoC로 image를 전송하는 data bus이며 MIPI Alliance가 정의합니다. 공식 정보는 `https://www.mipi.org/`에서 확인할 수 있습니다.

Parallel bus와 BT.656 bus는 data line마다 clock cycle 하나에 1bit를 전송합니다. Parallel bus는 동기화 신호와 그 밖의 추가 신호를 별도로 사용하지만 BT.656은 동기화 정보를 data에 embed합니다.

일반적인 pixel data bus
Bus전송·동기화 방식참조
MIPI CSI-2Camera → host SoC image data`https://www.mipi.org/`
ParallelData line당 cycle마다 1bit, 별도 sync 신호V4L2 parallel bus
BT.656Data line당 cycle마다 1bit, sync embed`ITU-R BT.656`

.. SPDX-License-Identifier: GPL-2.0

.. _transmitter-receiver:

Pixel data transmitter and receiver drivers
===========================================

V4L2 supports various devices that transmit and receive pixel data. Examples of
these devices include a camera sensor, a TV tuner and a parallel, a BT.656 or a
CSI-2 receiver in an SoC.

Bus types
---------

The following buses are the most common. This section discusses these two only.

MIPI CSI-2
^^^^^^^^^^

CSI-2 is a data bus intended for transferring images from cameras to
the host SoC. It is defined by the `MIPI alliance`_.

.. _`MIPI alliance`: https://www.mipi.org/

Parallel and BT.656
^^^^^^^^^^^^^^^^^^^

The parallel and `BT.656`_ buses transport one bit of data on each clock cycle
per data line. The parallel bus uses synchronisation and other additional
signals whereas BT.656 embeds synchronisation.

.. _`BT.656`: https://en.wikipedia.org/wiki/ITU-R_BT.656

Transmitter 설정과 link frequency

34-58

Transmitter driver는 일반적으로 receiver driver에 transmitter 구성을 제공해야 합니다. 필요한 값은 bus type에 따라 다르지만 media bus pixel code와 link frequency는 두 bus 계열에 공통입니다.

Media bus pixel code는 `v4l2-mbus-pixelcode` 문서를 참고합니다.

`V4L2_CID_LINK_FREQ` control은 receiver에 bus frequency를 알려 주며 symbol rate와 같은 값이 아닙니다.

사용자가 link frequency를 구성할 수 없는 driver는 control 대신 `.get_mbus_config()` subdev pad operation의 `struct v4l2_mbus_config.link_freq` 필드로 값을 보고해야 합니다. Receiver driver는 transmitter sub-device에서 link frequency를 얻을 때 `v4l2_get_link_freq()` helper를 사용해야 합니다.

Link frequency 전달
사용자 구성 가능`V4L2_CID_LINK_FREQ` controlReceiver
사용자 구성 불가`.get_mbus_config()``v4l2_mbus_config.link_freq`
Receiver driver`v4l2_get_link_freq()`Transmitter sub-device
주의Link frequency ≠ symbol rate

사용자 구성 가능 여부에 따라 control과 mbus config 경로를 구분합니다.

Transmitter drivers
-------------------

Transmitter drivers generally need to provide the receiver drivers with the
configuration of the transmitter. What is required depends on the type of the
bus. These are common for both buses.

Media bus pixel code
^^^^^^^^^^^^^^^^^^^^

See :ref:`v4l2-mbus-pixelcode`.

Link frequency
^^^^^^^^^^^^^^

The :ref:`V4L2_CID_LINK_FREQ <v4l2-cid-link-freq>` control is used to tell the
receiver the frequency of the bus (i.e. it is not the same as the symbol rate).

Drivers that do not have user-configurable link frequency should report it
through the ``.get_mbus_config()`` subdev pad operation, in the ``link_freq``
field of struct v4l2_mbus_config, instead of through controls.

Receiver drivers should use :c:func:`v4l2_get_link_freq` helper to obtain the
link frequency from the transmitter sub-device.

Stream enable·disable와 transmitter 정지

59-77

Receiver driver는 `v4l2_subdev_pad_ops.enable_streams()`와 `disable_streams()` callback으로 transmitter driver의 streaming 상태를 제어합니다. 이 callback을 직접 호출하지 말고 `v4l2_subdev_enable_streams()`와 `v4l2_subdev_disable_streams()`를 사용해야 합니다.

`.disable_streams()`가 호출되면 transmitter는 image stream 전송을 중지합니다. 일부 transmitter는 frame 경계에서 멈추지만 다른 장치는 즉시 멈춰 현재 frame을 미완성 상태로 남길 수 있습니다. Receiver driver는 어느 방식도 가정하지 않고 두 경우 모두 올바르게 동작해야 합니다.

Transmitter streaming 제어
Receiver driver`v4l2_subdev_enable_streams()`Transmitter `.enable_streams()`
Receiver driver`v4l2_subdev_disable_streams()`Transmitter `.disable_streams()`
정지 결과 AFrame 경계에서 완료 후 정지
정지 결과 B즉시 정지, 현재 frame 미완성

Receiver는 helper를 통해 callback을 호출하고 두 가지 정지 시점을 모두 처리합니다.

``.enable_streams()`` and ``.disable_streams()`` callbacks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The struct v4l2_subdev_pad_ops->enable_streams() and struct
v4l2_subdev_pad_ops->disable_streams() callbacks are used by the receiver driver
to control the transmitter driver's streaming state. These callbacks may not be
called directly, but by using ``v4l2_subdev_enable_streams()`` and
``v4l2_subdev_disable_streams()``.

Stopping the transmitter
^^^^^^^^^^^^^^^^^^^^^^^^

A transmitter stops sending the stream of images as a result of
calling the ``.disable_streams()`` callback. Some transmitters may stop the
stream at a frame boundary whereas others stop immediately,
effectively leaving the current frame unfinished. The receiver driver
should not make assumptions either way, but function properly in both
cases.

CSI-2 bus pixel rate

78-113

CSI-2 bus의 pixel rate는 `pixel_rate = link_freq × 2 × nr_of_lanes × 16 / k / bits_per_sample`로 계산합니다.

`link_freq`는 `V4L2_CID_LINK_FREQ` integer64 menu item의 값이고 `nr_of_lanes`는 CSI-2 link에서 사용하는 data lane 수입니다. 계수 2는 signal의 rising edge와 falling edge 모두에서 data를 전송한다는 뜻입니다.

`bits_per_sample`은 sample당 bit 수입니다. `k`는 D-PHY에서 16, C-PHY에서 7입니다. PHY 종류와 `nr_of_lanes`는 OF endpoint configuration에서 얻을 수 있습니다.

이 방식으로 계산한 bus pixel rate는 camera sensor pixel array의 pixel rate가 아니며, 후자는 `V4L2_CID_PIXEL_RATE` control로 나타냅니다.

CSI-2 pixel-rate 변수
변수·상수의미
`link_freq``V4L2_CID_LINK_FREQ` integer64 menu 값
`nr_of_lanes`CSI-2 data lane 수
`2`Rising·falling edge 모두 사용
`bits_per_sample`Sample당 bit 수
`k`D-PHY 16, C-PHY 7
결과Bus pixel rate, sensor pixel-array rate와 다름

CSI-2 transmitter drivers
-------------------------

Pixel rate
^^^^^^^^^^

The pixel rate on the bus is calculated as follows::

        pixel_rate = link_freq * 2 * nr_of_lanes * 16 / k / bits_per_sample

where

.. list-table:: variables in pixel rate calculation
   :header-rows: 1

   * - variable or constant
     - description
   * - link_freq
     - The value of the ``V4L2_CID_LINK_FREQ`` integer64 menu item.
   * - nr_of_lanes
     - Number of data lanes used on the CSI-2 link.
   * - 2
     - Data is transferred on both rising and falling edge of the signal.
   * - bits_per_sample
     - Number of bits per sample.
   * - k
     - 16 for D-PHY and 7 for C-PHY.

Information on whether D-PHY or C-PHY is used, and the value of ``nr_of_lanes``, can be obtained from the OF endpoint configuration.

.. note::

        The pixel rate calculated this way is **not** the same thing as the
        pixel rate on the camera sensor's pixel array which is indicated by the
        :ref:`V4L2_CID_PIXEL_RATE <v4l2-cid-pixel-rate>` control.

LP-11·LP-111 전이와 callback 대칭

114-144

CSI-2 transmitter는 high-speed mode로 전환하는 과정에서 PHY에 따라 bus를 잠시 LP-11 또는 LP-111 상태로 둡니다. 이 구간은 100μs 정도로 짧을 수 있으며 receiver는 이를 관찰한 뒤 자기 high-speed 전이 단계를 진행합니다.

대부분의 receiver는 software가 구성한 뒤 이 과정을 자동 처리하지만 LP-11·LP-111 관찰에 software 개입이 필요한 receiver도 있습니다. Interrupt 알림이 없다면 software가 100μs 구간을 포착하기는 어렵습니다.

한 가지 해결책은 transmitter를 명시적으로 LP-11 또는 LP-111 상태로 설정하는 것입니다. 이를 지원하는 transmitter hardware가 필요하며 모든 장치에서 가능한 것은 아닙니다. 많은 장치는 streaming을 멈추면 이 상태로 돌아가지만 power-on 직후 상태는 LP-00 또는 LP-000입니다.

`.pre_streamon()`은 transmitter가 streaming 상태로 전환할 준비를 하되 아직 streaming은 시작하지 않게 합니다. `.post_streamoff()`는 `.pre_streamon()`의 작업을 되돌리므로 caller는 성공한 `.pre_streamon()` 호출마다 `.post_streamoff()`를 한 번 호출해야 합니다.

CSI-2에서 `.pre_streamon()`은 transmitter를 LP-11 또는 LP-111로 전환하며 장치 power-on도 요구하므로 필요할 때만 수행해야 합니다. 명시적 LP-11·LP-111 설정이 필요 없는 receiver driver는 두 callback을 호출하지 않아도 됩니다.

CSI-2 explicit LP 상태 준비
명시적 LP 관찰 불필요두 callback 호출 면제
필요`.pre_streamon()`Power on + LP-11/LP-111High-speed transition
Streaming 종료성공한 pre마다 `.post_streamoff()`준비 작업 되돌림
Power-on 기본LP-00/LP-000

명시적 상태 설정이 필요한 receiver만 성공한 pre 호출과 post 호출을 대칭으로 유지합니다.

LP-11 and LP-111 states
^^^^^^^^^^^^^^^^^^^^^^^

As part of transitioning to high speed mode, a CSI-2 transmitter typically
briefly sets the bus to LP-11 or LP-111 state, depending on the PHY. This period
may be as short as 100 µs, during which the receiver observes this state and
proceeds its own part of high speed mode transition.

Most receivers are capable of autonomously handling this once the software has
configured them to do so, but there are receivers which require software
involvement in observing LP-11 or LP-111 state. 100 µs is a brief period to hit
in software, especially when there is no interrupt telling something is
happening.

One way to address this is to configure the transmitter side explicitly to LP-11
or LP-111 state, which requires support from the transmitter hardware. This is
not universally available. Many devices return to this state once streaming is
stopped while the state after power-on is LP-00 or LP-000.

The ``.pre_streamon()`` callback may be used to prepare a transmitter for
transitioning to streaming state, but not yet start streaming. Similarly, the
``.post_streamoff()`` callback is used to undo what was done by the
``.pre_streamon()`` callback. The caller of ``.pre_streamon()`` is thus required
to call ``.post_streamoff()`` for each successful call of ``.pre_streamon()``.

In the context of CSI-2, the ``.pre_streamon()`` callback is used to transition
the transmitter to the LP-11 or LP-111 state. This also requires powering on the
device, so this should be only done when it is needed.

Receiver drivers that do not need explicit LP-11 or LP-111 state setup are
waived from calling the two callbacks.