18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
28c2ecf20Sopenharmony_ci.. c:namespace:: V4L
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci.. _rds:
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci*************
78c2ecf20Sopenharmony_ciRDS Interface
88c2ecf20Sopenharmony_ci*************
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciThe Radio Data System transmits supplementary information in binary
118c2ecf20Sopenharmony_ciformat, for example the station name or travel information, on an
128c2ecf20Sopenharmony_ciinaudible audio subcarrier of a radio program. This interface is aimed
138c2ecf20Sopenharmony_ciat devices capable of receiving and/or transmitting RDS information.
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciFor more information see the core RDS standard :ref:`iec62106` and the
168c2ecf20Sopenharmony_ciRBDS standard :ref:`nrsc4`.
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci.. note::
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci   Note that the RBDS standard as is used in the USA is almost
218c2ecf20Sopenharmony_ci   identical to the RDS standard. Any RDS decoder/encoder can also handle
228c2ecf20Sopenharmony_ci   RBDS. Only some of the fields have slightly different meanings. See the
238c2ecf20Sopenharmony_ci   RBDS standard for more information.
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ciThe RBDS standard also specifies support for MMBS (Modified Mobile
268c2ecf20Sopenharmony_ciSearch). This is a proprietary format which seems to be discontinued.
278c2ecf20Sopenharmony_ciThe RDS interface does not support this format. Should support for MMBS
288c2ecf20Sopenharmony_ci(or the so-called 'E blocks' in general) be needed, then please contact
298c2ecf20Sopenharmony_cithe linux-media mailing list:
308c2ecf20Sopenharmony_ci`https://linuxtv.org/lists.php <https://linuxtv.org/lists.php>`__.
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciQuerying Capabilities
338c2ecf20Sopenharmony_ci=====================
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciDevices supporting the RDS capturing API set the
368c2ecf20Sopenharmony_ci``V4L2_CAP_RDS_CAPTURE`` flag in the ``capabilities`` field of struct
378c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` returned by the
388c2ecf20Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. Any tuner that
398c2ecf20Sopenharmony_cisupports RDS will set the ``V4L2_TUNER_CAP_RDS`` flag in the
408c2ecf20Sopenharmony_ci``capability`` field of struct :c:type:`v4l2_tuner`. If the
418c2ecf20Sopenharmony_cidriver only passes RDS blocks without interpreting the data the
428c2ecf20Sopenharmony_ci``V4L2_TUNER_CAP_RDS_BLOCK_IO`` flag has to be set, see
438c2ecf20Sopenharmony_ci:ref:`Reading RDS data <reading-rds-data>`. For future use the flag
448c2ecf20Sopenharmony_ci``V4L2_TUNER_CAP_RDS_CONTROLS`` has also been defined. However, a driver
458c2ecf20Sopenharmony_cifor a radio tuner with this capability does not yet exist, so if you are
468c2ecf20Sopenharmony_ciplanning to write such a driver you should discuss this on the
478c2ecf20Sopenharmony_cilinux-media mailing list:
488c2ecf20Sopenharmony_ci`https://linuxtv.org/lists.php <https://linuxtv.org/lists.php>`__.
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciWhether an RDS signal is present can be detected by looking at the
518c2ecf20Sopenharmony_ci``rxsubchans`` field of struct :c:type:`v4l2_tuner`: the
528c2ecf20Sopenharmony_ci``V4L2_TUNER_SUB_RDS`` will be set if RDS data was detected.
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciDevices supporting the RDS output API set the ``V4L2_CAP_RDS_OUTPUT``
558c2ecf20Sopenharmony_ciflag in the ``capabilities`` field of struct
568c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` returned by the
578c2ecf20Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. Any modulator that
588c2ecf20Sopenharmony_cisupports RDS will set the ``V4L2_TUNER_CAP_RDS`` flag in the
598c2ecf20Sopenharmony_ci``capability`` field of struct
608c2ecf20Sopenharmony_ci:c:type:`v4l2_modulator`. In order to enable the RDS
618c2ecf20Sopenharmony_citransmission one must set the ``V4L2_TUNER_SUB_RDS`` bit in the
628c2ecf20Sopenharmony_ci``txsubchans`` field of struct
638c2ecf20Sopenharmony_ci:c:type:`v4l2_modulator`. If the driver only passes RDS
648c2ecf20Sopenharmony_ciblocks without interpreting the data the ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
658c2ecf20Sopenharmony_ciflag has to be set. If the tuner is capable of handling RDS entities
668c2ecf20Sopenharmony_cilike program identification codes and radio text, the flag
678c2ecf20Sopenharmony_ci``V4L2_TUNER_CAP_RDS_CONTROLS`` should be set, see
688c2ecf20Sopenharmony_ci:ref:`Writing RDS data <writing-rds-data>` and
698c2ecf20Sopenharmony_ci:ref:`FM Transmitter Control Reference <fm-tx-controls>`.
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci.. _reading-rds-data:
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ciReading RDS data
748c2ecf20Sopenharmony_ci================
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ciRDS data can be read from the radio device with the
778c2ecf20Sopenharmony_ci:c:func:`read()` function. The data is packed in groups of
788c2ecf20Sopenharmony_cithree bytes.
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci.. _writing-rds-data:
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ciWriting RDS data
838c2ecf20Sopenharmony_ci================
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciRDS data can be written to the radio device with the
868c2ecf20Sopenharmony_ci:c:func:`write()` function. The data is packed in groups of
878c2ecf20Sopenharmony_cithree bytes, as follows:
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciRDS datastructures
908c2ecf20Sopenharmony_ci==================
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci.. c:type:: v4l2_rds_data
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{2.5cm}|p{2.5cm}|p{12.5cm}|
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_rds_data
978c2ecf20Sopenharmony_ci    :header-rows:  0
988c2ecf20Sopenharmony_ci    :stub-columns: 0
998c2ecf20Sopenharmony_ci    :widths:       1 1 5
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci    * - __u8
1028c2ecf20Sopenharmony_ci      - ``lsb``
1038c2ecf20Sopenharmony_ci      - Least Significant Byte of RDS Block
1048c2ecf20Sopenharmony_ci    * - __u8
1058c2ecf20Sopenharmony_ci      - ``msb``
1068c2ecf20Sopenharmony_ci      - Most Significant Byte of RDS Block
1078c2ecf20Sopenharmony_ci    * - __u8
1088c2ecf20Sopenharmony_ci      - ``block``
1098c2ecf20Sopenharmony_ci      - Block description
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci.. _v4l2-rds-block:
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{2.9cm}|p{14.6cm}|
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci.. flat-table:: Block description
1178c2ecf20Sopenharmony_ci    :header-rows:  0
1188c2ecf20Sopenharmony_ci    :stub-columns: 0
1198c2ecf20Sopenharmony_ci    :widths:       1 5
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci    * - Bits 0-2
1228c2ecf20Sopenharmony_ci      - Block (aka offset) of the received data.
1238c2ecf20Sopenharmony_ci    * - Bits 3-5
1248c2ecf20Sopenharmony_ci      - Deprecated. Currently identical to bits 0-2. Do not use these
1258c2ecf20Sopenharmony_ci	bits.
1268c2ecf20Sopenharmony_ci    * - Bit 6
1278c2ecf20Sopenharmony_ci      - Corrected bit. Indicates that an error was corrected for this data
1288c2ecf20Sopenharmony_ci	block.
1298c2ecf20Sopenharmony_ci    * - Bit 7
1308c2ecf20Sopenharmony_ci      - Error bit. Indicates that an uncorrectable error occurred during
1318c2ecf20Sopenharmony_ci	reception of this block.
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci.. _v4l2-rds-block-codes:
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{6.4cm}|p{2.0cm}|p{1.2cm}|p{7.9cm}|
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci.. flat-table:: Block defines
1398c2ecf20Sopenharmony_ci    :header-rows:  0
1408c2ecf20Sopenharmony_ci    :stub-columns: 0
1418c2ecf20Sopenharmony_ci    :widths:       1 1 1 5
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_MSK
1448c2ecf20Sopenharmony_ci      -
1458c2ecf20Sopenharmony_ci      - 7
1468c2ecf20Sopenharmony_ci      - Mask for bits 0-2 to get the block ID.
1478c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_A
1488c2ecf20Sopenharmony_ci      -
1498c2ecf20Sopenharmony_ci      - 0
1508c2ecf20Sopenharmony_ci      - Block A.
1518c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_B
1528c2ecf20Sopenharmony_ci      -
1538c2ecf20Sopenharmony_ci      - 1
1548c2ecf20Sopenharmony_ci      - Block B.
1558c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_C
1568c2ecf20Sopenharmony_ci      -
1578c2ecf20Sopenharmony_ci      - 2
1588c2ecf20Sopenharmony_ci      - Block C.
1598c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_D
1608c2ecf20Sopenharmony_ci      -
1618c2ecf20Sopenharmony_ci      - 3
1628c2ecf20Sopenharmony_ci      - Block D.
1638c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_C_ALT
1648c2ecf20Sopenharmony_ci      -
1658c2ecf20Sopenharmony_ci      - 4
1668c2ecf20Sopenharmony_ci      - Block C'.
1678c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_INVALID
1688c2ecf20Sopenharmony_ci      - read-only
1698c2ecf20Sopenharmony_ci      - 7
1708c2ecf20Sopenharmony_ci      - An invalid block.
1718c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_CORRECTED
1728c2ecf20Sopenharmony_ci      - read-only
1738c2ecf20Sopenharmony_ci      - 0x40
1748c2ecf20Sopenharmony_ci      - A bit error was detected but corrected.
1758c2ecf20Sopenharmony_ci    * - V4L2_RDS_BLOCK_ERROR
1768c2ecf20Sopenharmony_ci      - read-only
1778c2ecf20Sopenharmony_ci      - 0x80
1788c2ecf20Sopenharmony_ci      - An uncorrectable error occurred.
179