요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. 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 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.
``.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 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 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.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Pixel data transmitter·receiver bus
1-33V4L2는 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합니다.
.. 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-58Transmitter 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를 사용해야 합니다.
사용자 구성 가능 여부에 따라 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-77Receiver 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는 어느 방식도 가정하지 않고 두 경우 모두 올바르게 동작해야 합니다.
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-113CSI-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 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-144CSI-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을 호출하지 않아도 됩니다.
명시적 상태 설정이 필요한 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.
요약과 해설
tx-rx.rst:1-144Pixel transmitter와 receiver는 bus format·link frequency·streaming 생명주기를 합의해야 합니다. CSI-2에서는 PHY·lane·sample 폭을 반영해 bus pixel rate를 계산하고, 필요한 hardware에서는 짧은 LP-11·LP-111 상태를 명시적으로 준비합니다.