To query the attributes of a tuner applications initialize the
index field and zero out the
reserved array of a struct v4l2_tuner and call the
VIDIOC_G_TUNER ioctl with a pointer to this
structure. Drivers fill the rest of the structure or return an
EINVAL error code when the index is out of bounds. To enumerate all tuners
applications shall begin at index zero, incrementing by one until the
driver returns EINVAL.
Tuners have two writable properties, the audio mode and
the radio frequency. To change the audio mode, applications initialize
the index,
audmode and
reserved fields and call the
VIDIOC_S_TUNER ioctl. This will
not change the current tuner, which is determined
by the current video input. Drivers may choose a different audio mode
if the requested mode is invalid or unsupported. Since this is a
write-only ioctl, it does not return the actually
selected audio mode.
To change the radio frequency the VIDIOC_S_FREQUENCY ioctl
is available.
Table 1. struct v4l2_tuner
| __u32 | index | Identifies the tuner, set by the application. | |
| __u8 | name[32] | Name of the tuner, a NUL-terminated ASCII string. This information is intended for the user. | |
| enum v4l2_tuner_type | type | Type of the tuner, see Table 2. | |
| __u32 | capability | Tuner capability flags, see Table 3. Audio flags indicate the ability to decode audio subprograms. They will not change, for example with the current video standard. When
the structure refers to a radio tuner only the
 | |
| __u32 | rangelow | The lowest tunable frequency in
units of 62.5 kHz, or if the capabilityflagV4L2_TUNER_CAP_LOWis set, in units of 62.5
Hz. | |
| __u32 | rangehigh | The highest tunable frequency in
units of 62.5 kHz, or if the capabilityflagV4L2_TUNER_CAP_LOWis set, in units of 62.5
Hz. | |
| __u32 | rxsubchans | Some tuners or audio decoders can determine the received audio subprograms by analyzing audio carriers, pilot tones or other indicators. To pass this information drivers set flags defined in Table 4 in this field. For example: | |
| V4L2_TUNER_SUB_MONO | receiving mono audio | ||
| STEREO | SAP | receiving stereo audio and a secondary audio program | ||
| MONO | STEREO | receiving mono or stereo audio, the hardware cannot distinguish | ||
| LANG1 | LANG2 | receiving bilingual audio | ||
| MONO | STEREO | LANG1 | LANG2 | receiving mono, stereo or bilingual audio | ||
| When the
 This field is valid only if this is the tuner of the current video input, or when the structure refers to a radio tuner. | |||
| __u32 | audmode | The selected audio mode, see Table 5 for valid values. The audio mode does not affect audio subprogram detection, and like a control it does not automatically change unless the requested mode is invalid or unsupported. See Table 6 for possible results when the selected and received audio programs do not match. Currently this is the only field of struct
 | |
| __u32 | signal | The signal strength if known, ranging from 0 to 65535. Higher values indicate a better signal. | |
| __s32 | afc | Automatic frequency control: When the afcvalue is negative, the frequency is too
low, when positive too high. | |
| __u32 | reserved[4] | Reserved for future extensions. Drivers and applications must set the array to zero. | |
Table 3. Tuner and Modulator Capability Flags
| V4L2_TUNER_CAP_LOW | 0x0001 | When set, tuning frequencies are expressed in units of 62.5 Hz, otherwise in units of 62.5 kHz. | 
| V4L2_TUNER_CAP_NORM | 0x0002 | This is a multi-standard tuner; the video standard
can or must be switched. (B/G PAL tuners for example are typically not
      considered multi-standard because the video standard is automatically
      determined from the frequency band.) The set of supported video
      standards is available from the struct v4l2_input pointing to this tuner,
      see the description of ioctl VIDIOC_ENUMINPUTfor details. OnlyV4L2_TUNER_ANALOG_TVtuners can have this capability. | 
| V4L2_TUNER_CAP_STEREO | 0x0010 | Stereo audio reception is supported. | 
| V4L2_TUNER_CAP_LANG1 | 0x0040 | Reception of the primary language of a bilingual
audio program is supported. Bilingual audio is a feature of
two-channel systems, transmitting the primary language monaural on the
main audio carrier and a secondary language monaural on a second
carrier. Only V4L2_TUNER_ANALOG_TVtuners can have this capability. | 
| V4L2_TUNER_CAP_LANG2 | 0x0020 | Reception of the secondary language of a bilingual
audio program is supported. Only V4L2_TUNER_ANALOG_TVtuners can have this capability. | 
| V4L2_TUNER_CAP_SAP | 0x0020 | Reception of a secondary audio program is
supported. This is a feature of the BTSC system which accompanies the
NTSC video standard. Two audio carriers are available for mono or
stereo transmissions of a primary language, and an independent third
carrier for a monaural secondary language. Only
       Note the
 | 
