← Documents Documentation/userspace-api/media/v4l/vidioc-g-audio.rst GitHub 원문 ↗

Linux 6.18.37 · 사용자 공간 API

VIDIOC_G_AUDIO·VIDIOC_S_AUDIO ioctl

현재 V4L2 audio input과 capability·mode를 조회하거나 선택하고, stereo·AVL 플래그와 write-only 선택 동작을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

vidioc-g-audio.rst:1-124

현재 V4L2 audio input과 capability·mode를 조회하거나 선택하고, stereo·AVL 플래그와 write-only 선택 동작을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_G_AUDIO:
5
6 ************************************
7 ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO
8 ************************************
9
10 Name
11 ====
12
13 VIDIOC_G_AUDIO - VIDIOC_S_AUDIO - Query or select the current audio input and its attributes
14
15 Synopsis
16 ========
17
18 .. c:macro:: VIDIOC_G_AUDIO
19
20 ``int ioctl(int fd, VIDIOC_G_AUDIO, struct v4l2_audio *argp)``
21
22 .. c:macro:: VIDIOC_S_AUDIO
23
24 ``int ioctl(int fd, VIDIOC_S_AUDIO, const struct v4l2_audio *argp)``
25
26 Arguments
27 =========
28
29 ``fd``
30 File descriptor returned by :c:func:`open()`.
31
32 ``argp``
33 Pointer to struct :c:type:`v4l2_audio`.
34
35 Description
36 ===========
37
38 To query the current audio input applications zero out the ``reserved``
39 array of a struct :c:type:`v4l2_audio` and call the
40 :ref:`VIDIOC_G_AUDIO <VIDIOC_G_AUDIO>` ioctl with a pointer to this structure. Drivers fill
41 the rest of the structure or return an ``EINVAL`` error code when the device
42 has no audio inputs, or none which combine with the current video input.
43
44 Audio inputs have one writable property, the audio mode. To select the
45 current audio input *and* change the audio mode, applications initialize
46 the ``index`` and ``mode`` fields, and the ``reserved`` array of a
47 struct :c:type:`v4l2_audio` structure and call the :ref:`VIDIOC_S_AUDIO <VIDIOC_G_AUDIO>`
48 ioctl. Drivers may switch to a different audio mode if the request
49 cannot be satisfied. However, this is a write-only ioctl, it does not
50 return the actual new audio mode.
51
52 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
53
54 .. c:type:: v4l2_audio
55
56 .. flat-table:: struct v4l2_audio
57 :header-rows: 0
58 :stub-columns: 0
59 :widths: 1 1 2
60
61 * - __u32
62 - ``index``
63 - Identifies the audio input, set by the driver or application.
64 * - __u8
65 - ``name``\ [32]
66 - Name of the audio input, a NUL-terminated ASCII string, for
67 example: "Line In". This information is intended for the user,
68 preferably the connector label on the device itself.
69 * - __u32
70 - ``capability``
71 - Audio capability flags, see :ref:`audio-capability`.
72 * - __u32
73 - ``mode``
74 - Audio mode flags set by drivers and applications (on
75 :ref:`VIDIOC_S_AUDIO <VIDIOC_G_AUDIO>` ioctl), see :ref:`audio-mode`.
76 * - __u32
77 - ``reserved``\ [2]
78 - Reserved for future extensions. Drivers and applications must set
79 the array to zero.
80
81
82 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
83
84 .. _audio-capability:
85
86 .. flat-table:: Audio Capability Flags
87 :header-rows: 0
88 :stub-columns: 0
89 :widths: 3 1 4
90
91 * - ``V4L2_AUDCAP_STEREO``
92 - 0x00001
93 - This is a stereo input. The flag is intended to automatically
94 disable stereo recording etc. when the signal is always monaural.
95 The API provides no means to detect if stereo is *received*,
96 unless the audio input belongs to a tuner.
97 * - ``V4L2_AUDCAP_AVL``
98 - 0x00002
99 - Automatic Volume Level mode is supported.
100
101
102 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
103
104 .. _audio-mode:
105
106 .. flat-table:: Audio Mode Flags
107 :header-rows: 0
108 :stub-columns: 0
109 :widths: 3 1 4
110
111 * - ``V4L2_AUDMODE_AVL``
112 - 0x00001
113 - AVL mode is on.
114
115 Return Value
116 ============
117
118 On success 0 is returned, on error -1 and the ``errno`` variable is set
119 appropriately. The generic error codes are described at the
120 :ref:`Generic Error Codes <gen-errors>` chapter.
121
122 EINVAL
123 No audio inputs combine with the current video input, or the number
124 of the selected audio input is out of bounds or it does not combine.
125

