18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _VIDIOC_G_TUNER:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci************************************
78c2ecf20Sopenharmony_ciioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER
88c2ecf20Sopenharmony_ci************************************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciVIDIOC_G_TUNER - VIDIOC_S_TUNER - Get or set tuner attributes
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_G_TUNER
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_TUNER, struct v4l2_tuner *argp)``
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_S_TUNER
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_TUNER, const struct v4l2_tuner *argp)``
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciArguments
278c2ecf20Sopenharmony_ci=========
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci``fd``
308c2ecf20Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci``argp``
338c2ecf20Sopenharmony_ci    Pointer to struct :c:type:`v4l2_tuner`.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciDescription
368c2ecf20Sopenharmony_ci===========
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciTo query the attributes of a tuner applications initialize the ``index``
398c2ecf20Sopenharmony_cifield and zero out the ``reserved`` array of a struct
408c2ecf20Sopenharmony_ci:c:type:`v4l2_tuner` and call the ``VIDIOC_G_TUNER`` ioctl
418c2ecf20Sopenharmony_ciwith a pointer to this structure. Drivers fill the rest of the structure
428c2ecf20Sopenharmony_cior return an ``EINVAL`` error code when the index is out of bounds. To
438c2ecf20Sopenharmony_cienumerate all tuners applications shall begin at index zero,
448c2ecf20Sopenharmony_ciincrementing by one until the driver returns ``EINVAL``.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciTuners have two writable properties, the audio mode and the radio
478c2ecf20Sopenharmony_cifrequency. To change the audio mode, applications initialize the
488c2ecf20Sopenharmony_ci``index``, ``audmode`` and ``reserved`` fields and call the
498c2ecf20Sopenharmony_ci``VIDIOC_S_TUNER`` ioctl. This will *not* change the current tuner,
508c2ecf20Sopenharmony_ciwhich is determined by the current video input. Drivers may choose a
518c2ecf20Sopenharmony_cidifferent audio mode if the requested mode is invalid or unsupported.
528c2ecf20Sopenharmony_ciSince this is a write-only ioctl, it does not return the actually
538c2ecf20Sopenharmony_ciselected audio mode.
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci:ref:`SDR <sdr>` specific tuner types are ``V4L2_TUNER_SDR`` and
568c2ecf20Sopenharmony_ci``V4L2_TUNER_RF``. For SDR devices ``audmode`` field must be initialized
578c2ecf20Sopenharmony_cito zero. The term 'tuner' means SDR receiver in this context.
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciTo change the radio frequency the
608c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci .. tabularcolumns:: |p{1.3cm}|p{3.0cm}|p{6.6cm}|p{6.6cm}|
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci.. c:type:: v4l2_tuner
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci.. cssclass:: longtable
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_tuner
698c2ecf20Sopenharmony_ci    :header-rows:  0
708c2ecf20Sopenharmony_ci    :stub-columns: 0
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci    * - __u32
738c2ecf20Sopenharmony_ci      - ``index``
748c2ecf20Sopenharmony_ci      - :cspan:`1` Identifies the tuner, set by the application.
758c2ecf20Sopenharmony_ci    * - __u8
768c2ecf20Sopenharmony_ci      - ``name``\ [32]
778c2ecf20Sopenharmony_ci      - :cspan:`1`
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	Name of the tuner, a NUL-terminated ASCII string.
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	This information is intended for the user.
828c2ecf20Sopenharmony_ci    * - __u32
838c2ecf20Sopenharmony_ci      - ``type``
848c2ecf20Sopenharmony_ci      - :cspan:`1` Type of the tuner, see :c:type:`v4l2_tuner_type`.
858c2ecf20Sopenharmony_ci    * - __u32
868c2ecf20Sopenharmony_ci      - ``capability``
878c2ecf20Sopenharmony_ci      - :cspan:`1`
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	Tuner capability flags, see :ref:`tuner-capability`. Audio flags
908c2ecf20Sopenharmony_ci	indicate the ability to decode audio subprograms. They will *not*
918c2ecf20Sopenharmony_ci	change, for example with the current video standard.
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	When the structure refers to a radio tuner the
948c2ecf20Sopenharmony_ci	``V4L2_TUNER_CAP_LANG1``, ``V4L2_TUNER_CAP_LANG2`` and
958c2ecf20Sopenharmony_ci	``V4L2_TUNER_CAP_NORM`` flags can't be used.
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	If multiple frequency bands are supported, then ``capability`` is
988c2ecf20Sopenharmony_ci	the union of all ``capability`` fields of each struct
998c2ecf20Sopenharmony_ci	:c:type:`v4l2_frequency_band`.
1008c2ecf20Sopenharmony_ci    * - __u32
1018c2ecf20Sopenharmony_ci      - ``rangelow``
1028c2ecf20Sopenharmony_ci      - :cspan:`1` The lowest tunable frequency in units of 62.5 kHz, or
1038c2ecf20Sopenharmony_ci	if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units
1048c2ecf20Sopenharmony_ci	of 62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ``
1058c2ecf20Sopenharmony_ci	is set, in units of 1 Hz. If multiple frequency bands are
1068c2ecf20Sopenharmony_ci	supported, then ``rangelow`` is the lowest frequency of all the
1078c2ecf20Sopenharmony_ci	frequency bands.
1088c2ecf20Sopenharmony_ci    * - __u32
1098c2ecf20Sopenharmony_ci      - ``rangehigh``
1108c2ecf20Sopenharmony_ci      - :cspan:`1` The highest tunable frequency in units of 62.5 kHz,
1118c2ecf20Sopenharmony_ci	or if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in
1128c2ecf20Sopenharmony_ci	units of 62.5 Hz, or if the ``capability`` flag
1138c2ecf20Sopenharmony_ci	``V4L2_TUNER_CAP_1HZ`` is set, in units of 1 Hz. If multiple
1148c2ecf20Sopenharmony_ci	frequency bands are supported, then ``rangehigh`` is the highest
1158c2ecf20Sopenharmony_ci	frequency of all the frequency bands.
1168c2ecf20Sopenharmony_ci    * - __u32
1178c2ecf20Sopenharmony_ci      - ``rxsubchans``
1188c2ecf20Sopenharmony_ci      - :cspan:`1`
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	Some tuners or audio decoders can determine the received audio
1218c2ecf20Sopenharmony_ci	subprograms by analyzing audio carriers, pilot tones or other
1228c2ecf20Sopenharmony_ci	indicators. To pass this information drivers set flags defined in
1238c2ecf20Sopenharmony_ci	:ref:`tuner-rxsubchans` in this field. For example:
1248c2ecf20Sopenharmony_ci    * -
1258c2ecf20Sopenharmony_ci      -
1268c2ecf20Sopenharmony_ci      - ``V4L2_TUNER_SUB_MONO``
1278c2ecf20Sopenharmony_ci      - receiving mono audio
1288c2ecf20Sopenharmony_ci    * -
1298c2ecf20Sopenharmony_ci      -
1308c2ecf20Sopenharmony_ci      - ``STEREO | SAP``
1318c2ecf20Sopenharmony_ci      - receiving stereo audio and a secondary audio program
1328c2ecf20Sopenharmony_ci    * -
1338c2ecf20Sopenharmony_ci      -
1348c2ecf20Sopenharmony_ci      - ``MONO | STEREO``
1358c2ecf20Sopenharmony_ci      - receiving mono or stereo audio, the hardware cannot distinguish
1368c2ecf20Sopenharmony_ci    * -
1378c2ecf20Sopenharmony_ci      -
1388c2ecf20Sopenharmony_ci      - ``LANG1 | LANG2``
1398c2ecf20Sopenharmony_ci      - receiving bilingual audio
1408c2ecf20Sopenharmony_ci    * -
1418c2ecf20Sopenharmony_ci      -
1428c2ecf20Sopenharmony_ci      - ``MONO | STEREO | LANG1 | LANG2``
1438c2ecf20Sopenharmony_ci      - receiving mono, stereo or bilingual audio
1448c2ecf20Sopenharmony_ci    * -
1458c2ecf20Sopenharmony_ci      -
1468c2ecf20Sopenharmony_ci      - :cspan:`1`
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	When the ``V4L2_TUNER_CAP_STEREO``, ``_LANG1``, ``_LANG2`` or
1498c2ecf20Sopenharmony_ci	``_SAP`` flag is cleared in the ``capability`` field, the
1508c2ecf20Sopenharmony_ci	corresponding ``V4L2_TUNER_SUB_`` flag must not be set here.
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	This field is valid only if this is the tuner of the current video
1538c2ecf20Sopenharmony_ci	input, or when the structure refers to a radio tuner.
1548c2ecf20Sopenharmony_ci    * - __u32
1558c2ecf20Sopenharmony_ci      - ``audmode``
1568c2ecf20Sopenharmony_ci      - :cspan:`1`
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	The selected audio mode, see :ref:`tuner-audmode` for valid
1598c2ecf20Sopenharmony_ci	values. The audio mode does not affect audio subprogram detection,
1608c2ecf20Sopenharmony_ci	and like a :ref:`control` it does not automatically
1618c2ecf20Sopenharmony_ci	change unless the requested mode is invalid or unsupported. See
1628c2ecf20Sopenharmony_ci	:ref:`tuner-matrix` for possible results when the selected and
1638c2ecf20Sopenharmony_ci	received audio programs do not match.
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	Currently this is the only field of struct
1668c2ecf20Sopenharmony_ci	struct :c:type:`v4l2_tuner` applications can change.
1678c2ecf20Sopenharmony_ci    * - __u32
1688c2ecf20Sopenharmony_ci      - ``signal``
1698c2ecf20Sopenharmony_ci      - :cspan:`1` The signal strength if known.
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	Ranging from 0 to 65535. Higher values indicate a better signal.
1728c2ecf20Sopenharmony_ci    * - __s32
1738c2ecf20Sopenharmony_ci      - ``afc``
1748c2ecf20Sopenharmony_ci      - :cspan:`1` Automatic frequency control.
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	When the ``afc`` value is negative, the frequency is too
1778c2ecf20Sopenharmony_ci	low, when positive too high.
1788c2ecf20Sopenharmony_ci    * - __u32
1798c2ecf20Sopenharmony_ci      - ``reserved``\ [4]
1808c2ecf20Sopenharmony_ci      - :cspan:`1` Reserved for future extensions.
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	Drivers and applications must set the array to zero.
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci.. c:type:: v4l2_tuner_type
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci.. flat-table:: enum v4l2_tuner_type
1908c2ecf20Sopenharmony_ci    :header-rows:  0
1918c2ecf20Sopenharmony_ci    :stub-columns: 0
1928c2ecf20Sopenharmony_ci    :widths:       3 1 6
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_RADIO``
1958c2ecf20Sopenharmony_ci      - 1
1968c2ecf20Sopenharmony_ci      - Tuner supports radio
1978c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_ANALOG_TV``
1988c2ecf20Sopenharmony_ci      - 2
1998c2ecf20Sopenharmony_ci      - Tuner supports analog TV
2008c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SDR``
2018c2ecf20Sopenharmony_ci      - 4
2028c2ecf20Sopenharmony_ci      - Tuner controls the A/D and/or D/A block of a
2038c2ecf20Sopenharmony_ci	Software Digital Radio (SDR)
2048c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_RF``
2058c2ecf20Sopenharmony_ci      - 5
2068c2ecf20Sopenharmony_ci      - Tuner controls the RF part of a Software Digital Radio (SDR)
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci.. _tuner-capability:
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci.. cssclass:: longtable
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci.. flat-table:: Tuner and Modulator Capability Flags
2158c2ecf20Sopenharmony_ci    :header-rows:  0
2168c2ecf20Sopenharmony_ci    :stub-columns: 0
2178c2ecf20Sopenharmony_ci    :widths:       3 1 4
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_LOW``
2208c2ecf20Sopenharmony_ci      - 0x0001
2218c2ecf20Sopenharmony_ci      - When set, tuning frequencies are expressed in units of 62.5 Hz
2228c2ecf20Sopenharmony_ci	instead of 62.5 kHz.
2238c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_NORM``
2248c2ecf20Sopenharmony_ci      - 0x0002
2258c2ecf20Sopenharmony_ci      - This is a multi-standard tuner; the video standard can or must be
2268c2ecf20Sopenharmony_ci	switched. (B/G PAL tuners for example are typically not considered
2278c2ecf20Sopenharmony_ci	multi-standard because the video standard is automatically
2288c2ecf20Sopenharmony_ci	determined from the frequency band.) The set of supported video
2298c2ecf20Sopenharmony_ci	standards is available from the struct
2308c2ecf20Sopenharmony_ci	:c:type:`v4l2_input` pointing to this tuner, see the
2318c2ecf20Sopenharmony_ci	description of ioctl :ref:`VIDIOC_ENUMINPUT`
2328c2ecf20Sopenharmony_ci	for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
2338c2ecf20Sopenharmony_ci	capability.
2348c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
2358c2ecf20Sopenharmony_ci      - 0x0004
2368c2ecf20Sopenharmony_ci      - If set, then this tuner supports the hardware seek functionality
2378c2ecf20Sopenharmony_ci	where the seek stops when it reaches the end of the frequency
2388c2ecf20Sopenharmony_ci	range.
2398c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_HWSEEK_WRAP``
2408c2ecf20Sopenharmony_ci      - 0x0008
2418c2ecf20Sopenharmony_ci      - If set, then this tuner supports the hardware seek functionality
2428c2ecf20Sopenharmony_ci	where the seek wraps around when it reaches the end of the
2438c2ecf20Sopenharmony_ci	frequency range.
2448c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_STEREO``
2458c2ecf20Sopenharmony_ci      - 0x0010
2468c2ecf20Sopenharmony_ci      - Stereo audio reception is supported.
2478c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_LANG1``
2488c2ecf20Sopenharmony_ci      - 0x0040
2498c2ecf20Sopenharmony_ci      - Reception of the primary language of a bilingual audio program is
2508c2ecf20Sopenharmony_ci	supported. Bilingual audio is a feature of two-channel systems,
2518c2ecf20Sopenharmony_ci	transmitting the primary language monaural on the main audio
2528c2ecf20Sopenharmony_ci	carrier and a secondary language monaural on a second carrier.
2538c2ecf20Sopenharmony_ci	Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
2548c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_LANG2``
2558c2ecf20Sopenharmony_ci      - 0x0020
2568c2ecf20Sopenharmony_ci      - Reception of the secondary language of a bilingual audio program
2578c2ecf20Sopenharmony_ci	is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
2588c2ecf20Sopenharmony_ci	capability.
2598c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_SAP``
2608c2ecf20Sopenharmony_ci      - 0x0020
2618c2ecf20Sopenharmony_ci      - Reception of a secondary audio program is supported. This is a
2628c2ecf20Sopenharmony_ci	feature of the BTSC system which accompanies the NTSC video
2638c2ecf20Sopenharmony_ci	standard. Two audio carriers are available for mono or stereo
2648c2ecf20Sopenharmony_ci	transmissions of a primary language, and an independent third
2658c2ecf20Sopenharmony_ci	carrier for a monaural secondary language. Only
2668c2ecf20Sopenharmony_ci	``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci	.. note::
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	   The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
2718c2ecf20Sopenharmony_ci	   flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
2728c2ecf20Sopenharmony_ci	   supports the ``V4L2_STD_NTSC_M`` video standard.
2738c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_RDS``
2748c2ecf20Sopenharmony_ci      - 0x0080
2758c2ecf20Sopenharmony_ci      - RDS capture is supported. This capability is only valid for radio
2768c2ecf20Sopenharmony_ci	tuners.
2778c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
2788c2ecf20Sopenharmony_ci      - 0x0100
2798c2ecf20Sopenharmony_ci      - The RDS data is passed as unparsed RDS blocks.
2808c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_RDS_CONTROLS``
2818c2ecf20Sopenharmony_ci      - 0x0200
2828c2ecf20Sopenharmony_ci      - The RDS data is parsed by the hardware and set via controls.
2838c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_FREQ_BANDS``
2848c2ecf20Sopenharmony_ci      - 0x0400
2858c2ecf20Sopenharmony_ci      - The :ref:`VIDIOC_ENUM_FREQ_BANDS`
2868c2ecf20Sopenharmony_ci	ioctl can be used to enumerate the available frequency bands.
2878c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
2888c2ecf20Sopenharmony_ci      - 0x0800
2898c2ecf20Sopenharmony_ci      - The range to search when using the hardware seek functionality is
2908c2ecf20Sopenharmony_ci	programmable, see
2918c2ecf20Sopenharmony_ci	:ref:`VIDIOC_S_HW_FREQ_SEEK` for
2928c2ecf20Sopenharmony_ci	details.
2938c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_CAP_1HZ``
2948c2ecf20Sopenharmony_ci      - 0x1000
2958c2ecf20Sopenharmony_ci      - When set, tuning frequencies are expressed in units of 1 Hz
2968c2ecf20Sopenharmony_ci	instead of 62.5 kHz.
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci.. _tuner-rxsubchans:
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci.. flat-table:: Tuner Audio Reception Flags
3048c2ecf20Sopenharmony_ci    :header-rows:  0
3058c2ecf20Sopenharmony_ci    :stub-columns: 0
3068c2ecf20Sopenharmony_ci    :widths:       3 1 4
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_MONO``
3098c2ecf20Sopenharmony_ci      - 0x0001
3108c2ecf20Sopenharmony_ci      - The tuner receives a mono audio signal.
3118c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_STEREO``
3128c2ecf20Sopenharmony_ci      - 0x0002
3138c2ecf20Sopenharmony_ci      - The tuner receives a stereo audio signal.
3148c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_LANG1``
3158c2ecf20Sopenharmony_ci      - 0x0008
3168c2ecf20Sopenharmony_ci      - The tuner receives the primary language of a bilingual audio
3178c2ecf20Sopenharmony_ci	signal. Drivers must clear this flag when the current video
3188c2ecf20Sopenharmony_ci	standard is ``V4L2_STD_NTSC_M``.
3198c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_LANG2``
3208c2ecf20Sopenharmony_ci      - 0x0004
3218c2ecf20Sopenharmony_ci      - The tuner receives the secondary language of a bilingual audio
3228c2ecf20Sopenharmony_ci	signal (or a second audio program).
3238c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_SAP``
3248c2ecf20Sopenharmony_ci      - 0x0004
3258c2ecf20Sopenharmony_ci      - The tuner receives a Second Audio Program.
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci	.. note::
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci	   The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
3308c2ecf20Sopenharmony_ci	   flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
3318c2ecf20Sopenharmony_ci	   when the current video standard is ``V4L2_STD_NTSC_M``.
3328c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_RDS``
3338c2ecf20Sopenharmony_ci      - 0x0010
3348c2ecf20Sopenharmony_ci      - The tuner receives an RDS channel.
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci.. _tuner-audmode:
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci.. flat-table:: Tuner Audio Modes
3428c2ecf20Sopenharmony_ci    :header-rows:  0
3438c2ecf20Sopenharmony_ci    :stub-columns: 0
3448c2ecf20Sopenharmony_ci    :widths:       3 1 4
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_MODE_MONO``
3478c2ecf20Sopenharmony_ci      - 0
3488c2ecf20Sopenharmony_ci      - Play mono audio. When the tuner receives a stereo signal this a
3498c2ecf20Sopenharmony_ci	down-mix of the left and right channel. When the tuner receives a
3508c2ecf20Sopenharmony_ci	bilingual or SAP signal this mode selects the primary language.
3518c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_MODE_STEREO``
3528c2ecf20Sopenharmony_ci      - 1
3538c2ecf20Sopenharmony_ci      - Play stereo audio. When the tuner receives bilingual audio it may
3548c2ecf20Sopenharmony_ci	play different languages on the left and right channel or the
3558c2ecf20Sopenharmony_ci	primary language is played on both channels.
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci	Playing different languages in this mode is deprecated. New
3588c2ecf20Sopenharmony_ci	drivers should do this only in ``MODE_LANG1_LANG2``.
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	When the tuner receives no stereo signal or does not support
3618c2ecf20Sopenharmony_ci	stereo reception the driver shall fall back to ``MODE_MONO``.
3628c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_MODE_LANG1``
3638c2ecf20Sopenharmony_ci      - 3
3648c2ecf20Sopenharmony_ci      - Play the primary language, mono or stereo. Only
3658c2ecf20Sopenharmony_ci	``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
3668c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_MODE_LANG2``
3678c2ecf20Sopenharmony_ci      - 2
3688c2ecf20Sopenharmony_ci      - Play the secondary language, mono. When the tuner receives no
3698c2ecf20Sopenharmony_ci	bilingual audio or SAP, or their reception is not supported the
3708c2ecf20Sopenharmony_ci	driver shall fall back to mono or stereo mode. Only
3718c2ecf20Sopenharmony_ci	``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
3728c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_MODE_SAP``
3738c2ecf20Sopenharmony_ci      - 2
3748c2ecf20Sopenharmony_ci      - Play the Second Audio Program. When the tuner receives no
3758c2ecf20Sopenharmony_ci	bilingual audio or SAP, or their reception is not supported the
3768c2ecf20Sopenharmony_ci	driver shall fall back to mono or stereo mode. Only
3778c2ecf20Sopenharmony_ci	``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci	.. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
3808c2ecf20Sopenharmony_ci	   are synonyms.
3818c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_MODE_LANG1_LANG2``
3828c2ecf20Sopenharmony_ci      - 4
3838c2ecf20Sopenharmony_ci      - Play the primary language on the left channel, the secondary
3848c2ecf20Sopenharmony_ci	language on the right channel. When the tuner receives no
3858c2ecf20Sopenharmony_ci	bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
3868c2ecf20Sopenharmony_ci	``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
3878c2ecf20Sopenharmony_ci	mode.
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci.. raw:: latex
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci    \scriptsize
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci.. _tuner-matrix:
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci.. flat-table:: Tuner Audio Matrix
3988c2ecf20Sopenharmony_ci    :header-rows:  2
3998c2ecf20Sopenharmony_ci    :stub-columns: 0
4008c2ecf20Sopenharmony_ci    :widths: 7 7 14 14 14 14
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci    * -
4038c2ecf20Sopenharmony_ci      - :cspan:`4` Selected ``V4L2_TUNER_MODE_``
4048c2ecf20Sopenharmony_ci    * - Received ``V4L2_TUNER_SUB_``
4058c2ecf20Sopenharmony_ci      - ``MONO``
4068c2ecf20Sopenharmony_ci      - ``STEREO``
4078c2ecf20Sopenharmony_ci      - ``LANG1``
4088c2ecf20Sopenharmony_ci      - ``LANG2 = SAP``
4098c2ecf20Sopenharmony_ci      - ``LANG1_LANG2``\ [#f1]_
4108c2ecf20Sopenharmony_ci    * - ``MONO``
4118c2ecf20Sopenharmony_ci      - Mono
4128c2ecf20Sopenharmony_ci      - Mono/Mono
4138c2ecf20Sopenharmony_ci      - Mono
4148c2ecf20Sopenharmony_ci      - Mono
4158c2ecf20Sopenharmony_ci      - Mono/Mono
4168c2ecf20Sopenharmony_ci    * - ``MONO | SAP``
4178c2ecf20Sopenharmony_ci      - Mono
4188c2ecf20Sopenharmony_ci      - Mono/Mono
4198c2ecf20Sopenharmony_ci      - Mono
4208c2ecf20Sopenharmony_ci      - SAP
4218c2ecf20Sopenharmony_ci      - Mono/SAP (preferred) or Mono/Mono
4228c2ecf20Sopenharmony_ci    * - ``STEREO``
4238c2ecf20Sopenharmony_ci      - L+R
4248c2ecf20Sopenharmony_ci      - L/R
4258c2ecf20Sopenharmony_ci      - Stereo L/R (preferred) or Mono L+R
4268c2ecf20Sopenharmony_ci      - Stereo L/R (preferred) or Mono L+R
4278c2ecf20Sopenharmony_ci      - L/R (preferred) or L+R/L+R
4288c2ecf20Sopenharmony_ci    * - ``STEREO | SAP``
4298c2ecf20Sopenharmony_ci      - L+R
4308c2ecf20Sopenharmony_ci      - L/R
4318c2ecf20Sopenharmony_ci      - Stereo L/R (preferred) or Mono L+R
4328c2ecf20Sopenharmony_ci      - SAP
4338c2ecf20Sopenharmony_ci      - L+R/SAP (preferred) or L/R or L+R/L+R
4348c2ecf20Sopenharmony_ci    * - ``LANG1 | LANG2``
4358c2ecf20Sopenharmony_ci      - Language 1
4368c2ecf20Sopenharmony_ci      - Lang1/Lang2 (deprecated\ [#f2]_) or Lang1/Lang1
4378c2ecf20Sopenharmony_ci      - Language 1
4388c2ecf20Sopenharmony_ci      - Language 2
4398c2ecf20Sopenharmony_ci      - Lang1/Lang2 (preferred) or Lang1/Lang1
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci.. raw:: latex
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci    \normalsize
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ciReturn Value
4468c2ecf20Sopenharmony_ci============
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
4498c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the
4508c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ciEINVAL
4538c2ecf20Sopenharmony_ci    The struct :c:type:`v4l2_tuner` ``index`` is out of
4548c2ecf20Sopenharmony_ci    bounds.
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci.. [#f1]
4578c2ecf20Sopenharmony_ci   This mode has been added in Linux 2.6.17 and may not be supported by
4588c2ecf20Sopenharmony_ci   older drivers.
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci.. [#f2]
4618c2ecf20Sopenharmony_ci   Playback of both languages in ``MODE_STEREO`` is deprecated. In the
4628c2ecf20Sopenharmony_ci   future drivers should produce only the primary language in this mode.
4638c2ecf20Sopenharmony_ci   Applications should request ``MODE_LANG1_LANG2`` to record both
4648c2ecf20Sopenharmony_ci   languages or a stereo signal.
465