1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/userspace-api/media/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
12 ************************************
13 ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER
14 ************************************
19 VIDIOC_G_TUNER - VIDIOC_S_TUNER - Get or set tuner attributes
25 .. c:function:: int ioctl( int fd, VIDIOC_G_TUNER, struct v4l2_tuner *argp )
28 .. c:function:: int ioctl( int fd, VIDIOC_S_TUNER, const struct v4l2_tuner *argp )
36 File descriptor returned by :ref:`open() <func-open>`.
39 Pointer to struct :c:type:`v4l2_tuner`.
45 To query the attributes of a tuner applications initialize the ``index``
46 field and zero out the ``reserved`` array of a struct
47 :c:type:`v4l2_tuner` and call the ``VIDIOC_G_TUNER`` ioctl
48 with a pointer to this structure. Drivers fill the rest of the structure
49 or return an ``EINVAL`` error code when the index is out of bounds. To
50 enumerate all tuners applications shall begin at index zero,
51 incrementing by one until the driver returns ``EINVAL``.
53 Tuners have two writable properties, the audio mode and the radio
54 frequency. To change the audio mode, applications initialize the
55 ``index``, ``audmode`` and ``reserved`` fields and call the
56 ``VIDIOC_S_TUNER`` ioctl. This will *not* change the current tuner,
57 which is determined by the current video input. Drivers may choose a
58 different audio mode if the requested mode is invalid or unsupported.
59 Since this is a write-only ioctl, it does not return the actually
62 :ref:`SDR <sdr>` specific tuner types are ``V4L2_TUNER_SDR`` and
63 ``V4L2_TUNER_RF``. For SDR devices ``audmode`` field must be initialized
64 to zero. The term 'tuner' means SDR receiver in this context.
66 To change the radio frequency the
67 :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
70 .. tabularcolumns:: |p{1.3cm}|p{3.0cm}|p{6.6cm}|p{6.6cm}|
72 .. c:type:: v4l2_tuner
74 .. cssclass:: longtable
76 .. flat-table:: struct v4l2_tuner
82 - :cspan:`1` Identifies the tuner, set by the application.
87 Name of the tuner, a NUL-terminated ASCII string.
89 This information is intended for the user.
92 - :cspan:`1` Type of the tuner, see :c:type:`v4l2_tuner_type`.
97 Tuner capability flags, see :ref:`tuner-capability`. Audio flags
98 indicate the ability to decode audio subprograms. They will *not*
99 change, for example with the current video standard.
101 When the structure refers to a radio tuner the
102 ``V4L2_TUNER_CAP_LANG1``, ``V4L2_TUNER_CAP_LANG2`` and
103 ``V4L2_TUNER_CAP_NORM`` flags can't be used.
105 If multiple frequency bands are supported, then ``capability`` is
106 the union of all ``capability`` fields of each struct
107 :c:type:`v4l2_frequency_band`.
110 - :cspan:`1` The lowest tunable frequency in units of 62.5 kHz, or
111 if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units
112 of 62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ``
113 is set, in units of 1 Hz. If multiple frequency bands are
114 supported, then ``rangelow`` is the lowest frequency of all the
118 - :cspan:`1` The highest tunable frequency in units of 62.5 kHz,
119 or if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in
120 units of 62.5 Hz, or if the ``capability`` flag
121 ``V4L2_TUNER_CAP_1HZ`` is set, in units of 1 Hz. If multiple
122 frequency bands are supported, then ``rangehigh`` is the highest
123 frequency of all the frequency bands.
128 Some tuners or audio decoders can determine the received audio
129 subprograms by analyzing audio carriers, pilot tones or other
130 indicators. To pass this information drivers set flags defined in
131 :ref:`tuner-rxsubchans` in this field. For example:
134 - ``V4L2_TUNER_SUB_MONO``
135 - receiving mono audio
139 - receiving stereo audio and a secondary audio program
143 - receiving mono or stereo audio, the hardware cannot distinguish
147 - receiving bilingual audio
150 - ``MONO | STEREO | LANG1 | LANG2``
151 - receiving mono, stereo or bilingual audio
156 When the ``V4L2_TUNER_CAP_STEREO``, ``_LANG1``, ``_LANG2`` or
157 ``_SAP`` flag is cleared in the ``capability`` field, the
158 corresponding ``V4L2_TUNER_SUB_`` flag must not be set here.
160 This field is valid only if this is the tuner of the current video
161 input, or when the structure refers to a radio tuner.
166 The selected audio mode, see :ref:`tuner-audmode` for valid
167 values. The audio mode does not affect audio subprogram detection,
168 and like a :ref:`control` it does not automatically
169 change unless the requested mode is invalid or unsupported. See
170 :ref:`tuner-matrix` for possible results when the selected and
171 received audio programs do not match.
173 Currently this is the only field of struct
174 struct :c:type:`v4l2_tuner` applications can change.
177 - :cspan:`1` The signal strength if known.
179 Ranging from 0 to 65535. Higher values indicate a better signal.
182 - :cspan:`1` Automatic frequency control.
184 When the ``afc`` value is negative, the frequency is too
185 low, when positive too high.
188 - :cspan:`1` Reserved for future extensions.
190 Drivers and applications must set the array to zero.
194 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
196 .. c:type:: v4l2_tuner_type
198 .. flat-table:: enum v4l2_tuner_type
203 * - ``V4L2_TUNER_RADIO``
205 - Tuner supports radio
206 * - ``V4L2_TUNER_ANALOG_TV``
208 - Tuner supports analog TV
209 * - ``V4L2_TUNER_SDR``
211 - Tuner controls the A/D and/or D/A block of a
212 Software Digital Radio (SDR)
213 * - ``V4L2_TUNER_RF``
215 - Tuner controls the RF part of a Software Digital Radio (SDR)
218 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
220 .. _tuner-capability:
222 .. cssclass:: longtable
224 .. flat-table:: Tuner and Modulator Capability Flags
229 * - ``V4L2_TUNER_CAP_LOW``
231 - When set, tuning frequencies are expressed in units of 62.5 Hz
233 * - ``V4L2_TUNER_CAP_NORM``
235 - This is a multi-standard tuner; the video standard can or must be
236 switched. (B/G PAL tuners for example are typically not considered
237 multi-standard because the video standard is automatically
238 determined from the frequency band.) The set of supported video
239 standards is available from the struct
240 :c:type:`v4l2_input` pointing to this tuner, see the
241 description of ioctl :ref:`VIDIOC_ENUMINPUT`
242 for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
244 * - ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
246 - If set, then this tuner supports the hardware seek functionality
247 where the seek stops when it reaches the end of the frequency
249 * - ``V4L2_TUNER_CAP_HWSEEK_WRAP``
251 - If set, then this tuner supports the hardware seek functionality
252 where the seek wraps around when it reaches the end of the
254 * - ``V4L2_TUNER_CAP_STEREO``
256 - Stereo audio reception is supported.
257 * - ``V4L2_TUNER_CAP_LANG1``
259 - Reception of the primary language of a bilingual audio program is
260 supported. Bilingual audio is a feature of two-channel systems,
261 transmitting the primary language monaural on the main audio
262 carrier and a secondary language monaural on a second carrier.
263 Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
264 * - ``V4L2_TUNER_CAP_LANG2``
266 - Reception of the secondary language of a bilingual audio program
267 is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
269 * - ``V4L2_TUNER_CAP_SAP``
271 - Reception of a secondary audio program is supported. This is a
272 feature of the BTSC system which accompanies the NTSC video
273 standard. Two audio carriers are available for mono or stereo
274 transmissions of a primary language, and an independent third
275 carrier for a monaural secondary language. Only
276 ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
280 The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
281 flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
282 supports the ``V4L2_STD_NTSC_M`` video standard.
283 * - ``V4L2_TUNER_CAP_RDS``
285 - RDS capture is supported. This capability is only valid for radio
287 * - ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
289 - The RDS data is passed as unparsed RDS blocks.
290 * - ``V4L2_TUNER_CAP_RDS_CONTROLS``
292 - The RDS data is parsed by the hardware and set via controls.
293 * - ``V4L2_TUNER_CAP_FREQ_BANDS``
295 - The :ref:`VIDIOC_ENUM_FREQ_BANDS`
296 ioctl can be used to enumerate the available frequency bands.
297 * - ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
299 - The range to search when using the hardware seek functionality is
301 :ref:`VIDIOC_S_HW_FREQ_SEEK` for
303 * - ``V4L2_TUNER_CAP_1HZ``
305 - When set, tuning frequencies are expressed in units of 1 Hz
310 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
312 .. _tuner-rxsubchans:
314 .. flat-table:: Tuner Audio Reception Flags
319 * - ``V4L2_TUNER_SUB_MONO``
321 - The tuner receives a mono audio signal.
322 * - ``V4L2_TUNER_SUB_STEREO``
324 - The tuner receives a stereo audio signal.
325 * - ``V4L2_TUNER_SUB_LANG1``
327 - The tuner receives the primary language of a bilingual audio
328 signal. Drivers must clear this flag when the current video
329 standard is ``V4L2_STD_NTSC_M``.
330 * - ``V4L2_TUNER_SUB_LANG2``
332 - The tuner receives the secondary language of a bilingual audio
333 signal (or a second audio program).
334 * - ``V4L2_TUNER_SUB_SAP``
336 - The tuner receives a Second Audio Program.
340 The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
341 flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
342 when the current video standard is ``V4L2_STD_NTSC_M``.
343 * - ``V4L2_TUNER_SUB_RDS``
345 - The tuner receives an RDS channel.
349 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
353 .. flat-table:: Tuner Audio Modes
358 * - ``V4L2_TUNER_MODE_MONO``
360 - Play mono audio. When the tuner receives a stereo signal this a
361 down-mix of the left and right channel. When the tuner receives a
362 bilingual or SAP signal this mode selects the primary language.
363 * - ``V4L2_TUNER_MODE_STEREO``
365 - Play stereo audio. When the tuner receives bilingual audio it may
366 play different languages on the left and right channel or the
367 primary language is played on both channels.
369 Playing different languages in this mode is deprecated. New
370 drivers should do this only in ``MODE_LANG1_LANG2``.
372 When the tuner receives no stereo signal or does not support
373 stereo reception the driver shall fall back to ``MODE_MONO``.
374 * - ``V4L2_TUNER_MODE_LANG1``
376 - Play the primary language, mono or stereo. Only
377 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
378 * - ``V4L2_TUNER_MODE_LANG2``
380 - Play the secondary language, mono. When the tuner receives no
381 bilingual audio or SAP, or their reception is not supported the
382 driver shall fall back to mono or stereo mode. Only
383 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
384 * - ``V4L2_TUNER_MODE_SAP``
386 - Play the Second Audio Program. When the tuner receives no
387 bilingual audio or SAP, or their reception is not supported the
388 driver shall fall back to mono or stereo mode. Only
389 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
391 .. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
393 * - ``V4L2_TUNER_MODE_LANG1_LANG2``
395 - Play the primary language on the left channel, the secondary
396 language on the right channel. When the tuner receives no
397 bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
398 ``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
405 .. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|
409 .. flat-table:: Tuner Audio Matrix
412 :widths: 7 7 14 14 14 14
415 - :cspan:`4` Selected ``V4L2_TUNER_MODE_``
416 * - Received ``V4L2_TUNER_SUB_``
421 - ``LANG1_LANG2``\ [#f1]_
433 - Mono/SAP (preferred) or Mono/Mono
437 - Stereo L/R (preferred) or Mono L+R
438 - Stereo L/R (preferred) or Mono L+R
439 - L/R (preferred) or L+R/L+R
443 - Stereo L/R (preferred) or Mono L+R
445 - L+R/SAP (preferred) or L/R or L+R/L+R
446 * - ``LANG1 | LANG2``
448 - Lang1/Lang2 (deprecated\ [#f2]_) or Lang1/Lang1
451 - Lang1/Lang2 (preferred) or Lang1/Lang1
460 On success 0 is returned, on error -1 and the ``errno`` variable is set
461 appropriately. The generic error codes are described at the
462 :ref:`Generic Error Codes <gen-errors>` chapter.
465 The struct :c:type:`v4l2_tuner` ``index`` is out of
469 This mode has been added in Linux 2.6.17 and may not be supported by
473 Playback of both languages in ``MODE_STEREO`` is deprecated. In the
474 future drivers should produce only the primary language in this mode.
475 Applications should request ``MODE_LANG1_LANG2`` to record both
476 languages or a stereo signal.