18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _VIDIOC_G_MODULATOR:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci********************************************
78c2ecf20Sopenharmony_ciioctl VIDIOC_G_MODULATOR, VIDIOC_S_MODULATOR
88c2ecf20Sopenharmony_ci********************************************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciName
118c2ecf20Sopenharmony_ci====
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciVIDIOC_G_MODULATOR - VIDIOC_S_MODULATOR - Get or set modulator attributes
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciSynopsis
168c2ecf20Sopenharmony_ci========
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_G_MODULATOR
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_G_MODULATOR, struct v4l2_modulator *argp)``
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci.. c:macro:: VIDIOC_S_MODULATOR
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci``int ioctl(int fd, VIDIOC_S_MODULATOR, const struct v4l2_modulator *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_modulator`.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciDescription
368c2ecf20Sopenharmony_ci===========
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciTo query the attributes of a modulator applications initialize the
398c2ecf20Sopenharmony_ci``index`` field and zero out the ``reserved`` array of a struct
408c2ecf20Sopenharmony_ci:c:type:`v4l2_modulator` and call the
418c2ecf20Sopenharmony_ci:ref:`VIDIOC_G_MODULATOR <VIDIOC_G_MODULATOR>` ioctl with a pointer to this structure. Drivers
428c2ecf20Sopenharmony_cifill the rest of the structure or return an ``EINVAL`` error code when the
438c2ecf20Sopenharmony_ciindex is out of bounds. To enumerate all modulators applications shall
448c2ecf20Sopenharmony_cibegin at index zero, incrementing by one until the driver returns
458c2ecf20Sopenharmony_ciEINVAL.
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciModulators have two writable properties, an audio modulation set and the
488c2ecf20Sopenharmony_ciradio frequency. To change the modulated audio subprograms, applications
498c2ecf20Sopenharmony_ciinitialize the ``index`` and ``txsubchans`` fields and the ``reserved``
508c2ecf20Sopenharmony_ciarray and call the :ref:`VIDIOC_S_MODULATOR <VIDIOC_G_MODULATOR>` ioctl. Drivers may choose a
518c2ecf20Sopenharmony_cidifferent audio modulation if the request cannot be satisfied. However
528c2ecf20Sopenharmony_cithis is a write-only ioctl, it does not return the actual audio
538c2ecf20Sopenharmony_cimodulation selected.
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci:ref:`SDR <sdr>` specific modulator types are ``V4L2_TUNER_SDR`` and
568c2ecf20Sopenharmony_ci``V4L2_TUNER_RF``. For SDR devices ``txsubchans`` field must be
578c2ecf20Sopenharmony_ciinitialized to zero. The term 'modulator' means SDR transmitter in this
588c2ecf20Sopenharmony_cicontext.
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciTo change the radio frequency the
618c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{2.9cm}|p{2.9cm}|p{5.8cm}|p{2.9cm}|p{3.0cm}|
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci.. c:type:: v4l2_modulator
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_modulator
688c2ecf20Sopenharmony_ci    :header-rows:  0
698c2ecf20Sopenharmony_ci    :stub-columns: 0
708c2ecf20Sopenharmony_ci    :widths:       1 1 2 1 1
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci    * - __u32
738c2ecf20Sopenharmony_ci      - ``index``
748c2ecf20Sopenharmony_ci      - Identifies the modulator, set by the application.
758c2ecf20Sopenharmony_ci    * - __u8
768c2ecf20Sopenharmony_ci      - ``name``\ [32]
778c2ecf20Sopenharmony_ci      - Name of the modulator, a NUL-terminated ASCII string.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	This information is intended for the user.
808c2ecf20Sopenharmony_ci    * - __u32
818c2ecf20Sopenharmony_ci      - ``capability``
828c2ecf20Sopenharmony_ci      - Modulator capability flags. No flags are defined for this field,
838c2ecf20Sopenharmony_ci	the tuner flags in struct :c:type:`v4l2_tuner` are
848c2ecf20Sopenharmony_ci	used accordingly. The audio flags indicate the ability to encode
858c2ecf20Sopenharmony_ci	audio subprograms. They will *not* change for example with the
868c2ecf20Sopenharmony_ci	current video standard.
878c2ecf20Sopenharmony_ci    * - __u32
888c2ecf20Sopenharmony_ci      - ``rangelow``
898c2ecf20Sopenharmony_ci      - The lowest tunable frequency in units of 62.5 KHz, or if the
908c2ecf20Sopenharmony_ci	``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units of
918c2ecf20Sopenharmony_ci	62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ`` is
928c2ecf20Sopenharmony_ci	set, in units of 1 Hz.
938c2ecf20Sopenharmony_ci    * - __u32
948c2ecf20Sopenharmony_ci      - ``rangehigh``
958c2ecf20Sopenharmony_ci      - The highest tunable frequency in units of 62.5 KHz, or if the
968c2ecf20Sopenharmony_ci	``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units of
978c2ecf20Sopenharmony_ci	62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ`` is
988c2ecf20Sopenharmony_ci	set, in units of 1 Hz.
998c2ecf20Sopenharmony_ci    * - __u32
1008c2ecf20Sopenharmony_ci      - ``txsubchans``
1018c2ecf20Sopenharmony_ci      - With this field applications can determine how audio sub-carriers
1028c2ecf20Sopenharmony_ci	shall be modulated. It contains a set of flags as defined in
1038c2ecf20Sopenharmony_ci	:ref:`modulator-txsubchans`.
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci	.. note::
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	   The tuner ``rxsubchans`` flags  are reused, but the
1088c2ecf20Sopenharmony_ci	   semantics are different. Video output devices
1098c2ecf20Sopenharmony_ci	   are assumed to have an analog or PCM audio input with 1-3
1108c2ecf20Sopenharmony_ci	   channels. The ``txsubchans`` flags select one or more channels
1118c2ecf20Sopenharmony_ci	   for modulation, together with some audio subprogram indicator,
1128c2ecf20Sopenharmony_ci	   for example, a stereo pilot tone.
1138c2ecf20Sopenharmony_ci    * - __u32
1148c2ecf20Sopenharmony_ci      - ``type``
1158c2ecf20Sopenharmony_ci      - :cspan:`2` Type of the modulator, see :c:type:`v4l2_tuner_type`.
1168c2ecf20Sopenharmony_ci    * - __u32
1178c2ecf20Sopenharmony_ci      - ``reserved``\ [3]
1188c2ecf20Sopenharmony_ci      - Reserved for future extensions.
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	Drivers and applications must set the array to zero.
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci.. _modulator-txsubchans:
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci.. flat-table:: Modulator Audio Transmission Flags
1288c2ecf20Sopenharmony_ci    :header-rows:  0
1298c2ecf20Sopenharmony_ci    :stub-columns: 0
1308c2ecf20Sopenharmony_ci    :widths:       3 1 4
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_MONO``
1338c2ecf20Sopenharmony_ci      - 0x0001
1348c2ecf20Sopenharmony_ci      - Modulate channel 1 as mono audio, when the input has more
1358c2ecf20Sopenharmony_ci	channels, a down-mix of channel 1 and 2. This flag does not
1368c2ecf20Sopenharmony_ci	combine with ``V4L2_TUNER_SUB_STEREO`` or
1378c2ecf20Sopenharmony_ci	``V4L2_TUNER_SUB_LANG1``.
1388c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_STEREO``
1398c2ecf20Sopenharmony_ci      - 0x0002
1408c2ecf20Sopenharmony_ci      - Modulate channel 1 and 2 as left and right channel of a stereo
1418c2ecf20Sopenharmony_ci	audio signal. When the input has only one channel or two channels
1428c2ecf20Sopenharmony_ci	and ``V4L2_TUNER_SUB_SAP`` is also set, channel 1 is encoded as
1438c2ecf20Sopenharmony_ci	left and right channel. This flag does not combine with
1448c2ecf20Sopenharmony_ci	``V4L2_TUNER_SUB_MONO`` or ``V4L2_TUNER_SUB_LANG1``. When the
1458c2ecf20Sopenharmony_ci	driver does not support stereo audio it shall fall back to mono.
1468c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_LANG1``
1478c2ecf20Sopenharmony_ci      - 0x0008
1488c2ecf20Sopenharmony_ci      - Modulate channel 1 and 2 as primary and secondary language of a
1498c2ecf20Sopenharmony_ci	bilingual audio signal. When the input has only one channel it is
1508c2ecf20Sopenharmony_ci	used for both languages. It is not possible to encode the primary
1518c2ecf20Sopenharmony_ci	or secondary language only. This flag does not combine with
1528c2ecf20Sopenharmony_ci	``V4L2_TUNER_SUB_MONO``, ``V4L2_TUNER_SUB_STEREO`` or
1538c2ecf20Sopenharmony_ci	``V4L2_TUNER_SUB_SAP``. If the hardware does not support the
1548c2ecf20Sopenharmony_ci	respective audio matrix, or the current video standard does not
1558c2ecf20Sopenharmony_ci	permit bilingual audio the :ref:`VIDIOC_S_MODULATOR <VIDIOC_G_MODULATOR>` ioctl shall
1568c2ecf20Sopenharmony_ci	return an ``EINVAL`` error code and the driver shall fall back to mono
1578c2ecf20Sopenharmony_ci	or stereo mode.
1588c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_LANG2``
1598c2ecf20Sopenharmony_ci      - 0x0004
1608c2ecf20Sopenharmony_ci      - Same effect as ``V4L2_TUNER_SUB_SAP``.
1618c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_SAP``
1628c2ecf20Sopenharmony_ci      - 0x0004
1638c2ecf20Sopenharmony_ci      - When combined with ``V4L2_TUNER_SUB_MONO`` the first channel is
1648c2ecf20Sopenharmony_ci	encoded as mono audio, the last channel as Second Audio Program.
1658c2ecf20Sopenharmony_ci	When the input has only one channel it is used for both audio
1668c2ecf20Sopenharmony_ci	tracks. When the input has three channels the mono track is a
1678c2ecf20Sopenharmony_ci	down-mix of channel 1 and 2. When combined with
1688c2ecf20Sopenharmony_ci	``V4L2_TUNER_SUB_STEREO`` channel 1 and 2 are encoded as left and
1698c2ecf20Sopenharmony_ci	right stereo audio, channel 3 as Second Audio Program. When the
1708c2ecf20Sopenharmony_ci	input has only two channels, the first is encoded as left and
1718c2ecf20Sopenharmony_ci	right channel and the second as SAP. When the input has only one
1728c2ecf20Sopenharmony_ci	channel it is used for all audio tracks. It is not possible to
1738c2ecf20Sopenharmony_ci	encode a Second Audio Program only. This flag must combine with
1748c2ecf20Sopenharmony_ci	``V4L2_TUNER_SUB_MONO`` or ``V4L2_TUNER_SUB_STEREO``. If the
1758c2ecf20Sopenharmony_ci	hardware does not support the respective audio matrix, or the
1768c2ecf20Sopenharmony_ci	current video standard does not permit SAP the
1778c2ecf20Sopenharmony_ci	:ref:`VIDIOC_S_MODULATOR <VIDIOC_G_MODULATOR>` ioctl shall return an ``EINVAL`` error code and
1788c2ecf20Sopenharmony_ci	driver shall fall back to mono or stereo mode.
1798c2ecf20Sopenharmony_ci    * - ``V4L2_TUNER_SUB_RDS``
1808c2ecf20Sopenharmony_ci      - 0x0010
1818c2ecf20Sopenharmony_ci      - Enable the RDS encoder for a radio FM transmitter.
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ciReturn Value
1848c2ecf20Sopenharmony_ci============
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
1878c2ecf20Sopenharmony_ciappropriately. The generic error codes are described at the
1888c2ecf20Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ciEINVAL
1918c2ecf20Sopenharmony_ci    The struct :c:type:`v4l2_modulator` ``index`` is
1928c2ecf20Sopenharmony_ci    out of bounds.
193