1 .. -*- coding: utf-8; mode: rst -*-
5 ************************************
6 ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER
7 ************************************
12 VIDIOC_G_TUNER - VIDIOC_S_TUNER - Get or set tuner attributes
18 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_tuner *argp )
20 .. cpp:function:: int ioctl( int fd, int request, const struct v4l2_tuner *argp )
27 File descriptor returned by :ref:`open() <func-open>`.
30 VIDIOC_G_TUNER, VIDIOC_S_TUNER
38 To query the attributes of a tuner applications initialize the ``index``
39 field and zero out the ``reserved`` array of a struct
40 :ref:`v4l2_tuner <v4l2-tuner>` and call the ``VIDIOC_G_TUNER`` ioctl
41 with a pointer to this structure. Drivers fill the rest of the structure
42 or return an ``EINVAL`` error code when the index is out of bounds. To
43 enumerate all tuners applications shall begin at index zero,
44 incrementing by one until the driver returns ``EINVAL``.
46 Tuners have two writable properties, the audio mode and the radio
47 frequency. To change the audio mode, applications initialize the
48 ``index``, ``audmode`` and ``reserved`` fields and call the
49 ``VIDIOC_S_TUNER`` ioctl. This will *not* change the current tuner,
50 which is determined by the current video input. Drivers may choose a
51 different audio mode if the requested mode is invalid or unsupported.
52 Since this is a write-only ioctl, it does not return the actually
55 :ref:`SDR <sdr>` specific tuner types are ``V4L2_TUNER_SDR`` and
56 ``V4L2_TUNER_RF``. For SDR devices ``audmode`` field must be initialized
57 to zero. The term 'tuner' means SDR receiver in this context.
59 To change the radio frequency the
60 :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
65 .. flat-table:: struct v4l2_tuner
76 - :cspan:`1` Identifies the tuner, set by the application.
86 Name of the tuner, a NUL-terminated ASCII string. This information
87 is intended for the user.
95 - :cspan:`1` Type of the tuner, see :ref:`v4l2-tuner-type`.
105 Tuner capability flags, see :ref:`tuner-capability`. Audio flags
106 indicate the ability to decode audio subprograms. They will *not*
107 change, for example with the current video standard.
109 When the structure refers to a radio tuner the
110 ``V4L2_TUNER_CAP_LANG1``, ``V4L2_TUNER_CAP_LANG2`` and
111 ``V4L2_TUNER_CAP_NORM`` flags can't be used.
113 If multiple frequency bands are supported, then ``capability`` is
114 the union of all ``capability`` fields of each struct
115 :ref:`v4l2_frequency_band <v4l2-frequency-band>`.
123 - :cspan:`1` The lowest tunable frequency in units of 62.5 kHz, or
124 if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units
125 of 62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ``
126 is set, in units of 1 Hz. If multiple frequency bands are
127 supported, then ``rangelow`` is the lowest frequency of all the
136 - :cspan:`1` The highest tunable frequency in units of 62.5 kHz,
137 or if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in
138 units of 62.5 Hz, or if the ``capability`` flag
139 ``V4L2_TUNER_CAP_1HZ`` is set, in units of 1 Hz. If multiple
140 frequency bands are supported, then ``rangehigh`` is the highest
141 frequency of all the frequency bands.
151 Some tuners or audio decoders can determine the received audio
152 subprograms by analyzing audio carriers, pilot tones or other
153 indicators. To pass this information drivers set flags defined in
154 :ref:`tuner-rxsubchans` in this field. For example:
160 - ``V4L2_TUNER_SUB_MONO``
162 - receiving mono audio
170 - receiving stereo audio and a secondary audio program
178 - receiving mono or stereo audio, the hardware cannot distinguish
186 - receiving bilingual audio
192 - ``MONO | STEREO | LANG1 | LANG2``
194 - receiving mono, stereo or bilingual audio
202 When the ``V4L2_TUNER_CAP_STEREO``, ``_LANG1``, ``_LANG2`` or
203 ``_SAP`` flag is cleared in the ``capability`` field, the
204 corresponding ``V4L2_TUNER_SUB_`` flag must not be set here.
206 This field is valid only if this is the tuner of the current video
207 input, or when the structure refers to a radio tuner.
217 The selected audio mode, see :ref:`tuner-audmode` for valid
218 values. The audio mode does not affect audio subprogram detection,
219 and like a :ref:`control` it does not automatically
220 change unless the requested mode is invalid or unsupported. See
221 :ref:`tuner-matrix` for possible results when the selected and
222 received audio programs do not match.
224 Currently this is the only field of struct
225 :ref:`struct v4l2_tuner <v4l2-tuner>` applications can change.
233 - :cspan:`1` The signal strength if known, ranging from 0 to
234 65535. Higher values indicate a better signal.
242 - :cspan:`1` Automatic frequency control: When the ``afc`` value
243 is negative, the frequency is too low, when positive too high.
251 - :cspan:`1` Reserved for future extensions. Drivers and
252 applications must set the array to zero.
258 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
260 .. flat-table:: enum v4l2_tuner_type
268 - ``V4L2_TUNER_RADIO``
272 - Tuner supports radio
276 - ``V4L2_TUNER_ANALOG_TV``
280 - Tuner supports analog TV
288 - Tuner controls the A/D and/or D/A block of a
289 Sofware Digital Radio (SDR)
297 - Tuner controls the RF part of a Sofware Digital Radio (SDR)
300 .. _tuner-capability:
302 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
304 .. flat-table:: Tuner and Modulator Capability Flags
312 - ``V4L2_TUNER_CAP_LOW``
316 - When set, tuning frequencies are expressed in units of 62.5 Hz
321 - ``V4L2_TUNER_CAP_NORM``
325 - This is a multi-standard tuner; the video standard can or must be
326 switched. (B/G PAL tuners for example are typically not considered
327 multi-standard because the video standard is automatically
328 determined from the frequency band.) The set of supported video
329 standards is available from the struct
330 :ref:`v4l2_input <v4l2-input>` pointing to this tuner, see the
331 description of ioctl :ref:`VIDIOC_ENUMINPUT`
332 for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
337 - ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
341 - If set, then this tuner supports the hardware seek functionality
342 where the seek stops when it reaches the end of the frequency
347 - ``V4L2_TUNER_CAP_HWSEEK_WRAP``
351 - If set, then this tuner supports the hardware seek functionality
352 where the seek wraps around when it reaches the end of the
357 - ``V4L2_TUNER_CAP_STEREO``
361 - Stereo audio reception is supported.
365 - ``V4L2_TUNER_CAP_LANG1``
369 - Reception of the primary language of a bilingual audio program is
370 supported. Bilingual audio is a feature of two-channel systems,
371 transmitting the primary language monaural on the main audio
372 carrier and a secondary language monaural on a second carrier.
373 Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
377 - ``V4L2_TUNER_CAP_LANG2``
381 - Reception of the secondary language of a bilingual audio program
382 is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
387 - ``V4L2_TUNER_CAP_SAP``
391 - Reception of a secondary audio program is supported. This is a
392 feature of the BTSC system which accompanies the NTSC video
393 standard. Two audio carriers are available for mono or stereo
394 transmissions of a primary language, and an independent third
395 carrier for a monaural secondary language. Only
396 ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
400 The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
401 flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
402 supports the ``V4L2_STD_NTSC_M`` video standard.
406 - ``V4L2_TUNER_CAP_RDS``
410 - RDS capture is supported. This capability is only valid for radio
415 - ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
419 - The RDS data is passed as unparsed RDS blocks.
423 - ``V4L2_TUNER_CAP_RDS_CONTROLS``
427 - The RDS data is parsed by the hardware and set via controls.
431 - ``V4L2_TUNER_CAP_FREQ_BANDS``
435 - The :ref:`VIDIOC_ENUM_FREQ_BANDS`
436 ioctl can be used to enumerate the available frequency bands.
440 - ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
444 - The range to search when using the hardware seek functionality is
446 :ref:`VIDIOC_S_HW_FREQ_SEEK` for
451 - ``V4L2_TUNER_CAP_1HZ``
455 - When set, tuning frequencies are expressed in units of 1 Hz
460 .. _tuner-rxsubchans:
462 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
464 .. flat-table:: Tuner Audio Reception Flags
472 - ``V4L2_TUNER_SUB_MONO``
476 - The tuner receives a mono audio signal.
480 - ``V4L2_TUNER_SUB_STEREO``
484 - The tuner receives a stereo audio signal.
488 - ``V4L2_TUNER_SUB_LANG1``
492 - The tuner receives the primary language of a bilingual audio
493 signal. Drivers must clear this flag when the current video
494 standard is ``V4L2_STD_NTSC_M``.
498 - ``V4L2_TUNER_SUB_LANG2``
502 - The tuner receives the secondary language of a bilingual audio
503 signal (or a second audio program).
507 - ``V4L2_TUNER_SUB_SAP``
511 - The tuner receives a Second Audio Program.
515 The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
516 flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
517 when the current video standard is ``V4L2_STD_NTSC_M``.
521 - ``V4L2_TUNER_SUB_RDS``
525 - The tuner receives an RDS channel.
531 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
533 .. flat-table:: Tuner Audio Modes
541 - ``V4L2_TUNER_MODE_MONO``
545 - Play mono audio. When the tuner receives a stereo signal this a
546 down-mix of the left and right channel. When the tuner receives a
547 bilingual or SAP signal this mode selects the primary language.
551 - ``V4L2_TUNER_MODE_STEREO``
555 - Play stereo audio. When the tuner receives bilingual audio it may
556 play different languages on the left and right channel or the
557 primary language is played on both channels.
559 Playing different languages in this mode is deprecated. New
560 drivers should do this only in ``MODE_LANG1_LANG2``.
562 When the tuner receives no stereo signal or does not support
563 stereo reception the driver shall fall back to ``MODE_MONO``.
567 - ``V4L2_TUNER_MODE_LANG1``
571 - Play the primary language, mono or stereo. Only
572 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
576 - ``V4L2_TUNER_MODE_LANG2``
580 - Play the secondary language, mono. When the tuner receives no
581 bilingual audio or SAP, or their reception is not supported the
582 driver shall fall back to mono or stereo mode. Only
583 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
587 - ``V4L2_TUNER_MODE_SAP``
591 - Play the Second Audio Program. When the tuner receives no
592 bilingual audio or SAP, or their reception is not supported the
593 driver shall fall back to mono or stereo mode. Only
594 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
596 .. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
601 - ``V4L2_TUNER_MODE_LANG1_LANG2``
605 - Play the primary language on the left channel, the secondary
606 language on the right channel. When the tuner receives no
607 bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
608 ``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
615 .. flat-table:: Tuner Audio Matrix
623 - :cspan:`5` Selected ``V4L2_TUNER_MODE_``
627 - Received ``V4L2_TUNER_SUB_``
637 - ``LANG1_LANG2``\ [#f1]_
665 - Mono/SAP (preferred) or Mono/Mono
675 - Stereo L/R (preferred) or Mono L+R
677 - Stereo L/R (preferred) or Mono L+R
679 - L/R (preferred) or L+R/L+R
689 - Stereo L/R (preferred) or Mono L+R
693 - L+R/SAP (preferred) or L/R or L+R/L+R
701 - Lang1/Lang2 (deprecated [#f2]_) or Lang1/Lang1
707 - Lang1/Lang2 (preferred) or Lang1/Lang1
713 On success 0 is returned, on error -1 and the ``errno`` variable is set
714 appropriately. The generic error codes are described at the
715 :ref:`Generic Error Codes <gen-errors>` chapter.
718 The struct :ref:`v4l2_tuner <v4l2-tuner>` ``index`` is out of
722 This mode has been added in Linux 2.6.17 and may not be supported by
726 Playback of both languages in ``MODE_STEREO`` is deprecated. In the
727 future drivers should produce only the primary language in this mode.
728 Applications should request ``MODE_LANG1_LANG2`` to record both
729 languages or a stereo signal.