Table 4. Tuner Audio Reception Flags
| V4L2_TUNER_SUB_MONO | 0x0001 | The tuner receives a mono audio signal. | 
| V4L2_TUNER_SUB_STEREO | 0x0002 | The tuner receives a stereo audio signal. | 
| V4L2_TUNER_SUB_LANG1 | 0x0008 | The tuner receives the primary language of a
bilingual audio signal. Drivers must clear this flag when the current
video standard is V4L2_STD_NTSC_M. | 
| V4L2_TUNER_SUB_LANG2 | 0x0004 | The tuner receives the secondary language of a bilingual audio signal (or a second audio program). | 
| V4L2_TUNER_SUB_SAP | 0x0004 | The tuner receives a Second Audio Program. Note the V4L2_TUNER_SUB_LANG2andV4L2_TUNER_SUB_SAPflags are synonyms. TheV4L2_TUNER_SUB_SAPflag applies when the
current video standard isV4L2_STD_NTSC_M. | 
Table 5. Tuner Audio Modes
| V4L2_TUNER_MODE_MONO | 0 | Play mono audio. When the tuner receives a stereo signal this a down-mix of the left and right channel. When the tuner receives a bilingual or SAP signal this mode selects the primary language. | 
| V4L2_TUNER_MODE_STEREO | 1 | Play stereo audio. When the tuner receives bilingual audio it may play different languages on the left and right channel or the primary language on both channels. behave as in mono mode. Playing different languages in this mode is
deprecated. New drivers should do this only in
 When the tuner
receives no stereo signal or does not support stereo reception the
driver shall fall back to  | 
| V4L2_TUNER_MODE_LANG1 | 3 | Play the primary language, mono or stereo. Only V4L2_TUNER_ANALOG_TVtuners support this
mode. | 
| V4L2_TUNER_MODE_LANG2 | 2 | Play the secondary language, mono. When the tuner
receives no bilingual audio or SAP, or their reception is not
supported the driver shall fall back to mono or stereo mode. Only V4L2_TUNER_ANALOG_TVtuners support this
mode. | 
| V4L2_TUNER_MODE_SAP | 2 | Play the Second Audio Program. When the tuner
receives no bilingual audio or SAP, or their reception is not
supported the driver shall fall back to mono or stereo mode. Only V4L2_TUNER_ANALOG_TVtuners support this mode.
Note theV4L2_TUNER_MODE_LANG2andV4L2_TUNER_MODE_SAPare synonyms. | 
| V4L2_TUNER_MODE_LANG1_LANG2 | 4 | Play the primary language on the left channel, the
secondary language on the right channel. When the tuner receives no
bilingual audio or SAP, it shall fall back to MODE_LANG1orMODE_MONO.
OnlyV4L2_TUNER_ANALOG_TVtuners support this
mode. | 
Table 6. Tuner Audio Matrix
| Selected V4L2_TUNER_MODE_ | |||||
|---|---|---|---|---|---|
| Received V4L2_TUNER_SUB_ | MONO | STEREO | LANG1 | LANG2 = SAP | LANG1_LANG2[a] | 
| MONO | Mono | Mono/Mono | Mono | Mono | Mono/Mono | 
| MONO | SAP | Mono | Mono/Mono | Mono | SAP | Mono/SAP (preferred) or Mono/Mono | 
| STEREO | L+R | L/R | Stereo L/R (preferred) or Mono L+R | Stereo L/R (preferred) or Mono L+R | L/R (preferred) or L+R/L+R | 
| STEREO | SAP | L+R | L/R | Stereo L/R (preferred) or Mono L+R | SAP | L+R/SAP (preferred) or L/R or L+R/L+R | 
| LANG1 | LANG2 | Language 1 | Lang1/Lang2 (deprecated[b]) or Lang1/Lang1 | Language 1 | Language 2 | Lang1/Lang2 (preferred) or Lang1/Lang1 | 
| Notes: a. This mode has been added in Linux 2.6.17 and may not be supported by older drivers. b. Playback of both languages in MODE_STEREOis deprecated. In
the future drivers should produce only the primary language in this
mode. Applications should requestMODE_LANG1_LANG2to record both languages or a
stereo signal. | |||||
On success 0 is returned, on error -1 and the errno variable is set appropriately:
The struct v4l2_tuner index is
out of bounds.