3. 한국어 전문 번역

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

목적, 호출 형식과 인자

1-34

`VIDIOC_G_AUDIO`는 현재 audio input과 속성을 조회하고, `VIDIOC_S_AUDIO`는 현재 audio input과 audio mode를 선택하는 ioctl입니다.

조회 형식은 `int ioctl(int fd, VIDIOC_G_AUDIO, struct v4l2_audio *argp)`, 선택 형식은 `int ioctl(int fd, VIDIOC_S_AUDIO, const struct v4l2_audio *argp)`입니다. `fd`는 `open()`이 반환한 장치 파일 디스크립터입니다.

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

.. _VIDIOC_G_AUDIO:

************************************
ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO
************************************

Name
====

VIDIOC_G_AUDIO - VIDIOC_S_AUDIO - Query or select the current audio input and its attributes

Synopsis
========

.. c:macro:: VIDIOC_G_AUDIO

``int ioctl(int fd, VIDIOC_G_AUDIO, struct v4l2_audio *argp)``

.. c:macro:: VIDIOC_S_AUDIO

``int ioctl(int fd, VIDIOC_S_AUDIO, const struct v4l2_audio *argp)``

Arguments
=========

``fd``
    File descriptor returned by :c:func:`open()`.

``argp``
    Pointer to struct :c:type:`v4l2_audio`.

현재 입력 조회와 선택

35-51

현재 audio input을 조회할 때 응용 프로그램은 `v4l2_audio.reserved` 배열을 0으로 만든 뒤 `VIDIOC_G_AUDIO`를 호출합니다. 드라이버가 `index`, `name`, `capability`, `mode`를 포함한 나머지 필드를 채웁니다.

장치에 audio input이 없거나 현재 video input과 조합할 수 있는 audio input이 없으면 조회는 `EINVAL`을 반환합니다.

audio input에서 응용 프로그램이 쓸 수 있는 속성은 audio mode 하나입니다. 입력을 선택하면서 mode도 바꾸려면 `index`, `mode`, `reserved`를 초기화해 `VIDIOC_S_AUDIO`를 호출합니다.

드라이버가 요청을 그대로 만족할 수 없으면 다른 audio mode로 전환할 수 있습니다. `VIDIOC_S_AUDIO`는 write-only이므로 실제로 적용된 새 mode를 구조체에 반환하지 않습니다.

적용 결과가 필요하면 선택 후 `VIDIOC_G_AUDIO`로 다시 조회해야 합니다.

Audio input 조회·선택
reserved=0G_AUDIO로 현재 입력·mode 조회새 index·mode 선택S_AUDIO 호출드라이버가 가능한 mode 적용필요하면 G_AUDIO로 결과 재조회

조회와 write-only 선택의 차이를 나타냅니다.

Description
===========

To query the current audio input applications zero out the ``reserved``
array of a struct :c:type:`v4l2_audio` and call the
:ref:`VIDIOC_G_AUDIO <VIDIOC_G_AUDIO>` ioctl with a pointer to this structure. Drivers fill
the rest of the structure or return an ``EINVAL`` error code when the device
has no audio inputs, or none which combine with the current video input.

Audio inputs have one writable property, the audio mode. To select the
current audio input *and* change the audio mode, applications initialize
the ``index`` and ``mode`` fields, and the ``reserved`` array of a
struct :c:type:`v4l2_audio` structure and call the :ref:`VIDIOC_S_AUDIO <VIDIOC_G_AUDIO>`
ioctl. Drivers may switch to a different audio mode if the request
cannot be satisfied. However, this is a write-only ioctl, it does not
return the actual new audio mode.

v4l2_audio 구조체

