0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 .. c:namespace:: V4L
0003
0004 .. _VIDIOC_G_TUNER:
0005
0006 ************************************
0007 ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER
0008 ************************************
0009
0010 Name
0011 ====
0012
0013 VIDIOC_G_TUNER - VIDIOC_S_TUNER - Get or set tuner attributes
0014
0015 Synopsis
0016 ========
0017
0018 .. c:macro:: VIDIOC_G_TUNER
0019
0020 ``int ioctl(int fd, VIDIOC_G_TUNER, struct v4l2_tuner *argp)``
0021
0022 .. c:macro:: VIDIOC_S_TUNER
0023
0024 ``int ioctl(int fd, VIDIOC_S_TUNER, const struct v4l2_tuner *argp)``
0025
0026 Arguments
0027 =========
0028
0029 ``fd``
0030 File descriptor returned by :c:func:`open()`.
0031
0032 ``argp``
0033 Pointer to struct :c:type:`v4l2_tuner`.
0034
0035 Description
0036 ===========
0037
0038 To query the attributes of a tuner applications initialize the ``index``
0039 field and zero out the ``reserved`` array of a struct
0040 :c:type:`v4l2_tuner` and call the ``VIDIOC_G_TUNER`` ioctl
0041 with a pointer to this structure. Drivers fill the rest of the structure
0042 or return an ``EINVAL`` error code when the index is out of bounds. To
0043 enumerate all tuners applications shall begin at index zero,
0044 incrementing by one until the driver returns ``EINVAL``.
0045
0046 Tuners have two writable properties, the audio mode and the radio
0047 frequency. To change the audio mode, applications initialize the
0048 ``index``, ``audmode`` and ``reserved`` fields and call the
0049 ``VIDIOC_S_TUNER`` ioctl. This will *not* change the current tuner,
0050 which is determined by the current video input. Drivers may choose a
0051 different audio mode if the requested mode is invalid or unsupported.
0052 Since this is a write-only ioctl, it does not return the actually
0053 selected audio mode.
0054
0055 :ref:`SDR <sdr>` specific tuner types are ``V4L2_TUNER_SDR`` and
0056 ``V4L2_TUNER_RF``. For SDR devices ``audmode`` field must be initialized
0057 to zero. The term 'tuner' means SDR receiver in this context.
0058
0059 To change the radio frequency the
0060 :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
0061
0062 .. tabularcolumns:: |p{1.3cm}|p{3.0cm}|p{7.0cm}|p{5.8cm}|
0063
0064 .. c:type:: v4l2_tuner
0065
0066 .. cssclass:: longtable
0067
0068 .. flat-table:: struct v4l2_tuner
0069 :header-rows: 0
0070 :stub-columns: 0
0071
0072 * - __u32
0073 - ``index``
0074 - :cspan:`1` Identifies the tuner, set by the application.
0075 * - __u8
0076 - ``name``\ [32]
0077 - :cspan:`1`
0078
0079 Name of the tuner, a NUL-terminated ASCII string.
0080
0081 This information is intended for the user.
0082 * - __u32
0083 - ``type``
0084 - :cspan:`1` Type of the tuner, see :c:type:`v4l2_tuner_type`.
0085 * - __u32
0086 - ``capability``
0087 - :cspan:`1`
0088
0089 Tuner capability flags, see :ref:`tuner-capability`. Audio flags
0090 indicate the ability to decode audio subprograms. They will *not*
0091 change, for example with the current video standard.
0092
0093 When the structure refers to a radio tuner the
0094 ``V4L2_TUNER_CAP_LANG1``, ``V4L2_TUNER_CAP_LANG2`` and
0095 ``V4L2_TUNER_CAP_NORM`` flags can't be used.
0096
0097 If multiple frequency bands are supported, then ``capability`` is
0098 the union of all ``capability`` fields of each struct
0099 :c:type:`v4l2_frequency_band`.
0100 * - __u32
0101 - ``rangelow``
0102 - :cspan:`1` The lowest tunable frequency in units of 62.5 kHz, or
0103 if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units
0104 of 62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ``
0105 is set, in units of 1 Hz. If multiple frequency bands are
0106 supported, then ``rangelow`` is the lowest frequency of all the
0107 frequency bands.
0108 * - __u32
0109 - ``rangehigh``
0110 - :cspan:`1` The highest tunable frequency in units of 62.5 kHz,
0111 or if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in
0112 units of 62.5 Hz, or if the ``capability`` flag
0113 ``V4L2_TUNER_CAP_1HZ`` is set, in units of 1 Hz. If multiple
0114 frequency bands are supported, then ``rangehigh`` is the highest
0115 frequency of all the frequency bands.
0116 * - __u32
0117 - ``rxsubchans``
0118 - :cspan:`1`
0119
0120 Some tuners or audio decoders can determine the received audio
0121 subprograms by analyzing audio carriers, pilot tones or other
0122 indicators. To pass this information drivers set flags defined in
0123 :ref:`tuner-rxsubchans` in this field. For example:
0124 * -
0125 -
0126 - ``V4L2_TUNER_SUB_MONO``
0127 - receiving mono audio
0128 * -
0129 -
0130 - ``STEREO | SAP``
0131 - receiving stereo audio and a secondary audio program
0132 * -
0133 -
0134 - ``MONO | STEREO``
0135 - receiving mono or stereo audio, the hardware cannot distinguish
0136 * -
0137 -
0138 - ``LANG1 | LANG2``
0139 - receiving bilingual audio
0140 * -
0141 -
0142 - ``MONO | STEREO | LANG1 | LANG2``
0143 - receiving mono, stereo or bilingual audio
0144 * -
0145 -
0146 - :cspan:`1`
0147
0148 When the ``V4L2_TUNER_CAP_STEREO``, ``_LANG1``, ``_LANG2`` or
0149 ``_SAP`` flag is cleared in the ``capability`` field, the
0150 corresponding ``V4L2_TUNER_SUB_`` flag must not be set here.
0151
0152 This field is valid only if this is the tuner of the current video
0153 input, or when the structure refers to a radio tuner.
0154 * - __u32
0155 - ``audmode``
0156 - :cspan:`1`
0157
0158 The selected audio mode, see :ref:`tuner-audmode` for valid
0159 values. The audio mode does not affect audio subprogram detection,
0160 and like a :ref:`control` it does not automatically
0161 change unless the requested mode is invalid or unsupported. See
0162 :ref:`tuner-matrix` for possible results when the selected and
0163 received audio programs do not match.
0164
0165 Currently this is the only field of struct
0166 struct :c:type:`v4l2_tuner` applications can change.
0167 * - __u32
0168 - ``signal``
0169 - :cspan:`1` The signal strength if known.
0170
0171 Ranging from 0 to 65535. Higher values indicate a better signal.
0172 * - __s32
0173 - ``afc``
0174 - :cspan:`1` Automatic frequency control.
0175
0176 When the ``afc`` value is negative, the frequency is too
0177 low, when positive too high.
0178 * - __u32
0179 - ``reserved``\ [4]
0180 - :cspan:`1` Reserved for future extensions.
0181
0182 Drivers and applications must set the array to zero.
0183
0184
0185 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
0186
0187 .. c:type:: v4l2_tuner_type
0188
0189 .. flat-table:: enum v4l2_tuner_type
0190 :header-rows: 0
0191 :stub-columns: 0
0192 :widths: 3 1 6
0193
0194 * - ``V4L2_TUNER_RADIO``
0195 - 1
0196 - Tuner supports radio
0197 * - ``V4L2_TUNER_ANALOG_TV``
0198 - 2
0199 - Tuner supports analog TV
0200 * - ``V4L2_TUNER_SDR``
0201 - 4
0202 - Tuner controls the A/D and/or D/A block of a
0203 Software Digital Radio (SDR)
0204 * - ``V4L2_TUNER_RF``
0205 - 5
0206 - Tuner controls the RF part of a Software Digital Radio (SDR)
0207
0208 .. tabularcolumns:: |p{7.0cm}|p{2.2cm}|p{8.1cm}|
0209
0210 .. _tuner-capability:
0211
0212 .. cssclass:: longtable
0213
0214 .. flat-table:: Tuner and Modulator Capability Flags
0215 :header-rows: 0
0216 :stub-columns: 0
0217 :widths: 3 1 4
0218
0219 * - ``V4L2_TUNER_CAP_LOW``
0220 - 0x0001
0221 - When set, tuning frequencies are expressed in units of 62.5 Hz
0222 instead of 62.5 kHz.
0223 * - ``V4L2_TUNER_CAP_NORM``
0224 - 0x0002
0225 - This is a multi-standard tuner; the video standard can or must be
0226 switched. (B/G PAL tuners for example are typically not considered
0227 multi-standard because the video standard is automatically
0228 determined from the frequency band.) The set of supported video
0229 standards is available from the struct
0230 :c:type:`v4l2_input` pointing to this tuner, see the
0231 description of ioctl :ref:`VIDIOC_ENUMINPUT`
0232 for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
0233 capability.
0234 * - ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
0235 - 0x0004
0236 - If set, then this tuner supports the hardware seek functionality
0237 where the seek stops when it reaches the end of the frequency
0238 range.
0239 * - ``V4L2_TUNER_CAP_HWSEEK_WRAP``
0240 - 0x0008
0241 - If set, then this tuner supports the hardware seek functionality
0242 where the seek wraps around when it reaches the end of the
0243 frequency range.
0244 * - ``V4L2_TUNER_CAP_STEREO``
0245 - 0x0010
0246 - Stereo audio reception is supported.
0247 * - ``V4L2_TUNER_CAP_LANG1``
0248 - 0x0040
0249 - Reception of the primary language of a bilingual audio program is
0250 supported. Bilingual audio is a feature of two-channel systems,
0251 transmitting the primary language monaural on the main audio
0252 carrier and a secondary language monaural on a second carrier.
0253 Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
0254 * - ``V4L2_TUNER_CAP_LANG2``
0255 - 0x0020
0256 - Reception of the secondary language of a bilingual audio program
0257 is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
0258 capability.
0259 * - ``V4L2_TUNER_CAP_SAP``
0260 - 0x0020
0261 - Reception of a secondary audio program is supported. This is a
0262 feature of the BTSC system which accompanies the NTSC video
0263 standard. Two audio carriers are available for mono or stereo
0264 transmissions of a primary language, and an independent third
0265 carrier for a monaural secondary language. Only
0266 ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
0267
0268 .. note::
0269
0270 The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
0271 flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
0272 supports the ``V4L2_STD_NTSC_M`` video standard.
0273 * - ``V4L2_TUNER_CAP_RDS``
0274 - 0x0080
0275 - RDS capture is supported. This capability is only valid for radio
0276 tuners.
0277 * - ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
0278 - 0x0100
0279 - The RDS data is passed as unparsed RDS blocks.
0280 * - ``V4L2_TUNER_CAP_RDS_CONTROLS``
0281 - 0x0200
0282 - The RDS data is parsed by the hardware and set via controls.
0283 * - ``V4L2_TUNER_CAP_FREQ_BANDS``
0284 - 0x0400
0285 - The :ref:`VIDIOC_ENUM_FREQ_BANDS`
0286 ioctl can be used to enumerate the available frequency bands.
0287 * - ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
0288 - 0x0800
0289 - The range to search when using the hardware seek functionality is
0290 programmable, see
0291 :ref:`VIDIOC_S_HW_FREQ_SEEK` for
0292 details.
0293 * - ``V4L2_TUNER_CAP_1HZ``
0294 - 0x1000
0295 - When set, tuning frequencies are expressed in units of 1 Hz
0296 instead of 62.5 kHz.
0297
0298
0299 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
0300
0301 .. _tuner-rxsubchans:
0302
0303 .. flat-table:: Tuner Audio Reception Flags
0304 :header-rows: 0
0305 :stub-columns: 0
0306 :widths: 3 1 4
0307
0308 * - ``V4L2_TUNER_SUB_MONO``
0309 - 0x0001
0310 - The tuner receives a mono audio signal.
0311 * - ``V4L2_TUNER_SUB_STEREO``
0312 - 0x0002
0313 - The tuner receives a stereo audio signal.
0314 * - ``V4L2_TUNER_SUB_LANG1``
0315 - 0x0008
0316 - The tuner receives the primary language of a bilingual audio
0317 signal. Drivers must clear this flag when the current video
0318 standard is ``V4L2_STD_NTSC_M``.
0319 * - ``V4L2_TUNER_SUB_LANG2``
0320 - 0x0004
0321 - The tuner receives the secondary language of a bilingual audio
0322 signal (or a second audio program).
0323 * - ``V4L2_TUNER_SUB_SAP``
0324 - 0x0004
0325 - The tuner receives a Second Audio Program.
0326
0327 .. note::
0328
0329 The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
0330 flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
0331 when the current video standard is ``V4L2_STD_NTSC_M``.
0332 * - ``V4L2_TUNER_SUB_RDS``
0333 - 0x0010
0334 - The tuner receives an RDS channel.
0335
0336
0337 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
0338
0339 .. _tuner-audmode:
0340
0341 .. flat-table:: Tuner Audio Modes
0342 :header-rows: 0
0343 :stub-columns: 0
0344 :widths: 3 1 4
0345
0346 * - ``V4L2_TUNER_MODE_MONO``
0347 - 0
0348 - Play mono audio. When the tuner receives a stereo signal this a
0349 down-mix of the left and right channel. When the tuner receives a
0350 bilingual or SAP signal this mode selects the primary language.
0351 * - ``V4L2_TUNER_MODE_STEREO``
0352 - 1
0353 - Play stereo audio. When the tuner receives bilingual audio it may
0354 play different languages on the left and right channel or the
0355 primary language is played on both channels.
0356
0357 Playing different languages in this mode is deprecated. New
0358 drivers should do this only in ``MODE_LANG1_LANG2``.
0359
0360 When the tuner receives no stereo signal or does not support
0361 stereo reception the driver shall fall back to ``MODE_MONO``.
0362 * - ``V4L2_TUNER_MODE_LANG1``
0363 - 3
0364 - Play the primary language, mono or stereo. Only
0365 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
0366 * - ``V4L2_TUNER_MODE_LANG2``
0367 - 2
0368 - Play the secondary language, mono. When the tuner receives no
0369 bilingual audio or SAP, or their reception is not supported the
0370 driver shall fall back to mono or stereo mode. Only
0371 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
0372 * - ``V4L2_TUNER_MODE_SAP``
0373 - 2
0374 - Play the Second Audio Program. When the tuner receives no
0375 bilingual audio or SAP, or their reception is not supported the
0376 driver shall fall back to mono or stereo mode. Only
0377 ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
0378
0379 .. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
0380 are synonyms.
0381 * - ``V4L2_TUNER_MODE_LANG1_LANG2``
0382 - 4
0383 - Play the primary language on the left channel, the secondary
0384 language on the right channel. When the tuner receives no
0385 bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
0386 ``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
0387 mode.
0388
0389 .. raw:: latex
0390
0391 \scriptsize
0392
0393 .. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|
0394
0395 .. _tuner-matrix:
0396
0397 .. flat-table:: Tuner Audio Matrix
0398 :header-rows: 2
0399 :stub-columns: 0
0400 :widths: 7 7 14 14 14 14
0401
0402 * -
0403 - :cspan:`4` Selected ``V4L2_TUNER_MODE_``
0404 * - Received ``V4L2_TUNER_SUB_``
0405 - ``MONO``
0406 - ``STEREO``
0407 - ``LANG1``
0408 - ``LANG2 = SAP``
0409 - ``LANG1_LANG2``\ [#f1]_
0410 * - ``MONO``
0411 - Mono
0412 - Mono/Mono
0413 - Mono
0414 - Mono
0415 - Mono/Mono
0416 * - ``MONO | SAP``
0417 - Mono
0418 - Mono/Mono
0419 - Mono
0420 - SAP
0421 - Mono/SAP (preferred) or Mono/Mono
0422 * - ``STEREO``
0423 - L+R
0424 - L/R
0425 - Stereo L/R (preferred) or Mono L+R
0426 - Stereo L/R (preferred) or Mono L+R
0427 - L/R (preferred) or L+R/L+R
0428 * - ``STEREO | SAP``
0429 - L+R
0430 - L/R
0431 - Stereo L/R (preferred) or Mono L+R
0432 - SAP
0433 - L+R/SAP (preferred) or L/R or L+R/L+R
0434 * - ``LANG1 | LANG2``
0435 - Language 1
0436 - Lang1/Lang2 (deprecated\ [#f2]_) or Lang1/Lang1
0437 - Language 1
0438 - Language 2
0439 - Lang1/Lang2 (preferred) or Lang1/Lang1
0440
0441 .. raw:: latex
0442
0443 \normalsize
0444
0445 Return Value
0446 ============
0447
0448 On success 0 is returned, on error -1 and the ``errno`` variable is set
0449 appropriately. The generic error codes are described at the
0450 :ref:`Generic Error Codes <gen-errors>` chapter.
0451
0452 EINVAL
0453 The struct :c:type:`v4l2_tuner` ``index`` is out of
0454 bounds.
0455
0456 .. [#f1]
0457 This mode has been added in Linux 2.6.17 and may not be supported by
0458 older drivers.
0459
0460 .. [#f2]
0461 Playback of both languages in ``MODE_STEREO`` is deprecated. In the
0462 future drivers should produce only the primary language in this mode.
0463 Applications should request ``MODE_LANG1_LANG2`` to record both
0464 languages or a stereo signal.