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

Linux 6.18.37 · 사용자 공간 API

비디오 입력과 출력

비디오·VBI 장치의 물리 입력과 출력, 열거·현재 선택 조회·선택 변경 ioctl 및 두 C 예제를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

video.rst:1-68

비디오·VBI 장치의 물리 입력과 출력, 열거·현재 선택 조회·선택 변경 ioctl 및 두 C 예제를 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _video:
4
5 ************************
6 Video Inputs and Outputs
7 ************************
8
9 Video inputs and outputs are physical connectors of a device. These can
10 be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
11 Video, S-Video and RGB connectors. Camera sensors are also considered to
12 be a video input. Video and VBI capture devices have inputs. Video and
13 VBI output devices have outputs, at least one each. Radio devices have
14 no video inputs or outputs.
15
16 To learn about the number and attributes of the available inputs and
17 outputs applications can enumerate them with the
18 :ref:`VIDIOC_ENUMINPUT` and
19 :ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
20 struct :c:type:`v4l2_input` returned by the
21 :ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
22 status information applicable when the current video input is queried.
23
24 The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
25 :ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
26 the current video input or output. To select a different input or output
27 applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
28 :ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
29 implement all the input ioctls when the device has one or more inputs,
30 all the output ioctls when the device has one or more outputs.
31
32 Example: Information about the current video input
33 ==================================================
34
35 .. code-block:: c
36
37 struct v4l2_input input;
38 int index;
39
40 if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) {
41 perror("VIDIOC_G_INPUT");
42 exit(EXIT_FAILURE);
43 }
44
45 memset(&input, 0, sizeof(input));
46 input.index = index;
47
48 if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) {
49 perror("VIDIOC_ENUMINPUT");
50 exit(EXIT_FAILURE);
51 }
52
53 printf("Current input: %s\\n", input.name);
54
55
56 Example: Switching to the first video input
57 ===========================================
58
59 .. code-block:: c
60
61 int index;
62
63 index = 0;
64
65 if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) {
66 perror("VIDIOC_S_INPUT");
67 exit(EXIT_FAILURE);
68 }
69

3. 한국어 전문 번역

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

물리 커넥터와 장치 유형

1-16

비디오 입력과 출력은 장치의 물리 커넥터입니다. RF 안테나·케이블, CVBS 또는 컴포지트 비디오, S-Video, RGB 커넥터가 대표적이며 카메라 센서도 비디오 입력으로 취급합니다.

비디오와 VBI 캡처 장치는 입력을 가지고, 비디오와 VBI 출력 장치는 출력을 가지며 각각 최소 하나가 존재합니다. 라디오 장치에는 비디오 입력이나 출력이 없습니다.

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

.. _video:

************************
Video Inputs and Outputs
************************

Video inputs and outputs are physical connectors of a device. These can
be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
Video, S-Video and RGB connectors. Camera sensors are also considered to
be a video input. Video and VBI capture devices have inputs. Video and
VBI output devices have outputs, at least one each. Radio devices have
no video inputs or outputs.

To learn about the number and attributes of the available inputs and

입출력 열거, 조회와 선택

17-31

응용 프로그램은 `VIDIOC_ENUMINPUT`과 `VIDIOC_ENUMOUTPUT` ioctl로 사용 가능한 입력·출력의 개수와 속성을 각각 열거합니다. 현재 입력을 조회할 때 `VIDIOC_ENUMINPUT`이 반환하는 `struct v4l2_input`에는 해당 입력에 적용되는 신호 상태 정보도 들어 있습니다.

`VIDIOC_G_INPUT`과 `VIDIOC_G_OUTPUT`은 현재 입력 또는 출력의 인덱스를 반환합니다. 다른 경로를 선택하려면 `VIDIOC_S_INPUT` 또는 `VIDIOC_S_OUTPUT`을 호출합니다. 장치에 입력이 하나 이상 있으면 드라이버는 모든 입력 ioctl을, 출력이 하나 이상 있으면 모든 출력 ioctl을 구현해야 합니다.

입출력 ioctl 대응
대상열거현재 조회선택
입력`VIDIOC_ENUMINPUT``VIDIOC_G_INPUT``VIDIOC_S_INPUT`
출력`VIDIOC_ENUMOUTPUT``VIDIOC_G_OUTPUT``VIDIOC_S_OUTPUT`

열거, 현재 선택 조회와 선택 변경을 구분합니다.

outputs applications can enumerate them with the
:ref:`VIDIOC_ENUMINPUT` and
:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
struct :c:type:`v4l2_input` returned by the
:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
status information applicable when the current video input is queried.

The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
the current video input or output. To select a different input or output
applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
implement all the input ioctls when the device has one or more inputs,
all the output ioctls when the device has one or more outputs.

현재 비디오 입력 정보 조회 예제

32-57

첫 번째 예제는 `VIDIOC_G_INPUT`으로 현재 입력 인덱스를 얻습니다. `struct v4l2_input`을 0으로 초기화하고 그 인덱스를 `input.index`에 넣은 뒤 `VIDIOC_ENUMINPUT`을 호출해 해당 입력의 전체 설명을 가져옵니다.

두 ioctl 중 하나라도 -1을 반환하면 `perror()`로 실패한 요청 이름을 출력하고 종료합니다. 성공하면 `input.name`을 사용해 현재 입력의 사람이 읽을 수 있는 이름을 출력합니다.

Example: Information about the current video input
==================================================

.. code-block:: c

    struct v4l2_input input;
    int index;

    if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) {
	perror("VIDIOC_G_INPUT");
	exit(EXIT_FAILURE);
    }

    memset(&input, 0, sizeof(input));
    input.index = index;

    if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) {
	perror("VIDIOC_ENUMINPUT");
	exit(EXIT_FAILURE);
    }

    printf("Current input: %s\\n", input.name);


Example: Switching to the first video input
===========================================

첫 번째 비디오 입력으로 전환하는 예제

58-68

두 번째 예제는 인덱스를 0으로 설정하고 `VIDIOC_S_INPUT`에 그 주소를 전달해 첫 번째 비디오 입력을 선택합니다. 호출이 -1이면 오류를 보고하고 종료합니다. 인덱스가 유효한지는 앞서 `VIDIOC_ENUMINPUT`으로 열거한 범위 안에서 확인해야 합니다.


.. code-block:: c

    int index;

    index = 0;

    if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) {
	perror("VIDIOC_S_INPUT");
	exit(EXIT_FAILURE);
    }