52-80
struct v4l2_audio
형식필드의미
`__u32``index`audio input 식별 순번. 드라이버 또는 응용 프로그램이 설정
`__u8[32]``name``Line In` 같은 NUL 종료 ASCII 입력 이름. 장치 커넥터 라벨이 바람직함
`__u32``capability`Audio Capability Flags의 지원 기능 비트
`__u32``mode`드라이버가 반환하고 `VIDIOC_S_AUDIO`에서 응용 프로그램이 요청하는 Audio Mode Flags
`__u32[2]``reserved`미래 확장용. 드라이버와 응용 프로그램 모두 0으로 설정

드라이버와 응용 프로그램이 주고받는 audio input 속성입니다.

`index`는 조회에서는 현재 입력을 드라이버가 알려 주는 출력값이고, 선택에서는 응용 프로그램이 원하는 입력을 지정하는 입력값입니다.

`name`은 사용자 표시용이므로 실제 장치에서 식별할 수 있는 커넥터 이름을 제공하는 것이 좋습니다.

`capability`는 지원 여부를, `mode`는 현재 또는 요청 상태를 나타냅니다. 두 필드의 의미를 혼동해서는 안 됩니다.

.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|

.. c:type:: v4l2_audio

.. flat-table:: struct v4l2_audio
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2

    * - __u32
      - ``index``
      - Identifies the audio input, set by the driver or application.
    * - __u8
      - ``name``\ [32]
      - Name of the audio input, a NUL-terminated ASCII string, for
	example: "Line In". This information is intended for the user,
	preferably the connector label on the device itself.
    * - __u32
      - ``capability``
      - Audio capability flags, see :ref:`audio-capability`.
    * - __u32
      - ``mode``
      - Audio mode flags set by drivers and applications (on
	:ref:`VIDIOC_S_AUDIO <VIDIOC_G_AUDIO>` ioctl), see :ref:`audio-mode`.
    * - __u32
      - ``reserved``\ [2]
      - Reserved for future extensions. Drivers and applications must set
	the array to zero.

Audio capability 플래그

81-100
Audio Capability Flags
상수의미
`V4L2_AUDCAP_STEREO``0x00001`항상 mono인 신호에서 stereo recording 등을 자동 비활성화할 수 있는 stereo 입력
`V4L2_AUDCAP_AVL``0x00002`Automatic Volume Level mode 지원

`v4l2_audio.capability`가 나타내는 지원 기능입니다.

`V4L2_AUDCAP_STEREO`는 입력 자체가 stereo를 지원한다는 뜻이지 현재 stereo 신호가 수신됐다는 뜻은 아닙니다. audio input이 tuner에 속한 경우를 제외하면 이 API에는 현재 stereo 수신을 감지하는 방법이 없습니다.


.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|

.. _audio-capability:

.. flat-table:: Audio Capability Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * - ``V4L2_AUDCAP_STEREO``
      - 0x00001
      - This is a stereo input. The flag is intended to automatically
	disable stereo recording etc. when the signal is always monaural.
	The API provides no means to detect if stereo is *received*,
	unless the audio input belongs to a tuner.
    * - ``V4L2_AUDCAP_AVL``
      - 0x00002
      - Automatic Volume Level mode is supported.

Audio mode 플래그

101-114
Audio Mode Flags
상수의미
`V4L2_AUDMODE_AVL``0x00001`Automatic Volume Level mode가 켜져 있음

`v4l2_audio.mode`에서 현재 또는 요청 mode를 나타냅니다.

AVL mode는 `V4L2_AUDCAP_AVL` capability가 있는 입력에서 의미가 있으며, 선택 결과는 필요하면 다시 조회해야 합니다.


.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|

.. _audio-mode:

.. flat-table:: Audio Mode Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * - ``V4L2_AUDMODE_AVL``
      - 0x00001
      - AVL mode is on.

반환값과 EINVAL

115-124

성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 설정하며, 공통 오류 코드는 Generic Error Codes 장을 따릅니다.

G_AUDIO·S_AUDIO 오류
errno조건
`EINVAL`현재 video input과 조합되는 audio input이 없거나 선택한 audio input 번호가 범위를 벗어나거나 현재 video input과 조합되지 않음

현재 video input과 결합 가능한 audio input 및 선택 순번을 검사합니다.

Return Value
============

On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.

EINVAL
    No audio inputs combine with the current video input, or the number
    of the selected audio input is out of bounds or it does not combine.