dev-sdr.rst 3.7 KB

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