← Documents Documentation/admin-guide/media/vimc.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Media

The Virtual Media Controller Driver (vimc)

vimc의 virtual media topology, format 설정 명령, sensor·lens·debayer·scaler·capture subdevice와 allocator option을 설명합니다.

Source pathDocumentation/admin-guide/media/vimc.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

vimc 운용 개요

vimc.rst:1-110

Vimc는 실제 camera hardware 없이 V4L2·Media pipeline을 시험할 수 있게 합니다. 연결된 entity의 format을 일치시킨 뒤 capture node를 설정하는 순서가 핵심입니다.

항목API·구성핵심
목적V4L2 API + Media API복잡한 video hardware emulation
기본 구성capture + sensor/debayer/scalerhardcoded topology
설정 도구media-ctl + v4l2-ctllinked subdevice format 일치
Buffer allocatorallocator=0 또는 1vmalloc / dma-contig

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 The Virtual Media Controller Driver (vimc)
4 ==========================================
5
6 The vimc driver emulates complex video hardware using the V4L2 API and the Media
7 API. It has a capture device and three subdevices: sensor, debayer and scaler.
8
9 Topology
10 --------
11
12 The topology is hardcoded, although you could modify it in vimc-core and
13 recompile the driver to achieve your own topology. This is the default topology:
14
15 .. _vimc_topology_graph:
16
17 .. kernel-figure:: vimc.dot
18 :alt: Diagram of the default media pipeline topology
19 :align: center
20
21 Media pipeline graph on vimc
22
23 Configuring the topology
24 ~~~~~~~~~~~~~~~~~~~~~~~~
25
26 Each subdevice will come with its default configuration (pixelformat, height,
27 width, ...). One needs to configure the topology in order to match the
28 configuration on each linked subdevice to stream frames through the pipeline.
29 If the configuration doesn't match, the stream will fail. The ``v4l-utils``
30 package is a bundle of user-space applications, that comes with ``media-ctl`` and
31 ``v4l2-ctl`` that can be used to configure the vimc configuration. This sequence
32 of commands fits for the default topology:
33
34 .. code-block:: bash
35
36 media-ctl -d platform:vimc -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]'
37 media-ctl -d platform:vimc -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]'
38 media-ctl -d platform:vimc -V '"Scaler":0[fmt:RGB888_1X24/640x480]'
39 media-ctl -d platform:vimc -V '"Scaler":0[crop:(100,50)/400x150]'
40 media-ctl -d platform:vimc -V '"Scaler":1[fmt:RGB888_1X24/300x700]'
41 v4l2-ctl -z platform:vimc -d "RGB/YUV Capture" -v width=300,height=700
42 v4l2-ctl -z platform:vimc -d "Raw Capture 0" -v pixelformat=BA81
43
44 Subdevices
45 ----------
46
47 Subdevices define the behavior of an entity in the topology. Depending on the
48 subdevice, the entity can have multiple pads of type source or sink.
49
50 vimc-sensor:
51 Generates images in several formats using video test pattern generator.
52 Exposes:
53
54 * 1 Pad source
55
56 vimc-lens:
57 Ancillary lens for a sensor. Supports auto focus control. Linked to
58 a vimc-sensor using an ancillary link. The lens supports FOCUS_ABSOLUTE
59 control.
60
61 .. code-block:: bash
62
63 media-ctl -p
64 ...
65 - entity 28: Lens A (0 pad, 0 link)
66 type V4L2 subdev subtype Lens flags 0
67 device node name /dev/v4l-subdev6
68 - entity 29: Lens B (0 pad, 0 link)
69 type V4L2 subdev subtype Lens flags 0
70 device node name /dev/v4l-subdev7
71 v4l2-ctl -d /dev/v4l-subdev7 -C focus_absolute
72 focus_absolute: 0
73
74
75 vimc-debayer:
76 Transforms images in bayer format into a non-bayer format.
77 Exposes:
78
79 * 1 Pad sink
80 * 1 Pad source
81
82 vimc-scaler:
83 Re-size the image to meet the source pad resolution. E.g.: if the sync
84 pad is configured to 360x480 and the source to 1280x720, the image will
85 be stretched to fit the source resolution. Works for any resolution
86 within the vimc limitations (even shrinking the image if necessary).
87 Exposes:
88
89 * 1 Pad sink
90 * 1 Pad source
91
92 vimc-capture:
93 Exposes node /dev/videoX to allow userspace to capture the stream.
94 Exposes:
95
96 * 1 Pad sink
97 * 1 Pad source
98
99 Module options
100 --------------
101
102 Vimc has a module parameter to configure the driver.
103
104 * ``allocator=<unsigned int>``
105
106 memory allocator selection, default is 0. It specifies the way buffers
107 will be allocated.
108
109 - 0: vmalloc
110 - 1: dma-contig
111

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-21

Topology는 hardcoded되어 있습니다. 원하는 topology가 필요하면 `vimc-core`를 수정하고 driver를 다시 compile할 수 있습니다.

vimc 기본 media pipeline
Sensor ADebayer AScalerRGB/YUV Capture
Sensor ARaw Capture 0
Sensor ALens A (ancillary)
Sensor BDebayer BScaler (disabled link)
Sensor BRaw Capture 1
Sensor BLens B (ancillary)
RGB/YUV InputScaler (disabled link)RGB/YUV Capture

`vimc.dot`의 sensor, lens, debayer, scaler, raw/RGB capture 연결을 pipeline별로 구조화했습니다. 비활성 dashed link와 ancillary lens link는 label로 구분합니다.

Source entity·padLink 상태Sink entity·pad
Sensor A /dev/v4l-subdev0 pad 0enabledDebayer A /dev/v4l-subdev2 pad 0
Sensor A /dev/v4l-subdev0 pad 0enabledRaw Capture 0 /dev/video0
Sensor A /dev/v4l-subdev0ancillaryLens A /dev/v4l-subdev5
Sensor B /dev/v4l-subdev1 pad 0enabledDebayer B /dev/v4l-subdev3 pad 0
Sensor B /dev/v4l-subdev1 pad 0enabledRaw Capture 1 /dev/video1
Sensor B /dev/v4l-subdev1ancillaryLens B /dev/v4l-subdev6
Debayer A /dev/v4l-subdev2 pad 1solidScaler /dev/v4l-subdev5 pad 0
Debayer B /dev/v4l-subdev3 pad 1disabled (dashed)Scaler /dev/v4l-subdev5 pad 0
RGB/YUV Input /dev/v4l-subdev4 pad 0disabled (dashed)Scaler /dev/v4l-subdev5 pad 0
Scaler /dev/v4l-subdev5 pad 1enabledRGB/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-97

Subdevice는 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-110

Vimc는 driver 설정을 위한 module parameter를 제공합니다.

`allocator=<unsigned int>`는 memory allocator를 선택하며 기본값은 0입니다. Buffer 할당 방식을 지정합니다.

  • `0`: `vmalloc`
  • `1`: `dma-contig`