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