162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_G_MODULATOR:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci********************************************
762306a36Sopenharmony_ciioctl VIDIOC_G_MODULATOR, VIDIOC_S_MODULATOR
862306a36Sopenharmony_ci********************************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_G_MODULATOR - VIDIOC_S_MODULATOR - Get or set modulator attributes
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_G_MODULATOR
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_MODULATOR, struct v4l2_modulator *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_S_MODULATOR
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_MODULATOR, const struct v4l2_modulator *argp)``
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciArguments
2762306a36Sopenharmony_ci=========
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci``fd``
3062306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci``argp``
3362306a36Sopenharmony_ci    Pointer to struct :c:type:`v4l2_modulator`.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciDescription
3662306a36Sopenharmony_ci===========
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciTo query the attributes of a modulator applications initialize the
3962306a36Sopenharmony_ci``index`` field and zero out the ``reserved`` array of a struct
4062306a36Sopenharmony_ci:c:type:`v4l2_modulator` and call the
4162306a36Sopenharmony_ci:ref:`VIDIOC_G_MODULATOR <VIDIOC_G_MODULATOR>` ioctl with a pointer to this structure. Drivers
4262306a36Sopenharmony_cifill the rest of the structure or return an ``EINVAL`` error code when the
4362306a36Sopenharmony_ciindex is out of bounds. To enumerate all modulators applications shall
4462306a36Sopenharmony_cibegin at index zero, incrementing by one until the driver returns
4562306a36Sopenharmony_ciEINVAL.
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciModulators have two writable properties, an audio modulation set and the
4862306a36Sopenharmony_ciradio frequency. To change the modulated audio subprograms, applications
4962306a36Sopenharmony_ciinitialize the ``index`` and ``txsubchans`` fields and the ``reserved``
5062306a36Sopenharmony_ciarray and call the :ref:`VIDIOC_S_MODULATOR <VIDIOC_G_MODULATOR>` ioctl. Drivers may choose a
5162306a36Sopenharmony_cidifferent audio modulation if the request cannot be satisfied. However
5262306a36Sopenharmony_cithis is a write-only ioctl, it does not return the actual audio
5362306a36Sopenharmony_cimodulation selected.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci:ref:`SDR <sdr>` specific modulator types are ``V4L2_TUNER_SDR`` and
5662306a36Sopenharmony_ci``V4L2_TUNER_RF``. For SDR devices ``txsubchans`` field must be
5762306a36Sopenharmony_ciinitialized to zero. The term 'modulator' means SDR transmitter in this
5862306a36Sopenharmony_cicontext.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciTo change the radio frequency the
6162306a36Sopenharmony_ci:ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci.. tabularcolumns:: |p{2.9cm}|p{2.9cm}|p{5.8cm}|p{2.9cm}|p{2.4cm}|
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci.. c:type:: v4l2_modulator
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci.. flat-table:: struct v4l2_modulator
6862306a36Sopenharmony_ci    :header-rows:  0
6962306a36Sopenharmony_ci    :stub-columns: 0
7062306a36Sopenharmony_ci    :widths:       1 1 2 1 1
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci    * - __u32
7362306a36Sopenharmony_ci      - ``index``
7462306a36Sopenharmony_ci      - Identifies the modulator, set by the application.
7562306a36Sopenharmony_ci    * - __u8
7662306a36Sopenharmony_ci      - ``name``\ [32]
7762306a36Sopenharmony_ci      - Name of the modulator, a NUL-terminated ASCII string.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	This information is intended for the user.
8062306a36Sopenharmony_ci    * - __u32
8162306a36Sopenharmony_ci      - ``capability``
8262306a36Sopenharmony_ci      - Modulator capability flags. No flags are defined for this field,
8362306a36Sopenharmony_ci	the tuner flags in struct :c:type:`v4l2_tuner` are
8462306a36Sopenharmony_ci	used accordingly. The audio flags indicate the ability to encode
8562306a36Sopenharmony_ci	audio subprograms. They will *not* change for example with the
8662306a36Sopenharmony_ci	current video standard.
8762306a36Sopenharmony_ci    * - __u32
8862306a36Sopenharmony_ci      - ``rangelow``
8962306a36Sopenharmony_ci      - The lowest tunable frequency in units of 62.5 KHz, or if the
9062306a36Sopenharmony_ci	``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units of
9162306a36Sopenharmony_ci	62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ`` is
9262306a36Sopenharmony_ci	set, in units of 1 Hz.
9362306a36Sopenharmony_ci    * - __u32
9462306a36Sopenharmony_ci      - ``rangehigh``
9562306a36Sopenharmony_ci      - The highest tunable frequency in units of 62.5 KHz, or if the
9662306a36Sopenharmony_ci	``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units of
9762306a36Sopenharmony_ci	62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ`` is
9862306a36Sopenharmony_ci	set, in units of 1 Hz.
9962306a36Sopenharmony_ci    * - __u32
10062306a36Sopenharmony_ci      - ``txsubchans``
10162306a36Sopenharmony_ci      - With this field applications can determine how audio sub-carriers
10262306a36Sopenharmony_ci	shall be modulated. It contains a set of flags as defined in
10362306a36Sopenharmony_ci	:ref:`modulator-txsubchans`.
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci	.. note::
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	   The tuner ``rxsubchans`` flags  are reused, but the
10862306a36Sopenharmony_ci	   semantics are different. Video output devices
10962306a36Sopenharmony_ci	   are assumed to have an analog or PCM audio input with 1-3
11062306a36Sopenharmony_ci	   channels. The ``txsubchans`` flags select one or more channels
11162306a36Sopenharmony_ci	   for modulation, together with some audio subprogram indicator,
11262306a36Sopenharmony_ci	   for example, a stereo pilot tone.
11362306a36Sopenharmony_ci    * - __u32
11462306a36Sopenharmony_ci      - ``type``
11562306a36Sopenharmony_ci      - :cspan:`2` Type of the modulator, see :c:type:`v4l2_tuner_type`.
11662306a36Sopenharmony_ci    * - __u32
11762306a36Sopenharmony_ci      - ``reserved``\ [3]
11862306a36Sopenharmony_ci      - Reserved for future extensions.
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci	Drivers and applications must set the array to zero.
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci.. tabularcolumns:: |p{6.0cm}|p{2.0cm}|p{9.3cm}|
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci.. cssclass:: longtable
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci.. _modulator-txsubchans:
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci.. flat-table:: Modulator Audio Transmission Flags
12962306a36Sopenharmony_ci    :header-rows:  0
13062306a36Sopenharmony_ci    :stub-columns: 0
13162306a36Sopenharmony_ci    :widths:       3 1 4
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci    * - ``V4L2_TUNER_SUB_MONO``
13462306a36Sopenharmony_ci      - 0x0001
13562306a36Sopenharmony_ci      - Modulate channel 1 as mono audio, when the input has more
13662306a36Sopenharmony_ci	channels, a down-mix of channel 1 and 2. This flag does not
13762306a36Sopenharmony_ci	combine with ``V4L2_TUNER_SUB_STEREO`` or
13862306a36Sopenharmony_ci	``V4L2_TUNER_SUB_LANG1``.
13962306a36Sopenharmony_ci    * - ``V4L2_TUNER_SUB_STEREO``
14062306a36Sopenharmony_ci      - 0x0002
14162306a36Sopenharmony_ci      - Modulate channel 1 and 2 as left and right channel of a stereo
14262306a36Sopenharmony_ci	audio signal. When the input has only one channel or two channels
14362306a36Sopenharmony_ci	and ``V4L2_TUNER_SUB_SAP`` is also set, channel 1 is encoded as
14462306a36Sopenharmony_ci	left and right channel. This flag does not combine with
14562306a36Sopenharmony_ci	``V4L2_TUNER_SUB_MONO`` or ``V4L2_TUNER_SUB_LANG1``. When the
14662306a36Sopenharmony_ci	driver does not support stereo audio it shall fall back to mono.
14762306a36Sopenharmony_ci    * - ``V4L2_TUNER_SUB_LANG1``
14862306a36Sopenharmony_ci      - 0x0008
14962306a36Sopenharmony_ci      - Modulate channel 1 and 2 as primary and secondary language of a
15062306a36Sopenharmony_ci	bilingual audio signal. When the input has only one channel it is
15162306a36Sopenharmony_ci	used for both languages. It is not possible to encode the primary
15262306a36Sopenharmony_ci	or secondary language only. This flag does not combine with
15362306a36Sopenharmony_ci	``V4L2_TUNER_SUB_MONO``, ``V4L2_TUNER_SUB_STEREO`` or
15462306a36Sopenharmony_ci	``V4L2_TUNER_SUB_SAP``. If the hardware does not support the
15562306a36Sopenharmony_ci	respective audio matrix, or the current video standard does not
15662306a36Sopenharmony_ci	permit bilingual audio the :ref:`VIDIOC_S_MODULATOR <VIDIOC_G_MODULATOR>` ioctl shall
15762306a36Sopenharmony_ci	return an ``EINVAL`` error code and the driver shall fall back to mono
15862306a36Sopenharmony_ci	or stereo mode.
15962306a36Sopenharmony_ci    * - ``V4L2_TUNER_SUB_LANG2``
16062306a36Sopenharmony_ci      - 0x0004
16162306a36Sopenharmony_ci      - Same effect as ``V4L2_TUNER_SUB_SAP``.
16262306a36Sopenharmony_ci    * - ``V4L2_TUNER_SUB_SAP``
16362306a36Sopenharmony_ci      - 0x0004
16462306a36Sopenharmony_ci      - When combined with ``V4L2_TUNER_SUB_MONO`` the first channel is
16562306a36Sopenharmony_ci	encoded as mono audio, the last channel as Second Audio Program.
16662306a36Sopenharmony_ci	When the input has only one channel it is used for both audio
16762306a36Sopenharmony_ci	tracks. When the input has three channels the mono track is a
16862306a36Sopenharmony_ci	down-mix of channel 1 and 2. When combined with
16962306a36Sopenharmony_ci	``V4L2_TUNER_SUB_STEREO`` channel 1 and 2 are encoded as left and
17062306a36Sopenharmony_ci	right stereo audio, channel 3 as Second Audio Program. When the
17162306a36Sopenharmony_ci	input has only two channels, the first is encoded as left and
17262306a36Sopenharmony_ci	right channel and the second as SAP. When the input has only one
17362306a36Sopenharmony_ci	channel it is used for all audio tracks. It is not possible to
17462306a36Sopenharmony_ci	encode a Second Audio Program only. This flag must combine with
17562306a36Sopenharmony_ci	``V4L2_TUNER_SUB_MONO`` or ``V4L2_TUNER_SUB_STEREO``. If the
17662306a36Sopenharmony_ci	hardware does not support the respective audio matrix, or the
17762306a36Sopenharmony_ci	current video standard does not permit SAP the
17862306a36Sopenharmony_ci	:ref:`VIDIOC_S_MODULATOR <VIDIOC_G_MODULATOR>` ioctl shall return an ``EINVAL`` error code and
17962306a36Sopenharmony_ci	driver shall fall back to mono or stereo mode.
18062306a36Sopenharmony_ci    * - ``V4L2_TUNER_SUB_RDS``
18162306a36Sopenharmony_ci      - 0x0010
18262306a36Sopenharmony_ci      - Enable the RDS encoder for a radio FM transmitter.
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ciReturn Value
18562306a36Sopenharmony_ci============
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
18862306a36Sopenharmony_ciappropriately. The generic error codes are described at the
18962306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ciEINVAL
19262306a36Sopenharmony_ci    The struct :c:type:`v4l2_modulator` ``index`` is
19362306a36Sopenharmony_ci    out of bounds.
194