^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) .. _sdr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) **************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Software Defined Radio Interface (SDR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) **************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) SDR is an abbreviation of Software Defined Radio, the radio device which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) uses application software for modulation or demodulation. This interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) is intended for controlling and data streaming of such devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) SDR devices are accessed through character device special files named
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) ``/dev/swradio0`` to ``/dev/swradio255`` with major number 81 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) dynamically allocated minor numbers 0 to 255.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) Querying Capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) =====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) Devices supporting the SDR receiver interface set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) ``V4L2_CAP_SDR_CAPTURE`` and ``V4L2_CAP_TUNER`` flag in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ``capabilities`` field of struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) :c:type:`v4l2_capability` returned by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) :ref:`VIDIOC_QUERYCAP` ioctl. That flag means the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) device has an Analog to Digital Converter (ADC), which is a mandatory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) element for the SDR receiver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Devices supporting the SDR transmitter interface set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ``V4L2_CAP_SDR_OUTPUT`` and ``V4L2_CAP_MODULATOR`` flag in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ``capabilities`` field of struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) :c:type:`v4l2_capability` returned by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) :ref:`VIDIOC_QUERYCAP` ioctl. That flag means the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) device has an Digital to Analog Converter (DAC), which is a mandatory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) element for the SDR transmitter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) At least one of the read/write, streaming or asynchronous I/O methods
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) must be supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Supplemental Functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) ======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) SDR devices can support :ref:`controls <control>`, and must support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) the :ref:`tuner` ioctls. Tuner ioctls are used for setting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ADC/DAC sampling rate (sampling frequency) and the possible radio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) frequency (RF).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) The ``V4L2_TUNER_SDR`` tuner type is used for setting SDR device ADC/DAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) frequency, and the ``V4L2_TUNER_RF`` tuner type is used for setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) radio frequency. The tuner index of the RF tuner (if any) must always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) follow the SDR tuner index. Normally the SDR tuner is #0 and the RF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) tuner is #1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) The :ref:`VIDIOC_S_HW_FREQ_SEEK` ioctl is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) not supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Data Format Negotiation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) =======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) The SDR device uses the :ref:`format` ioctls to select the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) capture and output format. Both the sampling resolution and the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) streaming format are bound to that selectable format. In addition to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) basic :ref:`format` ioctls, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) :ref:`VIDIOC_ENUM_FMT` ioctl must be supported as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) To use the :ref:`format` ioctls applications set the ``type``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) field of a struct :c:type:`v4l2_format` to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ``V4L2_BUF_TYPE_SDR_CAPTURE`` or ``V4L2_BUF_TYPE_SDR_OUTPUT`` and use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) the struct :c:type:`v4l2_sdr_format` ``sdr`` member
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) of the ``fmt`` union as needed per the desired operation. Currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) there are two fields, ``pixelformat`` and ``buffersize``, of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct :c:type:`v4l2_sdr_format` which are used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) Content of the ``pixelformat`` is V4L2 FourCC code of the data format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) The ``buffersize`` field is maximum buffer size in bytes required for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) data transfer, set by the driver in order to inform application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .. c:type:: v4l2_sdr_format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .. flat-table:: struct v4l2_sdr_format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) :widths: 1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) - ``pixelformat``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) - The data format or type of compression, set by the application.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) This is a little endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) :ref:`four character code <v4l2-fourcc>`. V4L2 defines SDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) formats in :ref:`sdr-formats`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) - ``buffersize``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) - Maximum size in bytes required for data. Value is set by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * - __u8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) - ``reserved[24]``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) - This array is reserved for future extensions. Drivers and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) applications must set it to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) An SDR device may support :ref:`read/write <rw>` and/or streaming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) (:ref:`memory mapping <mmap>` or :ref:`user pointer <userp>`) I/O.