← Documents Documentation/userspace-api/media/v4l/dev-overlay.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / V4L

비디오 Overlay 인터페이스

V4L2 Video Overlay의 동시 capture 모델, framebuffer 보안, window·clipping·blending 구조와 실행 절차를 설명합니다.

Source pathDocumentation/userspace-api/media/v4l/dev-overlay.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

dev-overlay.rst:1-326

Video Overlay는 capture 영상을 framebuffer 또는 그래픽 출력에 합성하는 V4L2 경로입니다. 동시 capture에서는 logical stream마다 descriptor를 분리하고, window와 crop의 크기로 scaling을 정하며, chroma key나 alpha 같은 지원 방식을 확인한 뒤 VIDIOC_OVERLAY로 표시를 전환합니다.

Framebuffer physical memory에 직접 DMA하는 구형 설정은 권한 경계를 요구합니다. 현재 제거된 clips와 bitmap 필드는 기존 ABI의 의미를 이해하기 위해 기록되어 있으며, 새 코드에서는 드라이버가 제공하는 현재 기능과 반환 값을 기준으로 동작해야 합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _overlay:
4
5 ***********************
6 Video Overlay Interface
7 ***********************
8
9 **Also known as Framebuffer Overlay or Previewing.**
10
11 Video overlay devices have the ability to genlock (TV-)video into the
12 (VGA-)video signal of a graphics card, or to store captured images
13 directly in video memory of a graphics card, typically with clipping.
14 This can be considerable more efficient than capturing images and
15 displaying them by other means. In the old days when only nuclear power
16 plants needed cooling towers this used to be the only way to put live
17 video into a window.
18
19 Video overlay devices are accessed through the same character special
20 files as :ref:`video capture <capture>` devices.
21
22 .. note::
23
24 The default function of a ``/dev/video`` device is video
25 capturing. The overlay function is only available after calling
26 the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl.
27
28 The driver may support simultaneous overlay and capturing using the
29 read/write and streaming I/O methods. If so, operation at the nominal
30 frame rate of the video standard is not guaranteed. Frames may be
31 directed away from overlay to capture, or one field may be used for
32 overlay and the other for capture if the capture parameters permit this.
33
34 Applications should use different file descriptors for capturing and
35 overlay. This must be supported by all drivers capable of simultaneous
36 capturing and overlay. Optionally these drivers may also permit
37 capturing and overlay with a single file descriptor for compatibility
38 with V4L and earlier versions of V4L2. [#f1]_
39
40 A common application of two file descriptors is the X11
41 :ref:`Xv/V4L <xvideo>` interface driver and a V4L2 application.
42 While the X server controls video overlay, the application can take
43 advantage of memory mapping and DMA.
44
45 Querying Capabilities
46 =====================
47
48 Devices supporting the video overlay interface set the
49 ``V4L2_CAP_VIDEO_OVERLAY`` flag in the ``capabilities`` field of struct
50 :c:type:`v4l2_capability` returned by the
51 :ref:`VIDIOC_QUERYCAP` ioctl. The overlay I/O
52 method specified below must be supported. Tuners and audio inputs are
53 optional.
54
55
56 Supplemental Functions
57 ======================
58
59 Video overlay devices shall support :ref:`audio input <audio>`,
60 :ref:`tuner`, :ref:`controls <control>`,
61 :ref:`cropping and scaling <crop>` and
62 :ref:`streaming parameter <streaming-par>` ioctls as needed. The
63 :ref:`video input <video>` and :ref:`video standard <standard>`
64 ioctls must be supported by all video overlay devices.
65
66
67 Setup
68 =====
69
70 *Note: support for this has been removed.*
71 Before overlay can commence applications must program the driver with
72 frame buffer parameters, namely the address and size of the frame buffer
73 and the image format, for example RGB 5:6:5. The
74 :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>` and
75 :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` ioctls are available to get and
76 set these parameters, respectively. The :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` ioctl is
77 privileged because it allows to set up DMA into physical memory,
78 bypassing the memory protection mechanisms of the kernel. Only the
79 superuser can change the frame buffer address and size. Users are not
80 supposed to run TV applications as root or with SUID bit set. A small
81 helper application with suitable privileges should query the graphics
82 system and program the V4L2 driver at the appropriate time.
83
84 Some devices add the video overlay to the output signal of the graphics
85 card. In this case the frame buffer is not modified by the video device,
86 and the frame buffer address and pixel format are not needed by the
87 driver. The :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` ioctl is not privileged. An application
88 can check for this type of device by calling the :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`
89 ioctl.
90
91 A driver may support any (or none) of five clipping/blending methods:
92
93 1. Chroma-keying displays the overlaid image only where pixels in the
94 primary graphics surface assume a certain color.
95
96 2. *Note: support for this has been removed.*
97 A bitmap can be specified where each bit corresponds to a pixel in
98 the overlaid image. When the bit is set, the corresponding video
99 pixel is displayed, otherwise a pixel of the graphics surface.
100
101 3. *Note: support for this has been removed.*
102 A list of clipping rectangles can be specified. In these regions *no*
103 video is displayed, so the graphics surface can be seen here.
104
105 4. The framebuffer has an alpha channel that can be used to clip or
106 blend the framebuffer with the video.
107
108 5. A global alpha value can be specified to blend the framebuffer
109 contents with video images.
110
111 When simultaneous capturing and overlay is supported and the hardware
112 prohibits different image and frame buffer formats, the format requested
113 first takes precedence. The attempt to capture
114 (:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`) or overlay
115 (:ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>`) may fail with an ``EBUSY`` error
116 code or return accordingly modified parameters..
117
118
119 Overlay Window
120 ==============
121
122 The overlaid image is determined by cropping and overlay window
123 parameters. The former select an area of the video picture to capture,
124 the latter how images are overlaid and clipped. Cropping initialization
125 at minimum requires to reset the parameters to defaults. An example is
126 given in :ref:`crop`.
127
128 The overlay window is described by a struct
129 :c:type:`v4l2_window`. It defines the size of the image,
130 its position over the graphics surface and the clipping to be applied.
131 To get the current parameters applications set the ``type`` field of a
132 struct :c:type:`v4l2_format` to
133 ``V4L2_BUF_TYPE_VIDEO_OVERLAY`` and call the
134 :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl. The driver fills the
135 struct :c:type:`v4l2_window` substructure named ``win``. It is not
136 possible to retrieve a previously programmed clipping list or bitmap.
137
138 To program the overlay window applications set the ``type`` field of a
139 struct :c:type:`v4l2_format` to
140 ``V4L2_BUF_TYPE_VIDEO_OVERLAY``, initialize the ``win`` substructure and
141 call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl. The driver
142 adjusts the parameters against hardware limits and returns the actual
143 parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does. Like :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`, the
144 :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl can be used to learn
145 about driver capabilities without actually changing driver state. Unlike
146 :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` this also works after the overlay has been enabled.
147
148 The scaling factor of the overlaid image is implied by the width and
149 height given in struct :c:type:`v4l2_window` and the size
150 of the cropping rectangle. For more information see :ref:`crop`.
151
152 When simultaneous capturing and overlay is supported and the hardware
153 prohibits different image and window sizes, the size requested first
154 takes precedence. The attempt to capture or overlay as well
155 (:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`) may fail with an ``EBUSY`` error
156 code or return accordingly modified parameters.
157
158
159 .. c:type:: v4l2_window
160
161 struct v4l2_window
162 ------------------
163
164 ``struct v4l2_rect w``
165 Size and position of the window relative to the top, left corner of
166 the frame buffer defined with
167 :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>`. The window can extend the
168 frame buffer width and height, the ``x`` and ``y`` coordinates can
169 be negative, and it can lie completely outside the frame buffer. The
170 driver clips the window accordingly, or if that is not possible,
171 modifies its size and/or position.
172
173 ``enum v4l2_field field``
174 Applications set this field to determine which video field shall be
175 overlaid, typically one of ``V4L2_FIELD_ANY`` (0),
176 ``V4L2_FIELD_TOP``, ``V4L2_FIELD_BOTTOM`` or
177 ``V4L2_FIELD_INTERLACED``. Drivers may have to choose a different
178 field order and return the actual setting here.
179
180 ``__u32 chromakey``
181 When chroma-keying has been negotiated with
182 :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` applications set this field
183 to the desired pixel value for the chroma key. The format is the
184 same as the pixel format of the framebuffer (struct
185 :c:type:`v4l2_framebuffer` ``fmt.pixelformat``
186 field), with bytes in host order. E. g. for
187 :ref:`V4L2_PIX_FMT_BGR24 <V4L2-PIX-FMT-BGR32>` the value should
188 be 0xRRGGBB on a little endian, 0xBBGGRR on a big endian host.
189
190 ``struct v4l2_clip * clips``
191 *Note: support for this has been removed.*
192 When chroma-keying has *not* been negotiated and
193 :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>` indicated this capability,
194 applications can set this field to point to an array of clipping
195 rectangles.
196
197 Like the window coordinates w, clipping rectangles are defined
198 relative to the top, left corner of the frame buffer. However
199 clipping rectangles must not extend the frame buffer width and
200 height, and they must not overlap. If possible applications
201 should merge adjacent rectangles. Whether this must create
202 x-y or y-x bands, or the order of rectangles, is not defined. When
203 clip lists are not supported the driver ignores this field. Its
204 contents after calling :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
205 are undefined.
206
207 ``__u32 clipcount``
208 *Note: support for this has been removed.*
209 When the application set the ``clips`` field, this field must
210 contain the number of clipping rectangles in the list. When clip
211 lists are not supported the driver ignores this field, its contents
212 after calling :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` are undefined. When clip lists are
213 supported but no clipping is desired this field must be set to zero.
214
215 ``void * bitmap``
216 *Note: support for this has been removed.*
217 When chroma-keying has *not* been negotiated and
218 :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>` indicated this capability,
219 applications can set this field to point to a clipping bit mask.
220
221 It must be of the same size as the window, ``w.width`` and ``w.height``.
222 Each bit corresponds to a pixel in the overlaid image, which is
223 displayed only when the bit is *set*. Pixel coordinates translate to
224 bits like:
225
226
227 .. code-block:: c
228
229 ((__u8 *) bitmap)[w.width * y + x / 8] & (1 << (x & 7))
230
231 where ``0`` ≤ x < ``w.width`` and ``0`` ≤ y <``w.height``. [#f2]_
232
233 When a clipping bit mask is not supported the driver ignores this field,
234 its contents after calling :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` are
235 undefined. When a bit mask is supported but no clipping is desired this
236 field must be set to ``NULL``.
237
238 Applications need not create a clip list or bit mask. When they pass
239 both, or despite negotiating chroma-keying, the results are undefined.
240 Regardless of the chosen method, the clipping abilities of the hardware
241 may be limited in quantity or quality. The results when these limits are
242 exceeded are undefined. [#f3]_
243
244 ``__u8 global_alpha``
245 The global alpha value used to blend the framebuffer with video
246 images, if global alpha blending has been negotiated
247 (``V4L2_FBUF_FLAG_GLOBAL_ALPHA``, see
248 :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>`,
249 :ref:`framebuffer-flags`).
250
251 .. note::
252
253 This field was added in Linux 2.6.23, extending the
254 structure. However the :ref:`VIDIOC_[G|S|TRY]_FMT <VIDIOC_G_FMT>`
255 ioctls, which take a pointer to a :c:type:`v4l2_format`
256 parent structure with padding bytes at the end, are not affected.
257
258
259 .. c:type:: v4l2_clip
260
261 struct v4l2_clip [#f4]_
262 -----------------------
263
264 ``struct v4l2_rect c``
265 Coordinates of the clipping rectangle, relative to the top, left
266 corner of the frame buffer. Only window pixels *outside* all
267 clipping rectangles are displayed.
268
269 ``struct v4l2_clip * next``
270 Pointer to the next clipping rectangle, ``NULL`` when this is the last
271 rectangle. Drivers ignore this field, it cannot be used to pass a
272 linked list of clipping rectangles.
273
274
275 .. c:type:: v4l2_rect
276
277 struct v4l2_rect
278 ----------------
279
280 ``__s32 left``
281 Horizontal offset of the top, left corner of the rectangle, in
282 pixels.
283
284 ``__s32 top``
285 Vertical offset of the top, left corner of the rectangle, in pixels.
286 Offsets increase to the right and down.
287
288 ``__u32 width``
289 Width of the rectangle, in pixels.
290
291 ``__u32 height``
292 Height of the rectangle, in pixels.
293
294
295 Enabling Overlay
296 ================
297
298 To start or stop the frame buffer overlay applications call the
299 :ref:`VIDIOC_OVERLAY` ioctl.
300
301 .. [#f1]
302 In the opinion of the designers of this API, no driver writer taking
303 the efforts to support simultaneous capturing and overlay will
304 restrict this ability by requiring a single file descriptor, as in
305 V4L and earlier versions of V4L2. Making this optional means
306 applications depending on two file descriptors need backup routines
307 to be compatible with all drivers, which is considerable more work
308 than using two fds in applications which do not. Also two fd's fit
309 the general concept of one file descriptor for each logical stream.
310 Hence as a complexity trade-off drivers *must* support two file
311 descriptors and *may* support single fd operation.
312
313 .. [#f2]
314 Should we require ``w.width`` to be a multiple of eight?
315
316 .. [#f3]
317 When the image is written into frame buffer memory it will be
318 undesirable if the driver clips out less pixels than expected,
319 because the application and graphics system are not aware these
320 regions need to be refreshed. The driver should clip out more pixels
321 or not write the image at all.
322
323 .. [#f4]
324 The X Window system defines "regions" which are vectors of ``struct
325 BoxRec { short x1, y1, x2, y2; }`` with ``width = x2 - x1`` and
326 ``height = y2 - y1``, so one cannot pass X11 clip lists directly.
327

3. 한국어 전문 번역

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

Overlay 개요와 동시 스트림 모델

1-44

Video Overlay 인터페이스는 Framebuffer Overlay 또는 previewing이라고도 부릅니다. 일부 비디오 캡처 장치는 TV 영상 신호를 VGA 신호와 genlock 방식으로 합성하거나, 캡처한 영상을 그래픽 카드의 video memory에 직접 저장합니다. 보통 화면의 일부 영역만 갱신하도록 clipping하며, 예전에는 CPU와 bus 자원을 적게 쓰는 효율적인 미리보기 방식이었습니다.

Overlay는 video capture와 같은 character special file로 접근합니다. `/dev/video` 장치의 기본 기능은 capture이고, 애플리케이션이 `VIDIOC_S_FMT`로 overlay 형식을 설정한 뒤에만 overlay 기능을 사용할 수 있습니다.

드라이버가 허용하면 overlay와 read/write 또는 streaming capture를 동시에 실행할 수 있습니다. 다만 명목상 frame rate가 보장되는 것은 아닙니다. 장치가 일부 frame을 capture 쪽으로 전환하거나, 두 요청의 매개변수가 맞을 때 한 field씩 번갈아 처리할 수 있기 때문입니다.

동시 overlay와 capture를 사용하는 애플리케이션은 서로 다른 file descriptor를 사용해야 합니다. 이 기능을 제공하는 모든 드라이버는 두 descriptor 방식을 지원해야 하고, 하나의 descriptor에서 두 logical stream을 다루는 구형 V4L/초기 V4L2 호환 방식은 선택 사항입니다.

대표적인 구성은 X11의 Xv/V4L 드라이버가 한 descriptor로 overlay를 소유하고, 별도의 V4L2 애플리케이션이 다른 descriptor에서 memory mapping 또는 DMA capture를 수행하는 형태입니다.

Overlay와 capture 동시 처리
/dev/video를 두 번 open첫 번째 descriptor에서 VIDIOC_S_FMT로 overlay 구성Xv/V4L 계층이 overlay stream 소유두 번째 descriptor에서 mmap 또는 DMA capture 구성장치가 frame 또는 field 단위로 두 stream을 조정

각 logical stream을 별도의 descriptor로 분리합니다.

Descriptor 지원 규칙
항목설명
두 descriptor반드시 지원해야 하며 각 descriptor가 하나의 logical stream을 담당
한 descriptor구형 V4L/초기 V4L2 애플리케이션 호환을 위해 선택적으로 지원
Frame rate동시 실행 시 명목상 속도를 보장하지 않음
처리 단위일부 frame을 capture로 돌리거나 field를 교대로 처리 가능

동시 기능을 제공하는 드라이버의 호환성 요구 사항입니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later

.. _overlay:

***********************
Video Overlay Interface
***********************

**Also known as Framebuffer Overlay or Previewing.**

Video overlay devices have the ability to genlock (TV-)video into the
(VGA-)video signal of a graphics card, or to store captured images
directly in video memory of a graphics card, typically with clipping.
This can be considerable more efficient than capturing images and
displaying them by other means. In the old days when only nuclear power
plants needed cooling towers this used to be the only way to put live
video into a window.

Video overlay devices are accessed through the same character special
files as :ref:`video capture <capture>` devices.

.. note::

   The default function of a ``/dev/video`` device is video
   capturing. The overlay function is only available after calling
   the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl.

The driver may support simultaneous overlay and capturing using the
read/write and streaming I/O methods. If so, operation at the nominal
frame rate of the video standard is not guaranteed. Frames may be
directed away from overlay to capture, or one field may be used for
overlay and the other for capture if the capture parameters permit this.

Applications should use different file descriptors for capturing and
overlay. This must be supported by all drivers capable of simultaneous
capturing and overlay. Optionally these drivers may also permit
capturing and overlay with a single file descriptor for compatibility
with V4L and earlier versions of V4L2. [#f1]_

A common application of two file descriptors is the X11
:ref:`Xv/V4L <xvideo>` interface driver and a V4L2 application.
While the X server controls video overlay, the application can take
advantage of memory mapping and DMA.

Capability와 보조 기능

45-66

Video Overlay를 지원하는 장치는 `VIDIOC_QUERYCAP`가 반환하는 `struct v4l2_capability.capabilities`에 `V4L2_CAP_VIDEO_OVERLAY`를 설정합니다. 이 장치에는 overlay I/O가 필수이고 tuner와 audio input은 선택 사항입니다.

장치가 실제로 제공하는 기능에 따라 audio input, tuner, control, cropping/scaling, streaming parameter 관련 ioctl도 지원해야 합니다. 반면 video input과 video standard ioctl은 모든 Video Overlay 장치가 반드시 구현해야 합니다.

Overlay capability 구성
항목설명
capabilities 필드struct v4l2_capability에서 장치 기능 bit를 제공
V4L2_CAP_VIDEO_OVERLAYVIDIOC_QUERYCAP로 확인하는 핵심 capability
Overlay I/O모든 Video Overlay 장치의 필수 기능
Video input모든 Video Overlay 장치가 관련 ioctl을 지원
Video standard모든 Video Overlay 장치가 관련 ioctl을 지원
Tuner / audio input하드웨어에 있을 때 지원하는 선택 기능
Control / crop / stream parameter해당 기능을 제공할 때 관련 ioctl 지원

필수 기능과 장치별 보조 기능을 구분합니다.

기능 탐색 순서
VIDIOC_QUERYCAP 호출V4L2_CAP_VIDEO_OVERLAY 확인video input과 video standard 열거필요하면 tuner와 audio input 확인control, crop, streaming parameter 지원 확인

사용 전에 capability와 필요한 보조 경로를 확인합니다.

Querying Capabilities
=====================

Devices supporting the video overlay interface set the
``V4L2_CAP_VIDEO_OVERLAY`` flag in the ``capabilities`` field of struct
:c:type:`v4l2_capability` returned by the
:ref:`VIDIOC_QUERYCAP` ioctl. The overlay I/O
method specified below must be supported. Tuners and audio inputs are
optional.


Supplemental Functions
======================

Video overlay devices shall support :ref:`audio input <audio>`,
:ref:`tuner`, :ref:`controls <control>`,
:ref:`cropping and scaling <crop>` and
:ref:`streaming parameter <streaming-par>` ioctls as needed. The
:ref:`video input <video>` and :ref:`video standard <standard>`
ioctls must be supported by all video overlay devices.

Framebuffer 설정과 clipping 방식

67-118

현재 API에서 framebuffer setup 지원은 제거되었습니다. 다음 설명은 제거된 인터페이스의 동작과 기존 애플리케이션이 알아야 할 의미를 기록합니다.

과거 인터페이스에서는 overlay를 시작하기 전에 `VIDIOC_G_FBUF`와 `VIDIOC_S_FBUF`로 framebuffer의 physical address, 크기, pixel format을 설정했습니다. 예를 들어 RGB 5:6:5처럼 그래픽 메모리에 실제로 쓰이는 형식을 지정했습니다.

Framebuffer physical memory로 DMA하면 커널의 메모리 보호를 우회할 수 있으므로 `VIDIOC_S_FBUF`는 일반적으로 권한이 필요한 작업이었습니다. address와 크기를 바꾸는 권한은 superuser에게만 주어야 하며, TV 애플리케이션 전체를 root 또는 SUID로 실행해서는 안 됩니다. 필요한 설정만 작은 privileged helper로 분리하는 방식이 권장됩니다.

일부 장치는 framebuffer 내용을 수정하지 않고 그래픽 출력 단계에서 video를 합성합니다. 이런 장치는 address나 pixel format 설정이 필요하지 않고 `VIDIOC_S_FBUF`도 특권 작업이 아닙니다. 애플리케이션은 `VIDIOC_G_FBUF` 결과로 이 방식을 구별할 수 있습니다.

Overlay 영역을 제한하거나 배경과 합성하는 방법은 다섯 가지입니다. chroma key, 제거된 bitmap, 제거된 clipping rectangle list, framebuffer alpha channel, global alpha가 그것입니다. 실제 지원 방식은 framebuffer capability와 flag를 통해 협상합니다.

Capture와 overlay를 동시에 요청했는데 capture image format과 framebuffer format을 하드웨어가 함께 처리할 수 없다면 먼저 설정된 요청이 우선합니다. 나중의 `VIDIOC_S_FMT` 또는 `VIDIOC_S_FBUF`는 `EBUSY`로 실패하거나 하드웨어가 지원하는 매개변수로 조정해 반환할 수 있습니다.

Framebuffer 설정 보안 경계
VIDIOC_G_FBUF로 현재 framebuffer 특성 조회Address와 크기 변경 필요 여부 판단작은 privileged helper에서 VIDIOC_S_FBUF 실행일반 TV 애플리케이션은 비특권으로 유지Overlay 형식과 window를 일반 descriptor에서 구성

물리 메모리 접근은 최소 권한 helper에 한정합니다.

Clipping과 blending 방식
항목설명
Chroma key특정 framebuffer 색상을 key로 삼아 video를 표시
BitmapWindow 크기의 bit mask 사용, 지원 제거됨
Clipping rectangle list표시하지 않을 사각형 목록, 지원 제거됨
Framebuffer alpha channelFramebuffer pixel의 alpha channel로 혼합
Global alphaWindow 전체에 하나의 alpha 값 적용

Overlay pixel의 표시 범위를 결정하는 다섯 방식입니다.

동시 format 충돌
항목설명
첫 번째 S_FMT/S_FBUF지원 가능한 image/framebuffer format을 확정
호환되는 후속 요청요청한 매개변수로 진행
호환되지 않는 후속 요청EBUSY를 반환하거나 지원 값으로 조정

먼저 확정된 요청이 하드웨어 format을 선점합니다.

Setup
=====

*Note: support for this has been removed.*
Before overlay can commence applications must program the driver with
frame buffer parameters, namely the address and size of the frame buffer
and the image format, for example RGB 5:6:5. The
:ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>` and
:ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` ioctls are available to get and
set these parameters, respectively. The :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` ioctl is
privileged because it allows to set up DMA into physical memory,
bypassing the memory protection mechanisms of the kernel. Only the
superuser can change the frame buffer address and size. Users are not
supposed to run TV applications as root or with SUID bit set. A small
helper application with suitable privileges should query the graphics
system and program the V4L2 driver at the appropriate time.

Some devices add the video overlay to the output signal of the graphics
card. In this case the frame buffer is not modified by the video device,
and the frame buffer address and pixel format are not needed by the
driver. The :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` ioctl is not privileged. An application
can check for this type of device by calling the :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`
ioctl.

A driver may support any (or none) of five clipping/blending methods:

1. Chroma-keying displays the overlaid image only where pixels in the
   primary graphics surface assume a certain color.

2. *Note: support for this has been removed.*
   A bitmap can be specified where each bit corresponds to a pixel in
   the overlaid image. When the bit is set, the corresponding video
   pixel is displayed, otherwise a pixel of the graphics surface.

3. *Note: support for this has been removed.*
   A list of clipping rectangles can be specified. In these regions *no*
   video is displayed, so the graphics surface can be seen here.

4. The framebuffer has an alpha channel that can be used to clip or
   blend the framebuffer with the video.

5. A global alpha value can be specified to blend the framebuffer
   contents with video images.

When simultaneous capturing and overlay is supported and the hardware
prohibits different image and frame buffer formats, the format requested
first takes precedence. The attempt to capture
(:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`) or overlay
(:ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>`) may fail with an ``EBUSY`` error
code or return accordingly modified parameters..

Overlay window와 scaling

119-158

Cropping은 incoming video에서 사용할 영역을 고르고, overlay window는 framebuffer에서 영상을 놓을 위치와 clipping 정보를 정의합니다. 설정을 시작할 때 crop을 기본값으로 되돌리면 두 좌표계의 관계를 예측하기 쉽습니다.

현재 window를 읽으려면 `struct v4l2_format.type`을 `V4L2_BUF_TYPE_VIDEO_OVERLAY`로 설정하고 `VIDIOC_G_FMT`를 호출합니다. 드라이버는 `fmt.win`의 `struct v4l2_window`를 채웁니다. 과거에 설정한 clipping list나 bitmap은 다시 가져올 수 없습니다.

Window를 설정할 때는 같은 type으로 `win`을 채워 `VIDIOC_S_FMT`를 호출합니다. 드라이버는 하드웨어 제약에 맞게 값을 조정하고 실제 값을 반환합니다. `VIDIOC_TRY_FMT`는 상태를 바꾸지 않고 같은 제약을 시험하며, overlay를 이미 enabled한 뒤에도 사용할 수 있습니다.

Scaling 비율은 `v4l2_window`의 width와 height를 crop rectangle의 크기와 비교해 정해집니다. 하나가 framebuffer의 destination 크기이고 다른 하나가 incoming video의 source 크기입니다.

동시 capture와 overlay에서 image 크기와 window 크기를 서로 다르게 설정할 수 없는 하드웨어도 있습니다. 이때 역시 첫 요청이 우선하고 나중의 `VIDIOC_S_FMT`는 `EBUSY`로 실패하거나 조정된 값을 반환할 수 있습니다.

Overlay window 협상
Crop rectangle을 기본값 또는 원하는 source 영역으로 설정type = V4L2_BUF_TYPE_VIDEO_OVERLAY 지정VIDIOC_G_FMT로 현재 fmt.win 조회VIDIOC_TRY_FMT로 후보 window 시험VIDIOC_S_FMT로 조정된 window 확정Window와 crop 크기로 scaling 비율 확인

조회, 시험, 적용 순서로 window를 안전하게 협상합니다.

Window 관련 ioctl
항목설명
VIDIOC_G_FMT현재 `fmt.win`을 읽으며 예전 clips/bitmap은 반환하지 않음
VIDIOC_TRY_FMT상태 변경 없이 하드웨어 제약과 조정 결과 확인
VIDIOC_S_FMTWindow를 적용하고 실제 조정 값을 반환
EBUSY동시 stream의 선행 크기 설정과 양립하지 않을 때 가능

각 ioctl이 상태에 미치는 영향을 구분합니다.

Overlay Window
==============

The overlaid image is determined by cropping and overlay window
parameters. The former select an area of the video picture to capture,
the latter how images are overlaid and clipped. Cropping initialization
at minimum requires to reset the parameters to defaults. An example is
given in :ref:`crop`.

The overlay window is described by a struct
:c:type:`v4l2_window`. It defines the size of the image,
its position over the graphics surface and the clipping to be applied.
To get the current parameters applications set the ``type`` field of a
struct :c:type:`v4l2_format` to
``V4L2_BUF_TYPE_VIDEO_OVERLAY`` and call the
:ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` ioctl. The driver fills the
struct :c:type:`v4l2_window` substructure named ``win``. It is not
possible to retrieve a previously programmed clipping list or bitmap.

To program the overlay window applications set the ``type`` field of a
struct :c:type:`v4l2_format` to
``V4L2_BUF_TYPE_VIDEO_OVERLAY``, initialize the ``win`` substructure and
call the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl. The driver
adjusts the parameters against hardware limits and returns the actual
parameters as :ref:`VIDIOC_G_FMT <VIDIOC_G_FMT>` does. Like :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`, the
:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` ioctl can be used to learn
about driver capabilities without actually changing driver state. Unlike
:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` this also works after the overlay has been enabled.

The scaling factor of the overlaid image is implied by the width and
height given in struct :c:type:`v4l2_window` and the size
of the cropping rectangle. For more information see :ref:`crop`.

When simultaneous capturing and overlay is supported and the hardware
prohibits different image and window sizes, the size requested first
takes precedence. The attempt to capture or overlay as well
(:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`) may fail with an ``EBUSY`` error
code or return accordingly modified parameters.

v4l2_window의 위치, field, chromakey

159-189

`struct v4l2_window.w`는 framebuffer 왼쪽 위를 기준으로 한 `struct v4l2_rect`입니다. x와 y는 음수일 수 있고 width와 height 때문에 오른쪽이나 아래쪽 경계를 넘어갈 수도 있으며, window 전체가 framebuffer 밖에 놓일 수도 있습니다. 드라이버는 가능한 부분을 clip하거나 지원 가능한 값으로 조정합니다.

`field`는 `V4L2_FIELD_ANY`, `V4L2_FIELD_TOP`, `V4L2_FIELD_BOTTOM`, `V4L2_FIELD_INTERLACED` 중 하나입니다. 애플리케이션이 `V4L2_FIELD_ANY`를 요청하면 드라이버가 실제 field order를 선택해 반환할 수 있습니다.

`chromakey`는 `VIDIOC_S_FBUF`로 협상한 framebuffer pixel format의 값이며 host byte order를 따릅니다. BGR24에서 같은 RGB 성분은 little-endian host에서는 `0xRRGGBB`, big-endian host에서는 `0xBBGGRR`로 표현됩니다.

v4l2_window 핵심 필드
항목설명
wFramebuffer 좌표계의 struct v4l2_rect
fieldANY, TOP, BOTTOM 또는 INTERLACED
chromakeyFramebuffer pixel format과 host byte order를 따르는 key 값
global_alpha전체 window에 적용하는 alpha 값

Window의 geometry와 영상 해석을 구성합니다.

BGR24 chromakey byte order
Host byte orderchromakey 표현
Little-endian0xRRGGBB
Big-endian0xBBGGRR

논리적 RGB 성분이 host 정수에 배치되는 순서입니다.

Window 경계 처리
Framebuffer 왼쪽 위를 원점으로 w 지정음수 x/y 또는 경계 밖 width/height 허용Driver가 실제 framebuffer 경계로 clip필요하면 지원 가능한 rectangle로 조정해 반환

Window가 framebuffer를 벗어날 수 있음을 전제로 처리합니다.

.. c:type:: v4l2_window

struct v4l2_window
------------------

``struct v4l2_rect w``
    Size and position of the window relative to the top, left corner of
    the frame buffer defined with
    :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>`. The window can extend the
    frame buffer width and height, the ``x`` and ``y`` coordinates can
    be negative, and it can lie completely outside the frame buffer. The
    driver clips the window accordingly, or if that is not possible,
    modifies its size and/or position.

``enum v4l2_field field``
    Applications set this field to determine which video field shall be
    overlaid, typically one of ``V4L2_FIELD_ANY`` (0),
    ``V4L2_FIELD_TOP``, ``V4L2_FIELD_BOTTOM`` or
    ``V4L2_FIELD_INTERLACED``. Drivers may have to choose a different
    field order and return the actual setting here.

``__u32 chromakey``
    When chroma-keying has been negotiated with
    :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>` applications set this field
    to the desired pixel value for the chroma key. The format is the
    same as the pixel format of the framebuffer (struct
    :c:type:`v4l2_framebuffer` ``fmt.pixelformat``
    field), with bytes in host order. E. g. for
    :ref:`V4L2_PIX_FMT_BGR24 <V4L2-PIX-FMT-BGR32>` the value should
    be 0xRRGGBB on a little endian, 0xBBGGRR on a big endian host.

Clips, bitmap과 global alpha

190-258

`clips`와 `clipcount`로 clipping rectangle list를 넘기는 지원은 제거되었습니다. 과거에는 chroma key를 쓰지 않고 `VIDIOC_G_FBUF`가 기능을 알렸을 때 `clips`가 `struct v4l2_clip` 배열을 가리켰습니다. 각 rectangle은 window 왼쪽 위에 상대적이고 framebuffer 경계를 벗어나거나 서로 겹치면 안 되며, 가능한 경우 인접 rectangle을 합쳐야 했습니다. Banding이나 목록 순서에는 의미가 없었습니다.

지원되지 않는 장치에서는 `clips`와 `clipcount`가 무시되고 `VIDIOC_S_FMT` 뒤 내용도 정의되지 않습니다. 지원 장치에서 `clipcount`가 0이면 clipping하지 않는다는 뜻이었습니다. 애플리케이션은 예전 clipping list를 다시 읽을 수 없습니다.

`bitmap` 지원도 제거되었습니다. 과거에는 chroma key가 없고 framebuffer가 bitmap clipping을 지원할 때 window와 같은 크기의 bit mask를 전달했습니다. 좌표 `(x, y)`의 bit는 `((__u8 *) bitmap)[w.width * y + x / 8] & (1 << (x & 7))` 식으로 검사하며 범위는 `0 <= x < w.width`, `0 <= y < w.height`입니다.

지원하지 않는 장치는 bitmap을 무시하고 호출 뒤 내용을 정의하지 않습니다. 지원 장치에서 `bitmap == NULL`이면 clipping이 없습니다. Clipping list와 bitmap을 동시에 넘기거나 chroma key와 함께 넘기는 동작은 정의되지 않으며, 하드웨어 한계를 넘는 목록이나 mask를 제공한 결과도 정의되지 않습니다.

`global_alpha`는 `V4L2_FBUF_FLAG_GLOBAL_ALPHA`가 설정된 경우 framebuffer와 video를 혼합하는 전체 alpha 값입니다. 이 필드는 Linux 2.6.23에 추가되었지만 부모 `struct v4l2_format`의 padding 덕분에 기존 `VIDIOC_G_FMT`, `VIDIOC_S_FMT`, `VIDIOC_TRY_FMT` 호출의 binary layout에는 영향을 주지 않았습니다.

Clipping list 규칙
항목설명
clipsstruct v4l2_clip 배열을 가리키던 pointer, 현재 지원 제거
clipcount배열 원소 수, 0이면 clipping 없음
좌표Window 왼쪽 위 기준이며 framebuffer 안에 있어야 함
겹침Rectangle끼리 겹치면 안 되고 인접 항목은 가능한 한 병합
순서Banding과 배열 순서에 의미 없음
조회S_FMT에 넘긴 과거 목록을 G_FMT로 회수할 수 없음

제거된 인터페이스의 유효성 조건과 호환 의미입니다.

Bitmap clipping 계산
항목설명
Byte indexw.width * y + x / 8
Bit mask1 << (x & 7)
전체 검사식((__u8 *) bitmap)[w.width * y + x / 8] & (1 << (x & 7))
x 범위0 <= x < w.width
y 범위0 <= y < w.height
NULL지원 장치에서 clipping 없음

한 좌표에 대응하는 byte와 bit를 찾습니다.

Clipping 방식 선택
VIDIOC_G_FBUF로 지원 clipping/blending 기능 확인Chroma key, clips, bitmap 중 하나만 선택Clips는 경계와 비중첩 조건 검사Bitmap은 window 크기와 좌표 계산 검사Global alpha는 V4L2_FBUF_FLAG_GLOBAL_ALPHA 확인VIDIOC_S_FMT 뒤 driver가 반환한 window를 다시 확인

서로 배타적인 방식과 지원 flag를 먼저 확인합니다.

정의되지 않은 조합
항목설명
clips + bitmap두 clipping 표현을 동시에 전달
chromakey + clips/bitmap색상 key와 별도 clipping 표현을 함께 전달
하드웨어 한계 초과지원 개수나 mask 제약을 넘는 입력
지원 제거 필드의 반환값S_FMT 뒤 clips, clipcount, bitmap 내용

다음 입력은 portable한 결과를 기대할 수 없습니다.

``struct v4l2_clip * clips``
    *Note: support for this has been removed.*
    When chroma-keying has *not* been negotiated and
    :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>` indicated this capability,
    applications can set this field to point to an array of clipping
    rectangles.

    Like the window coordinates w, clipping rectangles are defined
    relative to the top, left corner of the frame buffer. However
    clipping rectangles must not extend the frame buffer width and
    height, and they must not overlap. If possible applications
    should merge adjacent rectangles. Whether this must create
    x-y or y-x bands, or the order of rectangles, is not defined. When
    clip lists are not supported the driver ignores this field. Its
    contents after calling :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
    are undefined.

``__u32 clipcount``
    *Note: support for this has been removed.*
    When the application set the ``clips`` field, this field must
    contain the number of clipping rectangles in the list. When clip
    lists are not supported the driver ignores this field, its contents
    after calling :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` are undefined. When clip lists are
    supported but no clipping is desired this field must be set to zero.

``void * bitmap``
    *Note: support for this has been removed.*
    When chroma-keying has *not* been negotiated and
    :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>` indicated this capability,
    applications can set this field to point to a clipping bit mask.

It must be of the same size as the window, ``w.width`` and ``w.height``.
Each bit corresponds to a pixel in the overlaid image, which is
displayed only when the bit is *set*. Pixel coordinates translate to
bits like:


.. code-block:: c

    ((__u8 *) bitmap)[w.width * y + x / 8] & (1 << (x & 7))

where ``0`` ≤ x < ``w.width`` and ``0`` ≤ y <``w.height``. [#f2]_

When a clipping bit mask is not supported the driver ignores this field,
its contents after calling :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` are
undefined. When a bit mask is supported but no clipping is desired this
field must be set to ``NULL``.

Applications need not create a clip list or bit mask. When they pass
both, or despite negotiating chroma-keying, the results are undefined.
Regardless of the chosen method, the clipping abilities of the hardware
may be limited in quantity or quality. The results when these limits are
exceeded are undefined. [#f3]_

``__u8 global_alpha``
    The global alpha value used to blend the framebuffer with video
    images, if global alpha blending has been negotiated
    (``V4L2_FBUF_FLAG_GLOBAL_ALPHA``, see
    :ref:`VIDIOC_S_FBUF <VIDIOC_G_FBUF>`,
    :ref:`framebuffer-flags`).

.. note::

   This field was added in Linux 2.6.23, extending the
   structure. However the :ref:`VIDIOC_[G|S|TRY]_FMT <VIDIOC_G_FMT>`
   ioctls, which take a pointer to a :c:type:`v4l2_format`
   parent structure with padding bytes at the end, are not affected.

v4l2_clip과 v4l2_rect

259-294

`struct v4l2_clip.c`는 window 왼쪽 위를 기준으로 한 clipping rectangle입니다. 목록에 들어 있는 모든 clipping rectangle의 바깥쪽 pixel만 화면에 표시됩니다. 즉 rectangle은 표시 영역이 아니라 가릴 영역을 뜻합니다.

`struct v4l2_clip.next`는 다음 원소를 가리키고 마지막 원소에서 `NULL`인 pointer로 정의되어 있지만 드라이버는 이 값을 무시합니다. 따라서 linked list를 넘길 수 없고, 실제 ABI는 `clipcount`로 길이를 지정한 연속 배열을 전제로 했습니다.

`struct v4l2_rect`의 `left`와 `top`은 왼쪽 위 꼭짓점의 수평·수직 offset입니다. Offset은 오른쪽과 아래쪽으로 증가하며 `width`와 `height`는 pixel 단위입니다.

struct v4l2_clip 필드
항목설명
cWindow 왼쪽 위 기준의 struct v4l2_rect
next드라이버가 무시하므로 linked list 전달에 사용할 수 없음
표시 의미모든 clipping rectangle 바깥의 pixel만 표시

제거된 clipping list 원소의 구조입니다.

struct v4l2_rect 필드
항목설명
left왼쪽 위 점의 수평 offset, 오른쪽으로 증가
top왼쪽 위 점의 수직 offset, 아래쪽으로 증가
widthPixel 단위 너비
heightPixel 단위 높이

사각형의 원점과 크기를 pixel 좌표로 표현합니다.

Clip 배열 해석
clips가 첫 struct v4l2_clip 원소를 가리킴clipcount가 유효 원소 수 지정각 c를 window 상대 좌표로 해석각 next 값은 driver가 무시모든 rectangle 바깥만 표시

Pointer chain이 아니라 연속 배열과 개수를 사용하던 형식입니다.

.. c:type:: v4l2_clip

struct v4l2_clip [#f4]_
-----------------------

``struct v4l2_rect c``
    Coordinates of the clipping rectangle, relative to the top, left
    corner of the frame buffer. Only window pixels *outside* all
    clipping rectangles are displayed.

``struct v4l2_clip * next``
    Pointer to the next clipping rectangle, ``NULL`` when this is the last
    rectangle. Drivers ignore this field, it cannot be used to pass a
    linked list of clipping rectangles.


.. c:type:: v4l2_rect

struct v4l2_rect
----------------

``__s32 left``
    Horizontal offset of the top, left corner of the rectangle, in
    pixels.

``__s32 top``
    Vertical offset of the top, left corner of the rectangle, in pixels.
    Offsets increase to the right and down.

``__u32 width``
    Width of the rectangle, in pixels.

``__u32 height``
    Height of the rectangle, in pixels.

Overlay 시작·중지와 설계 주석

295-326

설정이 끝나면 `VIDIOC_OVERLAY` ioctl로 overlay를 시작하거나 중지합니다. Format과 window 협상을 마친 뒤 표시 상태만 전환하는 단계입니다.

API 설계자는 동시 capture와 overlay에 두 file descriptor 방식을 반드시 지원하고 한 descriptor 방식은 선택 사항으로 두었습니다. 하나의 descriptor에서 두 stream의 상태와 명령을 섞으면 인터페이스가 복잡해지므로, descriptor 하나를 logical stream 하나에 대응시키는 모델이 기본입니다.

원문의 주석은 bitmap에서 `w.width`가 8의 배수여야 하는지 질문을 남깁니다. 명세가 확정하지 않은 부분이므로 애플리케이션은 임의로 가정하지 말고 드라이버가 반환한 제약과 실제 format을 따라야 합니다.

Framebuffer에 직접 쓰는 장치에서는 under-clipping이 특히 바람직하지 않습니다. 애플리케이션이나 그래픽 시스템이 손상된 영역을 다시 그려야 한다는 사실을 알지 못하기 때문입니다. 정확한 경계를 지원할 수 없다면 드라이버는 더 넓게 clip하거나 아예 쓰지 않는 쪽을 선택해야 합니다.

X11 region의 rectangle은 `BoxRec`의 `x1`, `y1`, `x2`, `y2`로 표현되고 width는 `x2 - x1`, height는 `y2 - y1`입니다. V4L2 clipping rectangle과 표현 및 의미가 다르므로 X11 clip list를 그대로 전달할 수 없습니다.

Overlay 실행 순서
Capability와 input/standard 확인Crop과 framebuffer 조건 확인VIDIOC_S_FMT로 overlay window 확정Clipping 또는 blending 방식 확정VIDIOC_OVERLAY로 시작필요할 때 VIDIOC_OVERLAY로 중지

구성 완료 후 VIDIOC_OVERLAY로 표시 상태를 전환합니다.

설계 주석과 구현 지침
항목설명
두 descriptor동시 기능을 지원하는 드라이버의 필수 모델
한 descriptor구형 호환을 위한 선택 모델
Bitmap width8의 배수 요구 여부가 명세에서 확정되지 않음
Under-clipping화면 손상을 알릴 수 없어 피해야 함
안전한 대안더 많이 clip하거나 framebuffer에 쓰지 않음
X11 BoxRecx2/y2 끝 좌표 표현이므로 V4L2 목록으로 직접 전달 불가

문서의 각주가 강조하는 호환성과 안전 원칙입니다.

Enabling Overlay
================

To start or stop the frame buffer overlay applications call the
:ref:`VIDIOC_OVERLAY` ioctl.

.. [#f1]
   In the opinion of the designers of this API, no driver writer taking
   the efforts to support simultaneous capturing and overlay will
   restrict this ability by requiring a single file descriptor, as in
   V4L and earlier versions of V4L2. Making this optional means
   applications depending on two file descriptors need backup routines
   to be compatible with all drivers, which is considerable more work
   than using two fds in applications which do not. Also two fd's fit
   the general concept of one file descriptor for each logical stream.
   Hence as a complexity trade-off drivers *must* support two file
   descriptors and *may* support single fd operation.

.. [#f2]
   Should we require ``w.width`` to be a multiple of eight?

.. [#f3]
   When the image is written into frame buffer memory it will be
   undesirable if the driver clips out less pixels than expected,
   because the application and graphics system are not aware these
   regions need to be refreshed. The driver should clip out more pixels
   or not write the image at all.

.. [#f4]
   The X Window system defines "regions" which are vectors of ``struct
   BoxRec { short x1, y1, x2, y2; }`` with ``width = x2 - x1`` and
   ``height = y2 - y1``, so one cannot pass X11 clip lists directly.