162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _rds:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci*************
762306a36Sopenharmony_ciRDS Interface
862306a36Sopenharmony_ci*************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciThe Radio Data System transmits supplementary information in binary
1162306a36Sopenharmony_ciformat, for example the station name or travel information, on an
1262306a36Sopenharmony_ciinaudible audio subcarrier of a radio program. This interface is aimed
1362306a36Sopenharmony_ciat devices capable of receiving and/or transmitting RDS information.
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciFor more information see the core RDS standard :ref:`iec62106` and the
1662306a36Sopenharmony_ciRBDS standard :ref:`nrsc4`.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. note::
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci   Note that the RBDS standard as is used in the USA is almost
2162306a36Sopenharmony_ci   identical to the RDS standard. Any RDS decoder/encoder can also handle
2262306a36Sopenharmony_ci   RBDS. Only some of the fields have slightly different meanings. See the
2362306a36Sopenharmony_ci   RBDS standard for more information.
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciThe RBDS standard also specifies support for MMBS (Modified Mobile
2662306a36Sopenharmony_ciSearch). This is a proprietary format which seems to be discontinued.
2762306a36Sopenharmony_ciThe RDS interface does not support this format. Should support for MMBS
2862306a36Sopenharmony_ci(or the so-called 'E blocks' in general) be needed, then please contact
2962306a36Sopenharmony_cithe linux-media mailing list:
3062306a36Sopenharmony_ci`https://linuxtv.org/lists.php <https://linuxtv.org/lists.php>`__.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciQuerying Capabilities
3362306a36Sopenharmony_ci=====================
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciDevices supporting the RDS capturing API set the
3662306a36Sopenharmony_ci``V4L2_CAP_RDS_CAPTURE`` flag in the ``capabilities`` field of struct
3762306a36Sopenharmony_ci:c:type:`v4l2_capability` returned by the
3862306a36Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. Any tuner that
3962306a36Sopenharmony_cisupports RDS will set the ``V4L2_TUNER_CAP_RDS`` flag in the
4062306a36Sopenharmony_ci``capability`` field of struct :c:type:`v4l2_tuner`. If the
4162306a36Sopenharmony_cidriver only passes RDS blocks without interpreting the data the
4262306a36Sopenharmony_ci``V4L2_TUNER_CAP_RDS_BLOCK_IO`` flag has to be set, see
4362306a36Sopenharmony_ci:ref:`Reading RDS data <reading-rds-data>`. For future use the flag
4462306a36Sopenharmony_ci``V4L2_TUNER_CAP_RDS_CONTROLS`` has also been defined. However, a driver
4562306a36Sopenharmony_cifor a radio tuner with this capability does not yet exist, so if you are
4662306a36Sopenharmony_ciplanning to write such a driver you should discuss this on the
4762306a36Sopenharmony_cilinux-media mailing list:
4862306a36Sopenharmony_ci`https://linuxtv.org/lists.php <https://linuxtv.org/lists.php>`__.
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciWhether an RDS signal is present can be detected by looking at the
5162306a36Sopenharmony_ci``rxsubchans`` field of struct :c:type:`v4l2_tuner`: the
5262306a36Sopenharmony_ci``V4L2_TUNER_SUB_RDS`` will be set if RDS data was detected.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciDevices supporting the RDS output API set the ``V4L2_CAP_RDS_OUTPUT``
5562306a36Sopenharmony_ciflag in the ``capabilities`` field of struct
5662306a36Sopenharmony_ci:c:type:`v4l2_capability` returned by the
5762306a36Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. Any modulator that
5862306a36Sopenharmony_cisupports RDS will set the ``V4L2_TUNER_CAP_RDS`` flag in the
5962306a36Sopenharmony_ci``capability`` field of struct
6062306a36Sopenharmony_ci:c:type:`v4l2_modulator`. In order to enable the RDS
6162306a36Sopenharmony_citransmission one must set the ``V4L2_TUNER_SUB_RDS`` bit in the
6262306a36Sopenharmony_ci``txsubchans`` field of struct
6362306a36Sopenharmony_ci:c:type:`v4l2_modulator`. If the driver only passes RDS
6462306a36Sopenharmony_ciblocks without interpreting the data the ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
6562306a36Sopenharmony_ciflag has to be set. If the tuner is capable of handling RDS entities
6662306a36Sopenharmony_cilike program identification codes and radio text, the flag
6762306a36Sopenharmony_ci``V4L2_TUNER_CAP_RDS_CONTROLS`` should be set, see
6862306a36Sopenharmony_ci:ref:`Writing RDS data <writing-rds-data>` and
6962306a36Sopenharmony_ci:ref:`FM Transmitter Control Reference <fm-tx-controls>`.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci.. _reading-rds-data:
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciReading RDS data
7462306a36Sopenharmony_ci================
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciRDS data can be read from the radio device with the
7762306a36Sopenharmony_ci:c:func:`read()` function. The data is packed in groups of
7862306a36Sopenharmony_cithree bytes.
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci.. _writing-rds-data:
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciWriting RDS data
8362306a36Sopenharmony_ci================
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ciRDS data can be written to the radio device with the
8662306a36Sopenharmony_ci:c:func:`write()` function. The data is packed in groups of
8762306a36Sopenharmony_cithree bytes, as follows:
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciRDS datastructures
9062306a36Sopenharmony_ci==================
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci.. c:type:: v4l2_rds_data
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci.. flat-table:: struct v4l2_rds_data
9562306a36Sopenharmony_ci    :header-rows:  0
9662306a36Sopenharmony_ci    :stub-columns: 0
9762306a36Sopenharmony_ci    :widths:       1 1 5
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci    * - __u8
10062306a36Sopenharmony_ci      - ``lsb``
10162306a36Sopenharmony_ci      - Least Significant Byte of RDS Block
10262306a36Sopenharmony_ci    * - __u8
10362306a36Sopenharmony_ci      - ``msb``
10462306a36Sopenharmony_ci      - Most Significant Byte of RDS Block
10562306a36Sopenharmony_ci    * - __u8
10662306a36Sopenharmony_ci      - ``block``
10762306a36Sopenharmony_ci      - Block description
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci.. _v4l2-rds-block:
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci.. tabularcolumns:: |p{2.9cm}|p{14.6cm}|
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci.. flat-table:: Block description
11562306a36Sopenharmony_ci    :header-rows:  0
11662306a36Sopenharmony_ci    :stub-columns: 0
11762306a36Sopenharmony_ci    :widths:       1 5
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci    * - Bits 0-2
12062306a36Sopenharmony_ci      - Block (aka offset) of the received data.
12162306a36Sopenharmony_ci    * - Bits 3-5
12262306a36Sopenharmony_ci      - Deprecated. Currently identical to bits 0-2. Do not use these
12362306a36Sopenharmony_ci	bits.
12462306a36Sopenharmony_ci    * - Bit 6
12562306a36Sopenharmony_ci      - Corrected bit. Indicates that an error was corrected for this data
12662306a36Sopenharmony_ci	block.
12762306a36Sopenharmony_ci    * - Bit 7
12862306a36Sopenharmony_ci      - Error bit. Indicates that an uncorrectable error occurred during
12962306a36Sopenharmony_ci	reception of this block.
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci.. _v4l2-rds-block-codes:
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci.. tabularcolumns:: |p{6.4cm}|p{2.0cm}|p{1.2cm}|p{7.0cm}|
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci.. flat-table:: Block defines
13762306a36Sopenharmony_ci    :header-rows:  0
13862306a36Sopenharmony_ci    :stub-columns: 0
13962306a36Sopenharmony_ci    :widths:       1 1 1 5
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_MSK
14262306a36Sopenharmony_ci      -
14362306a36Sopenharmony_ci      - 7
14462306a36Sopenharmony_ci      - Mask for bits 0-2 to get the block ID.
14562306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_A
14662306a36Sopenharmony_ci      -
14762306a36Sopenharmony_ci      - 0
14862306a36Sopenharmony_ci      - Block A.
14962306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_B
15062306a36Sopenharmony_ci      -
15162306a36Sopenharmony_ci      - 1
15262306a36Sopenharmony_ci      - Block B.
15362306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_C
15462306a36Sopenharmony_ci      -
15562306a36Sopenharmony_ci      - 2
15662306a36Sopenharmony_ci      - Block C.
15762306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_D
15862306a36Sopenharmony_ci      -
15962306a36Sopenharmony_ci      - 3
16062306a36Sopenharmony_ci      - Block D.
16162306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_C_ALT
16262306a36Sopenharmony_ci      -
16362306a36Sopenharmony_ci      - 4
16462306a36Sopenharmony_ci      - Block C'.
16562306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_INVALID
16662306a36Sopenharmony_ci      - read-only
16762306a36Sopenharmony_ci      - 7
16862306a36Sopenharmony_ci      - An invalid block.
16962306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_CORRECTED
17062306a36Sopenharmony_ci      - read-only
17162306a36Sopenharmony_ci      - 0x40
17262306a36Sopenharmony_ci      - A bit error was detected but corrected.
17362306a36Sopenharmony_ci    * - V4L2_RDS_BLOCK_ERROR
17462306a36Sopenharmony_ci      - read-only
17562306a36Sopenharmony_ci      - 0x80
17662306a36Sopenharmony_ci      - An uncorrectable error occurred.
177