dev-sdr.rst 3.7 KB

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