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

Linux 6.18.37 · Userspace API / Media / V4L

V4L2 입력/출력

read/write, streaming, DMABUF와 overlay 방식의 선택 및 전환 규칙을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

io.rst:1-49

파일 디스크립터마다 보통 하나의 I/O 방식만 사용하며, streaming은 VIDIOC_REQBUFS로 협상하고 overlay는 VIDIOC_S_FMT로 시작합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _io:
5
6 ############
7 Input/Output
8 ############
9 The V4L2 API defines several different methods to read from or write to
10 a device. All drivers exchanging data with applications must support at
11 least one of them.
12
13 The classic I/O method using the :c:func:`read()` and
14 :c:func:`write()` function is automatically selected after opening a
15 V4L2 device. When the driver does not support this method attempts to
16 read or write will fail at any time.
17
18 Other methods must be negotiated. To select the streaming I/O method
19 with memory mapped or user buffers applications call the
20 :ref:`VIDIOC_REQBUFS` ioctl.
21
22 Video overlay can be considered another I/O method, although the
23 application does not directly receive the image data. It is selected by
24 initiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
25 ioctl. For more information see :ref:`overlay`.
26
27 Generally exactly one I/O method, including overlay, is associated with
28 each file descriptor. The only exceptions are applications not
29 exchanging data with a driver ("panel applications", see :ref:`open`)
30 and drivers permitting simultaneous video capturing and overlay using
31 the same file descriptor, for compatibility with V4L and earlier
32 versions of V4L2.
33
34 :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some
35 degree, but for simplicity drivers need not support switching the I/O
36 method (after first switching away from read/write) other than by
37 closing and reopening the device.
38
39 The following sections describe the various I/O methods in more detail.
40
41 .. toctree::
42 :maxdepth: 1
43
44 rw
45 mmap
46 userp
47 dmabuf
48 buffer
49 field-order
50

3. 한국어 전문 번역

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

V4L2 I/O 방식과 선택

1-31

V4L2는 장치에서 읽거나 장치로 쓰는 여러 I/O 방식을 정의하며, 응용 프로그램과 데이터를 교환하는 모든 드라이버는 그중 적어도 하나를 지원해야 합니다.

I/O 방식
항목설명
`read()`/`write()`V4L2 장치를 연 뒤 자동으로 선택되는 고전적 방식입니다. 드라이버가 지원하지 않으면 어느 시점의 읽기나 쓰기든 실패할 수 있습니다.
Memory-mapped streaming`VIDIOC_REQBUFS`로 협상하며 드라이버가 할당한 버퍼를 응용 프로그램 주소 공간에 매핑합니다.
User-pointer streaming`VIDIOC_REQBUFS`로 협상하며 응용 프로그램이 마련한 버퍼를 큐에 제공합니다.
DMABUF streamingDMA buffer 공유를 통해 장치 사이 또는 장치와 응용 프로그램 사이에서 버퍼를 교환합니다.
Video overlay응용 프로그램이 영상 데이터를 직접 받지는 않지만 또 하나의 I/O 방식으로 볼 수 있습니다. `VIDIOC_S_FMT`로 오버레이를 시작해 선택합니다.

선택 시점과 데이터 소유 방식을 비교합니다.

일반적으로 파일 디스크립터 하나에는 overlay를 포함해 정확히 한 I/O 방식만 연결됩니다. 예외는 드라이버와 데이터를 교환하지 않는 panel application, 그리고 V4L 및 초기 V4L2 호환을 위해 같은 디스크립터에서 캡처와 오버레이를 동시에 허용하는 드라이버입니다.

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

.. _io:

############
Input/Output
############
The V4L2 API defines several different methods to read from or write to
a device. All drivers exchanging data with applications must support at
least one of them.

The classic I/O method using the :c:func:`read()` and
:c:func:`write()` function is automatically selected after opening a
V4L2 device. When the driver does not support this method attempts to
read or write will fail at any time.

Other methods must be negotiated. To select the streaming I/O method
with memory mapped or user buffers applications call the
:ref:`VIDIOC_REQBUFS` ioctl.

Video overlay can be considered another I/O method, although the
application does not directly receive the image data. It is selected by
initiating video overlay with the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>`
ioctl. For more information see :ref:`overlay`.

Generally exactly one I/O method, including overlay, is associated with
each file descriptor. The only exceptions are applications not
exchanging data with a driver ("panel applications", see :ref:`open`)
and drivers permitting simultaneous video capturing and overlay using
the same file descriptor, for compatibility with V4L and earlier

I/O 방식 전환 제약과 하위 문서

32-49

`VIDIOC_S_FMT`와 `VIDIOC_REQBUFS`를 이용하면 어느 정도 I/O 방식을 바꿀 수 있지만, 단순성을 위해 드라이버는 read/write에서 처음 다른 방식으로 전환한 뒤에는 추가 전환을 지원할 의무가 없습니다. 확실한 전환 방법은 장치를 닫고 다시 여는 것입니다.

I/O 방식 선택
V4L2 장치를 열어 기본 read/write 방식 선택필요하면 `VIDIOC_REQBUFS`로 streaming 방식 협상또는 `VIDIOC_S_FMT`로 video overlay 시작선택한 방식으로 버퍼 교환다른 방식이 필요하고 드라이버가 전환을 지원하지 않으면 close 후 reopen

파일 디스크립터별로 방식을 확정하는 흐름입니다.

이어지는 하위 문서는 read/write, mmap, user pointer, DMABUF, 공통 buffer 구조와 field order를 각각 자세히 설명합니다.

versions of V4L2.

:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` and :ref:`VIDIOC_REQBUFS` would permit this to some
degree, but for simplicity drivers need not support switching the I/O
method (after first switching away from read/write) other than by
closing and reopening the device.

The following sections describe the various I/O methods in more detail.

.. toctree::
    :maxdepth: 1

    rw
    mmap
    userp
    dmabuf
    buffer
    field-order