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 .. flat-table:: enum v4l2_tuner_type
266 - ``V4L2_TUNER_RADIO``
274 - ``V4L2_TUNER_ANALOG_TV``
298 .. _tuner-capability:
300 .. flat-table:: Tuner and Modulator Capability Flags
308 - ``V4L2_TUNER_CAP_LOW``
312 - When set, tuning frequencies are expressed in units of 62.5 Hz
317 - ``V4L2_TUNER_CAP_NORM``
321 - This is a multi-standard tuner; the video standard can or must be
322 switched. (B/G PAL tuners for example are typically not considered
323 multi-standard because the video standard is automatically
324 determined from the frequency band.) The set of supported video
325 standards is available from the struct
326 :ref:`v4l2_input <v4l2-input>` pointing to this tuner, see the
327 description of ioctl :ref:`VIDIOC_ENUMINPUT`
328 for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
333 - ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
337 - If set, then this tuner supports the hardware seek functionality
338 where the seek stops when it reaches the end of the frequency
343 - ``V4L2_TUNER_CAP_HWSEEK_WRAP``
347 - If set, then this tuner supports the hardware seek functionality
348 where the seek wraps around when it reaches the end of the
353 - ``V4L2_TUNER_CAP_STEREO``
357 - Stereo audio reception is supported.
361 - ``V4L2_TUNER_CAP_LANG1``
365 - Reception of the primary language of a bilingual audio program is
366 supported. Bilingual audio is a feature of two-channel systems,
367 transmitting the primary language monaural on the main audio
368 carrier and a secondary language monaural on a second carrier.
369 Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
373 - ``V4L2_TUNER_CAP_LANG2``
377 - Reception of the secondary language of a bilingual audio program
378 is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
383 - ``V4L2_TUNER_CAP_SAP``
387 - Reception of a secondary audio program is supported. This is a
388 feature of the BTSC system which accompanies the NTSC video
389 standard. Two audio carriers are available for mono or stereo
390 transmissions of a primary language, and an independent third
391 carrier for a monaural secondary language. Only
392 ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
394 .. note:: The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
395 flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
396 supports the ``V4L2_STD_NTSC_M`` video standard.
400 - ``V4L2_TUNER_CAP_RDS``
404 - RDS capture is supported. This capability is only valid for radio
409 - ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
413 - The RDS data is passed as unparsed RDS blocks.
417 - ``V4L2_TUNER_CAP_RDS_CONTROLS``
421 - The RDS data is parsed by the hardware and set via controls.
425 - ``V4L2_TUNER_CAP_FREQ_BANDS``
429 - The :ref:`VIDIOC_ENUM_FREQ_BANDS`
430 ioctl can be used to enumerate the available frequency bands.
434 - ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
438 - The range to search when using the hardware seek functionality is
440 :ref:`VIDIOC_S_HW_FREQ_SEEK` for
445 - ``V4L2_TUNER_CAP_1HZ``
449 - When set, tuning frequencies are expressed in units of 1 Hz
454 .. _tuner-rxsubchans:
456 .. flat-table:: Tuner Audio Reception Flags
464 - ``V4L2_TUNER_SUB_MONO``
468 - The tuner receives a mono audio signal.
472 - ``V4L2_TUNER_SUB_STEREO``
476 - The tuner receives a stereo audio signal.
480 - ``V4L2_TUNER_SUB_LANG1``
484 - The tuner receives the primary language of a bilingual audio
485 signal. Drivers must clear this flag when the current video
486 standard is ``V4L2_STD_NTSC_M``.
490 - ``V4L2_TUNER_SUB_LANG2``
494 - The tuner receives the secondary language of a bilingual audio
495 signal (or a second audio program).
499 - ``V4L2_TUNER_SUB_SAP``
503 - The tuner receives a Second Audio Program.
505 .. note:: The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
506 flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
507 when the current video standard is ``V4L2_STD_NTSC_M``.
511 - ``V4L2_TUNER_SUB_RDS``
515 - The tuner receives an RDS channel.
521 .. flat-table:: Tuner Audio Modes
529 - ``V4L2_TUNER_MODE_MONO``
533 - Play mono audio. When the tuner receives a stereo signal this a
534 down-mix of the left and right channel. When the tuner receives a
535 bilingual or SAP signal this mode selects the primary language.
539 - ``V4L2_TUNER_MODE_STEREO``
543 - Play stereo audio. When the tuner receives bilingual audio it may
544 play different languages on the left and right channel or the
545 primary language is played on both channels.
547 Playing different languages in this mode is deprecated. New
548 drivers should do this only in ``MODE_LANG1_LANG2``.
550 When the tuner receives no stereo signal or does not support
551 stereo reception the driver shall fall back to ``MODE_MONO``.
555 - ``V4L2_TUNER_MODE_LANG1``
559 - Play the primary language, mono or stereo. Only
560 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
564 - ``V4L2_TUNER_MODE_LANG2``
568 - Play the secondary language, mono. When the tuner receives no
569 bilingual audio or SAP, or their reception is not supported the
570 driver shall fall back to mono or stereo mode. Only
571 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
575 - ``V4L2_TUNER_MODE_SAP``
579 - Play the Second Audio Program. When the tuner receives no
580 bilingual audio or SAP, or their reception is not supported the
581 driver shall fall back to mono or stereo mode. Only
582 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
584 .. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
589 - ``V4L2_TUNER_MODE_LANG1_LANG2``
593 - Play the primary language on the left channel, the secondary
594 language on the right channel. When the tuner receives no
595 bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
596 ``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
603 .. flat-table:: Tuner Audio Matrix
611 - :cspan:`5` Selected ``V4L2_TUNER_MODE_``
615 - Received ``V4L2_TUNER_SUB_``
625 - ``LANG1_LANG2``\ [#f1]_
653 - Mono/SAP (preferred) or Mono/Mono
663 - Stereo L/R (preferred) or Mono L+R
665 - Stereo L/R (preferred) or Mono L+R
667 - L/R (preferred) or L+R/L+R
677 - Stereo L/R (preferred) or Mono L+R
681 - L+R/SAP (preferred) or L/R or L+R/L+R
689 - Lang1/Lang2 (deprecated [#f2]_) or Lang1/Lang1
695 - Lang1/Lang2 (preferred) or Lang1/Lang1
701 On success 0 is returned, on error -1 and the ``errno`` variable is set
702 appropriately. The generic error codes are described at the
703 :ref:`Generic Error Codes <gen-errors>` chapter.
706 The struct :ref:`v4l2_tuner <v4l2-tuner>` ``index`` is out of
710 This mode has been added in Linux 2.6.17 and may not be supported by
714 Playback of both languages in ``MODE_STEREO`` is deprecated. In the
715 future drivers should produce only the primary language in this mode.
716 Applications should request ``MODE_LANG1_LANG2`` to record both
717 languages or a stereo signal.