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.
63 .. tabularcolumns:: |p{1.3cm}|p{3.0cm}|p{6.6cm}|p{6.6cm}|
67 .. cssclass:: longtable
69 .. flat-table:: struct v4l2_tuner
80 - :cspan:`1` Identifies the tuner, set by the application.
90 Name of the tuner, a NUL-terminated ASCII string.
92 This information is intended for the user.
100 - :cspan:`1` Type of the tuner, see :ref:`v4l2-tuner-type`.
110 Tuner capability flags, see :ref:`tuner-capability`. Audio flags
111 indicate the ability to decode audio subprograms. They will *not*
112 change, for example with the current video standard.
114 When the structure refers to a radio tuner the
115 ``V4L2_TUNER_CAP_LANG1``, ``V4L2_TUNER_CAP_LANG2`` and
116 ``V4L2_TUNER_CAP_NORM`` flags can't be used.
118 If multiple frequency bands are supported, then ``capability`` is
119 the union of all ``capability`` fields of each struct
120 :ref:`v4l2_frequency_band <v4l2-frequency-band>`.
128 - :cspan:`1` The lowest tunable frequency in units of 62.5 kHz, or
129 if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units
130 of 62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ``
131 is set, in units of 1 Hz. If multiple frequency bands are
132 supported, then ``rangelow`` is the lowest frequency of all the
141 - :cspan:`1` The highest tunable frequency in units of 62.5 kHz,
142 or if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in
143 units of 62.5 Hz, or if the ``capability`` flag
144 ``V4L2_TUNER_CAP_1HZ`` is set, in units of 1 Hz. If multiple
145 frequency bands are supported, then ``rangehigh`` is the highest
146 frequency of all the frequency bands.
156 Some tuners or audio decoders can determine the received audio
157 subprograms by analyzing audio carriers, pilot tones or other
158 indicators. To pass this information drivers set flags defined in
159 :ref:`tuner-rxsubchans` in this field. For example:
165 - ``V4L2_TUNER_SUB_MONO``
167 - receiving mono audio
175 - receiving stereo audio and a secondary audio program
183 - receiving mono or stereo audio, the hardware cannot distinguish
191 - receiving bilingual audio
197 - ``MONO | STEREO | LANG1 | LANG2``
199 - receiving mono, stereo or bilingual audio
207 When the ``V4L2_TUNER_CAP_STEREO``, ``_LANG1``, ``_LANG2`` or
208 ``_SAP`` flag is cleared in the ``capability`` field, the
209 corresponding ``V4L2_TUNER_SUB_`` flag must not be set here.
211 This field is valid only if this is the tuner of the current video
212 input, or when the structure refers to a radio tuner.
222 The selected audio mode, see :ref:`tuner-audmode` for valid
223 values. The audio mode does not affect audio subprogram detection,
224 and like a :ref:`control` it does not automatically
225 change unless the requested mode is invalid or unsupported. See
226 :ref:`tuner-matrix` for possible results when the selected and
227 received audio programs do not match.
229 Currently this is the only field of struct
230 :ref:`struct v4l2_tuner <v4l2-tuner>` applications can change.
238 - :cspan:`1` The signal strength if known.
240 Ranging from 0 to 65535. Higher values indicate a better signal.
248 - :cspan:`1` Automatic frequency control.
250 When the ``afc`` value is negative, the frequency is too
251 low, when positive too high.
259 - :cspan:`1` Reserved for future extensions.
261 Drivers and applications must set the array to zero.
265 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
269 .. flat-table:: enum v4l2_tuner_type
277 - ``V4L2_TUNER_RADIO``
281 - Tuner supports radio
285 - ``V4L2_TUNER_ANALOG_TV``
289 - Tuner supports analog TV
297 - Tuner controls the A/D and/or D/A block of a
298 Sofware Digital Radio (SDR)
306 - Tuner controls the RF part of a Sofware Digital Radio (SDR)
309 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
311 .. _tuner-capability:
313 .. cssclass:: longtable
315 .. flat-table:: Tuner and Modulator Capability Flags
323 - ``V4L2_TUNER_CAP_LOW``
327 - When set, tuning frequencies are expressed in units of 62.5 Hz
332 - ``V4L2_TUNER_CAP_NORM``
336 - This is a multi-standard tuner; the video standard can or must be
337 switched. (B/G PAL tuners for example are typically not considered
338 multi-standard because the video standard is automatically
339 determined from the frequency band.) The set of supported video
340 standards is available from the struct
341 :ref:`v4l2_input <v4l2-input>` pointing to this tuner, see the
342 description of ioctl :ref:`VIDIOC_ENUMINPUT`
343 for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
348 - ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
352 - If set, then this tuner supports the hardware seek functionality
353 where the seek stops when it reaches the end of the frequency
358 - ``V4L2_TUNER_CAP_HWSEEK_WRAP``
362 - If set, then this tuner supports the hardware seek functionality
363 where the seek wraps around when it reaches the end of the
368 - ``V4L2_TUNER_CAP_STEREO``
372 - Stereo audio reception is supported.
376 - ``V4L2_TUNER_CAP_LANG1``
380 - Reception of the primary language of a bilingual audio program is
381 supported. Bilingual audio is a feature of two-channel systems,
382 transmitting the primary language monaural on the main audio
383 carrier and a secondary language monaural on a second carrier.
384 Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
388 - ``V4L2_TUNER_CAP_LANG2``
392 - Reception of the secondary language of a bilingual audio program
393 is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
398 - ``V4L2_TUNER_CAP_SAP``
402 - Reception of a secondary audio program is supported. This is a
403 feature of the BTSC system which accompanies the NTSC video
404 standard. Two audio carriers are available for mono or stereo
405 transmissions of a primary language, and an independent third
406 carrier for a monaural secondary language. Only
407 ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
411 The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
412 flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
413 supports the ``V4L2_STD_NTSC_M`` video standard.
417 - ``V4L2_TUNER_CAP_RDS``
421 - RDS capture is supported. This capability is only valid for radio
426 - ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
430 - The RDS data is passed as unparsed RDS blocks.
434 - ``V4L2_TUNER_CAP_RDS_CONTROLS``
438 - The RDS data is parsed by the hardware and set via controls.
442 - ``V4L2_TUNER_CAP_FREQ_BANDS``
446 - The :ref:`VIDIOC_ENUM_FREQ_BANDS`
447 ioctl can be used to enumerate the available frequency bands.
451 - ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
455 - The range to search when using the hardware seek functionality is
457 :ref:`VIDIOC_S_HW_FREQ_SEEK` for
462 - ``V4L2_TUNER_CAP_1HZ``
466 - When set, tuning frequencies are expressed in units of 1 Hz
471 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
473 .. _tuner-rxsubchans:
475 .. flat-table:: Tuner Audio Reception Flags
483 - ``V4L2_TUNER_SUB_MONO``
487 - The tuner receives a mono audio signal.
491 - ``V4L2_TUNER_SUB_STEREO``
495 - The tuner receives a stereo audio signal.
499 - ``V4L2_TUNER_SUB_LANG1``
503 - The tuner receives the primary language of a bilingual audio
504 signal. Drivers must clear this flag when the current video
505 standard is ``V4L2_STD_NTSC_M``.
509 - ``V4L2_TUNER_SUB_LANG2``
513 - The tuner receives the secondary language of a bilingual audio
514 signal (or a second audio program).
518 - ``V4L2_TUNER_SUB_SAP``
522 - The tuner receives a Second Audio Program.
526 The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
527 flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
528 when the current video standard is ``V4L2_STD_NTSC_M``.
532 - ``V4L2_TUNER_SUB_RDS``
536 - The tuner receives an RDS channel.
540 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
544 .. flat-table:: Tuner Audio Modes
552 - ``V4L2_TUNER_MODE_MONO``
556 - Play mono audio. When the tuner receives a stereo signal this a
557 down-mix of the left and right channel. When the tuner receives a
558 bilingual or SAP signal this mode selects the primary language.
562 - ``V4L2_TUNER_MODE_STEREO``
566 - Play stereo audio. When the tuner receives bilingual audio it may
567 play different languages on the left and right channel or the
568 primary language is played on both channels.
570 Playing different languages in this mode is deprecated. New
571 drivers should do this only in ``MODE_LANG1_LANG2``.
573 When the tuner receives no stereo signal or does not support
574 stereo reception the driver shall fall back to ``MODE_MONO``.
578 - ``V4L2_TUNER_MODE_LANG1``
582 - Play the primary language, mono or stereo. Only
583 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
587 - ``V4L2_TUNER_MODE_LANG2``
591 - Play the secondary language, mono. 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.
598 - ``V4L2_TUNER_MODE_SAP``
602 - Play the Second Audio Program. When the tuner receives no
603 bilingual audio or SAP, or their reception is not supported the
604 driver shall fall back to mono or stereo mode. Only
605 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
607 .. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
612 - ``V4L2_TUNER_MODE_LANG1_LANG2``
616 - Play the primary language on the left channel, the secondary
617 language on the right channel. When the tuner receives no
618 bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
619 ``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
624 \begin{adjustbox}{width=\columnwidth}
628 .. flat-table:: Tuner Audio Matrix
636 - :cspan:`5` Selected ``V4L2_TUNER_MODE_``
640 - Received ``V4L2_TUNER_SUB_``
650 - ``LANG1_LANG2``\ [#f1]_
678 - Mono/SAP (preferred) or Mono/Mono
688 - Stereo L/R (preferred) or Mono L+R
690 - Stereo L/R (preferred) or Mono L+R
692 - L/R (preferred) or L+R/L+R
702 - Stereo L/R (preferred) or Mono L+R
706 - L+R/SAP (preferred) or L/R or L+R/L+R
714 - Lang1/Lang2 (deprecated [#f2]_) or Lang1/Lang1
720 - Lang1/Lang2 (preferred) or Lang1/Lang1
724 \end{adjustbox}\newline\newline
729 On success 0 is returned, on error -1 and the ``errno`` variable is set
730 appropriately. The generic error codes are described at the
731 :ref:`Generic Error Codes <gen-errors>` chapter.
734 The struct :ref:`v4l2_tuner <v4l2-tuner>` ``index`` is out of
738 This mode has been added in Linux 2.6.17 and may not be supported by
742 Playback of both languages in ``MODE_STEREO`` is deprecated. In the
743 future drivers should produce only the primary language in this mode.
744 Applications should request ``MODE_LANG1_LANG2`` to record both
745 languages or a stereo signal.