요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
The Virtual Media Controller Driver (vimc)
==========================================
The vimc driver emulates complex video hardware using the V4L2 API and the Media
API. It has a capture device and three subdevices: sensor, debayer and scaler.
Topology
--------
The topology is hardcoded, although you could modify it in vimc-core and
recompile the driver to achieve your own topology. This is the default topology:
.. _vimc_topology_graph:
.. kernel-figure:: vimc.dot
:alt: Diagram of the default media pipeline topology
:align: center
Media pipeline graph on vimc
Configuring the topology
~~~~~~~~~~~~~~~~~~~~~~~~
Each subdevice will come with its default configuration (pixelformat, height,
width, ...). One needs to configure the topology in order to match the
configuration on each linked subdevice to stream frames through the pipeline.
If the configuration doesn't match, the stream will fail. The ``v4l-utils``
package is a bundle of user-space applications, that comes with ``media-ctl`` and
``v4l2-ctl`` that can be used to configure the vimc configuration. This sequence
of commands fits for the default topology:
.. code-block:: bash
media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
media-ctl -d platform:vimc -V '"Scaler":0[fmt:RGB888_1X24/640x480]'
media-ctl -d platform:vimc -V '"Scaler":0[crop:(100,50)/400x150]'
media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/300x700]'
v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=300,height=700
v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81
Subdevices
----------
Subdevices define the behavior of an entity in the topology. Depending on the
subdevice, the entity can have multiple pads of type source or sink.
vimc-sensor:
Generates images in several formats using video test pattern generator.
Exposes:
* 1 Pad source
vimc-lens:
Ancillary lens for a sensor. Supports auto focus control. Linked to
a vimc-sensor using an ancillary link. The lens supports FOCUS_ABSOLUTE
control.
.. code-block:: bash
media-ctl -p
...
- entity 28: Lens A (0 pad, 0 link)
type V4L2 subdev subtype Lens flags 0
device node name /dev/v4l-subdev6
- entity 29: Lens B (0 pad, 0 link)
type V4L2 subdev subtype Lens flags 0
device node name /dev/v4l-subdev7
v4l2-ctl -d /dev/v4l-subdev7 -C focus_absolute
focus_absolute: 0
vimc-debayer:
Transforms images in bayer format into a non-bayer format.
Exposes:
* 1 Pad sink
* 1 Pad source
vimc-scaler:
Re-size the image to meet the source pad resolution. E.g.: if the sync
pad is configured to 360x480 and the source to 1280x720, the image will
be stretched to fit the source resolution. Works for any resolution
within the vimc limitations (even shrinking the image if necessary).
Exposes:
* 1 Pad sink
* 1 Pad source
vimc-capture:
Exposes node /dev/videoX to allow userspace to capture the stream.
Exposes:
* 1 Pad sink
* 1 Pad source
Module options
--------------
Vimc has a module parameter to configure the driver.
* ``allocator=<unsigned int>``
memory allocator selection, default is 0. It specifies the way buffers
will be allocated.
- 0: vmalloc
- 1: dma-contig
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
vimc 개요
1-7이 문서는 GPL-2.0 라이선스를 따릅니다. `vimc` driver는 V4L2 API와 Media API를 사용해 복잡한 video hardware를 emulation합니다.
기본 구성에는 capture device 하나와 sensor, debayer, scaler의 세 subdevice가 있습니다.
기본 topology
9-21Topology는 hardcoded되어 있습니다. 원하는 topology가 필요하면 `vimc-core`를 수정하고 driver를 다시 compile할 수 있습니다.
`vimc.dot`의 sensor, lens, debayer, scaler, raw/RGB capture 연결을 pipeline별로 구조화했습니다. 비활성 dashed link와 ancillary lens link는 label로 구분합니다.
| Source entity·pad | Link 상태 | Sink entity·pad |
|---|---|---|
| Sensor A /dev/v4l-subdev0 pad 0 | enabled | Debayer A /dev/v4l-subdev2 pad 0 |
| Sensor A /dev/v4l-subdev0 pad 0 | enabled | Raw Capture 0 /dev/video0 |
| Sensor A /dev/v4l-subdev0 | ancillary | Lens A /dev/v4l-subdev5 |
| Sensor B /dev/v4l-subdev1 pad 0 | enabled | Debayer B /dev/v4l-subdev3 pad 0 |
| Sensor B /dev/v4l-subdev1 pad 0 | enabled | Raw Capture 1 /dev/video1 |
| Sensor B /dev/v4l-subdev1 | ancillary | Lens B /dev/v4l-subdev6 |
| Debayer A /dev/v4l-subdev2 pad 1 | solid | Scaler /dev/v4l-subdev5 pad 0 |
| Debayer B /dev/v4l-subdev3 pad 1 | disabled (dashed) | Scaler /dev/v4l-subdev5 pad 0 |
| RGB/YUV Input /dev/v4l-subdev4 pad 0 | disabled (dashed) | Scaler /dev/v4l-subdev5 pad 0 |
| Scaler /dev/v4l-subdev5 pad 1 | enabled | RGB/YUV Capture /dev/video2 |
표의 device node는 `Documentation/admin-guide/media/vimc.dot` label을 그대로 반영합니다. 아래 `media-ctl -p` 예제의 Lens A/B node 번호는 runtime 예시 표기를 그대로 보존합니다.
Topology 설정
23-42각 subdevice에는 pixel format, height, width 등의 기본 설정이 있습니다. Pipeline으로 frame을 stream하려면 연결된 모든 subdevice 설정이 서로 일치해야 하며, 맞지 않으면 stream이 실패합니다.
`v4l-utils` user-space application 묶음에는 vimc 설정에 사용할 수 있는 `media-ctl`과 `v4l2-ctl`이 포함됩니다. 다음 명령은 기본 topology에 맞습니다.
media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
media-ctl -d platform:vimc -V '"Scaler":0[fmt:RGB888_1X24/640x480]'
media-ctl -d platform:vimc -V '"Scaler":0[crop:(100,50)/400x150]'
media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/300x700]'
v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=300,height=700
v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81
Subdevice 동작
44-97Subdevice는 topology entity의 동작을 정의하며, 종류에 따라 source 또는 sink 유형의 pad를 여러 개 가질 수 있습니다.
`vimc-sensor`는 video test pattern generator로 여러 format의 image를 생성하며 source pad 하나를 노출합니다.
`vimc-lens`는 sensor의 ancillary lens입니다. Auto focus control을 지원하고 ancillary link로 `vimc-sensor`에 연결되며 `FOCUS_ABSOLUTE` control을 지원합니다.
media-ctl -p
...
- entity 28: Lens A (0 pad, 0 link)
type V4L2 subdev subtype Lens flags 0
device node name /dev/v4l-subdev6
- entity 29: Lens B (0 pad, 0 link)
type V4L2 subdev subtype Lens flags 0
device node name /dev/v4l-subdev7
v4l2-ctl -d /dev/v4l-subdev7 -C focus_absolute
focus_absolute: 0
`vimc-debayer`는 Bayer format image를 non-Bayer format으로 변환하며 sink pad 하나와 source pad 하나를 노출합니다.
`vimc-scaler`는 image를 source pad resolution에 맞게 resize합니다. 예를 들어 sink pad가 360x480이고 source가 1280x720이면 source resolution에 맞춰 image를 늘립니다. 필요하면 축소하는 경우를 포함해 vimc 제한 안의 모든 resolution에서 동작하며 sink pad 하나와 source pad 하나를 노출합니다.
`vimc-capture`는 userspace가 stream을 capture할 수 있도록 `/dev/videoX` node를 노출하며 sink pad 하나와 source pad 하나를 제공합니다.
Module option
99-110Vimc는 driver 설정을 위한 module parameter를 제공합니다.
`allocator=<unsigned int>`는 memory allocator를 선택하며 기본값은 0입니다. Buffer 할당 방식을 지정합니다.
- `0`: `vmalloc`
- `1`: `dma-contig`
vimc 운용 개요
vimc.rst:1-110Vimc는 실제 camera hardware 없이 V4L2·Media pipeline을 시험할 수 있게 합니다. 연결된 entity의 format을 일치시킨 뒤 capture node를 설정하는 순서가 핵심입니다.