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

Linux 6.18.37 · 사용자 공간 API

VIDIOC_G_FREQUENCY·VIDIOC_S_FREQUENCY ioctl

V4L2 tuner·modulator의 무선 주파수를 조회·설정하고 capability별 62.5 kHz·62.5 Hz·1 Hz 단위를 해석하는 방법을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

vidioc-g-frequency.rst:1-103

tuner 또는 modulator의 주파수와 단위를 다루며 설정 뒤 실제 조정값은 별도 조회해야 합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_G_FREQUENCY:
5
6 ********************************************
7 ioctl VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY
8 ********************************************
9
10 Name
11 ====
12
13 VIDIOC_G_FREQUENCY - VIDIOC_S_FREQUENCY - Get or set tuner or modulator radio frequency
14
15 Synopsis
16 ========
17
18 .. c:macro:: VIDIOC_G_FREQUENCY
19
20 ``int ioctl(int fd, VIDIOC_G_FREQUENCY, struct v4l2_frequency *argp)``
21
22 .. c:macro:: VIDIOC_S_FREQUENCY
23
24 ``int ioctl(int fd, VIDIOC_S_FREQUENCY, const struct v4l2_frequency *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_frequency`.
34
35 Description
36 ===========
37
38 To get the current tuner or modulator radio frequency applications set
39 the ``tuner`` field of a struct
40 :c:type:`v4l2_frequency` to the respective tuner or
41 modulator number (only input devices have tuners, only output devices
42 have modulators), zero out the ``reserved`` array and call the
43 :ref:`VIDIOC_G_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl with a pointer to this structure. The
44 driver stores the current frequency in the ``frequency`` field.
45
46 To change the current tuner or modulator radio frequency applications
47 initialize the ``tuner``, ``type`` and ``frequency`` fields, and the
48 ``reserved`` array of a struct :c:type:`v4l2_frequency`
49 and call the :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl with a pointer to this
50 structure. When the requested frequency is not possible the driver
51 assumes the closest possible value. However :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` is a
52 write-only ioctl, it does not return the actual new frequency.
53
54 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
55
56 .. c:type:: v4l2_frequency
57
58 .. flat-table:: struct v4l2_frequency
59 :header-rows: 0
60 :stub-columns: 0
61 :widths: 1 1 2
62
63 * - __u32
64 - ``tuner``
65 - The tuner or modulator index number. This is the same value as in
66 the struct :c:type:`v4l2_input` ``tuner`` field and
67 the struct :c:type:`v4l2_tuner` ``index`` field, or
68 the struct :c:type:`v4l2_output` ``modulator`` field
69 and the struct :c:type:`v4l2_modulator` ``index``
70 field.
71 * - __u32
72 - ``type``
73 - The tuner type. This is the same value as in the struct
74 :c:type:`v4l2_tuner` ``type`` field. The type must be
75 set to ``V4L2_TUNER_RADIO`` for ``/dev/radioX`` device nodes, and
76 to ``V4L2_TUNER_ANALOG_TV`` for all others. Set this field to
77 ``V4L2_TUNER_RADIO`` for modulators (currently only radio
78 modulators are supported). See :c:type:`v4l2_tuner_type`
79 * - __u32
80 - ``frequency``
81 - Tuning frequency in units of 62.5 kHz, or if the struct
82 :c:type:`v4l2_tuner` or struct
83 :c:type:`v4l2_modulator` ``capability`` flag
84 ``V4L2_TUNER_CAP_LOW`` is set, in units of 62.5 Hz. A 1 Hz unit is
85 used when the ``capability`` flag ``V4L2_TUNER_CAP_1HZ`` is set.
86 * - __u32
87 - ``reserved``\ [8]
88 - Reserved for future extensions. Drivers and applications must set
89 the array to zero.
90
91 Return Value
92 ============
93
94 On success 0 is returned, on error -1 and the ``errno`` variable is set
95 appropriately. The generic error codes are described at the
96 :ref:`Generic Error Codes <gen-errors>` chapter.
97
98 EINVAL
99 The ``tuner`` index is out of bounds or the value in the ``type``
100 field is wrong.
101
102 EBUSY
103 A hardware seek is in progress.
104

3. 한국어 전문 번역

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

목적, 호출 형식과 인자

1-34

`VIDIOC_G_FREQUENCY`와 `VIDIOC_S_FREQUENCY`는 tuner 또는 modulator의 무선 주파수를 조회하거나 설정합니다. 입력 장치에는 tuner만 있고 출력 장치에는 modulator만 있습니다.

두 ioctl은 `struct v4l2_frequency`를 사용합니다. 조회는 수정 가능한 포인터를, 설정은 `const struct v4l2_frequency *argp`를 받으며 `fd`는 `open()`이 반환한 파일 디스크립터입니다.

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

.. _VIDIOC_G_FREQUENCY:

********************************************
ioctl VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY
********************************************

Name
====

VIDIOC_G_FREQUENCY - VIDIOC_S_FREQUENCY - Get or set tuner or modulator radio frequency

Synopsis
========

.. c:macro:: VIDIOC_G_FREQUENCY

``int ioctl(int fd, VIDIOC_G_FREQUENCY, struct v4l2_frequency *argp)``

.. c:macro:: VIDIOC_S_FREQUENCY

``int ioctl(int fd, VIDIOC_S_FREQUENCY, const struct v4l2_frequency *argp)``

Arguments
=========

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

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

현재 주파수 조회와 설정

35-53

현재 주파수를 읽으려면 `tuner`를 대상 tuner 또는 modulator 번호로 설정하고 `reserved` 배열을 0으로 만든 뒤 `VIDIOC_G_FREQUENCY`를 호출합니다. 드라이버가 현재 값을 `frequency`에 저장합니다.

주파수를 바꾸려면 `tuner`, `type`, `frequency`와 `reserved`를 초기화한 뒤 `VIDIOC_S_FREQUENCY`를 호출합니다. 요청값이 불가능하면 드라이버가 가장 가까운 가능한 주파수를 사용합니다.

S_FREQUENCY는 write-only ioctl이므로 실제로 선택된 새 주파수를 구조체에 돌려주지 않습니다. 조정된 값을 알아야 하면 설정 후 G_FREQUENCY로 다시 조회해야 합니다.

주파수 설정과 확인
tuner 또는 modulator index 확인type과 원하는 frequency 설정reserved[8]을 0으로 초기화VIDIOC_S_FREQUENCY 호출VIDIOC_G_FREQUENCY로 실제 주파수 재조회

설정 호출의 입력 구조체를 결과로 해석하지 않고 별도 조회합니다.

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

To get the current tuner or modulator radio frequency applications set
the ``tuner`` field of a struct
:c:type:`v4l2_frequency` to the respective tuner or
modulator number (only input devices have tuners, only output devices
have modulators), zero out the ``reserved`` array and call the
:ref:`VIDIOC_G_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl with a pointer to this structure. The
driver stores the current frequency in the ``frequency`` field.

To change the current tuner or modulator radio frequency applications
initialize the ``tuner``, ``type`` and ``frequency`` fields, and the
``reserved`` array of a struct :c:type:`v4l2_frequency`
and call the :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl with a pointer to this
structure. When the requested frequency is not possible the driver
assumes the closest possible value. However :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` is a
write-only ioctl, it does not return the actual new frequency.

struct v4l2_frequency

54-90
v4l2_frequency 필드
형식필드의미
`__u32``tuner`tuner 또는 modulator index. `v4l2_input.tuner`·`v4l2_tuner.index` 또는 `v4l2_output.modulator`·`v4l2_modulator.index`와 같은 값
`__u32``type`tuner type. `/dev/radioX`와 modulator는 `V4L2_TUNER_RADIO`, 다른 노드는 `V4L2_TUNER_ANALOG_TV`
`__u32``frequency`capability에 따라 62.5 kHz, 62.5 Hz 또는 1 Hz 단위의 조정 주파수
`__u32[8]``reserved[8]`미래 확장용. 드라이버와 애플리케이션 모두 0으로 설정

대상 index, tuner 종류와 capability별 단위를 전달합니다.

frequency 단위
capability1 단위의 크기
기본62.5 kHz
`V4L2_TUNER_CAP_LOW`62.5 Hz
`V4L2_TUNER_CAP_1HZ`1 Hz

tuner 또는 modulator capability flag가 단위를 선택합니다.

현재 지원되는 modulator는 radio modulator뿐이므로 modulator의 `type`은 `V4L2_TUNER_RADIO`입니다. 단위는 `v4l2_tuner` 또는 `v4l2_modulator.capability`를 먼저 확인해 해석해야 합니다.

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

.. c:type:: v4l2_frequency

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

    * - __u32
      - ``tuner``
      - The tuner or modulator index number. This is the same value as in
	the struct :c:type:`v4l2_input` ``tuner`` field and
	the struct :c:type:`v4l2_tuner` ``index`` field, or
	the struct :c:type:`v4l2_output` ``modulator`` field
	and the struct :c:type:`v4l2_modulator` ``index``
	field.
    * - __u32
      - ``type``
      - The tuner type. This is the same value as in the struct
	:c:type:`v4l2_tuner` ``type`` field. The type must be
	set to ``V4L2_TUNER_RADIO`` for ``/dev/radioX`` device nodes, and
	to ``V4L2_TUNER_ANALOG_TV`` for all others. Set this field to
	``V4L2_TUNER_RADIO`` for modulators (currently only radio
	modulators are supported). See :c:type:`v4l2_tuner_type`
    * - __u32
      - ``frequency``
      - Tuning frequency in units of 62.5 kHz, or if the struct
	:c:type:`v4l2_tuner` or struct
	:c:type:`v4l2_modulator` ``capability`` flag
	``V4L2_TUNER_CAP_LOW`` is set, in units of 62.5 Hz. A 1 Hz unit is
	used when the ``capability`` flag ``V4L2_TUNER_CAP_1HZ`` is set.
    * - __u32
      - ``reserved``\ [8]
      - Reserved for future extensions. Drivers and applications must set
	the array to zero.

반환값과 오류

91-103

성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 설정하며 Generic Error Codes 장의 공통 오류도 적용됩니다.

frequency 오류
errno조건
`EINVAL``tuner` index가 범위를 벗어나거나 `type` 값이 잘못됨
`EBUSY`하드웨어 seek가 진행 중

index·type과 하드웨어 seek 상태에 따른 오류입니다.

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
    The ``tuner`` index is out of bounds or the value in the ``type``
    field is wrong.

EBUSY
    A hardware seek is in progress.