18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci.. _sdr: 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci************************************** 68c2ecf20Sopenharmony_ciSoftware Defined Radio Interface (SDR) 78c2ecf20Sopenharmony_ci************************************** 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciSDR is an abbreviation of Software Defined Radio, the radio device which 108c2ecf20Sopenharmony_ciuses application software for modulation or demodulation. This interface 118c2ecf20Sopenharmony_ciis intended for controlling and data streaming of such devices. 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ciSDR devices are accessed through character device special files named 148c2ecf20Sopenharmony_ci``/dev/swradio0`` to ``/dev/swradio255`` with major number 81 and 158c2ecf20Sopenharmony_cidynamically allocated minor numbers 0 to 255. 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciQuerying Capabilities 198c2ecf20Sopenharmony_ci===================== 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciDevices supporting the SDR receiver interface set the 228c2ecf20Sopenharmony_ci``V4L2_CAP_SDR_CAPTURE`` and ``V4L2_CAP_TUNER`` flag in the 238c2ecf20Sopenharmony_ci``capabilities`` field of struct 248c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` returned by the 258c2ecf20Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. That flag means the 268c2ecf20Sopenharmony_cidevice has an Analog to Digital Converter (ADC), which is a mandatory 278c2ecf20Sopenharmony_cielement for the SDR receiver. 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciDevices supporting the SDR transmitter interface set the 308c2ecf20Sopenharmony_ci``V4L2_CAP_SDR_OUTPUT`` and ``V4L2_CAP_MODULATOR`` flag in the 318c2ecf20Sopenharmony_ci``capabilities`` field of struct 328c2ecf20Sopenharmony_ci:c:type:`v4l2_capability` returned by the 338c2ecf20Sopenharmony_ci:ref:`VIDIOC_QUERYCAP` ioctl. That flag means the 348c2ecf20Sopenharmony_cidevice has an Digital to Analog Converter (DAC), which is a mandatory 358c2ecf20Sopenharmony_cielement for the SDR transmitter. 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ciAt least one of the read/write, streaming or asynchronous I/O methods 388c2ecf20Sopenharmony_cimust be supported. 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciSupplemental Functions 428c2ecf20Sopenharmony_ci====================== 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciSDR devices can support :ref:`controls <control>`, and must support 458c2ecf20Sopenharmony_cithe :ref:`tuner` ioctls. Tuner ioctls are used for setting the 468c2ecf20Sopenharmony_ciADC/DAC sampling rate (sampling frequency) and the possible radio 478c2ecf20Sopenharmony_cifrequency (RF). 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciThe ``V4L2_TUNER_SDR`` tuner type is used for setting SDR device ADC/DAC 508c2ecf20Sopenharmony_cifrequency, and the ``V4L2_TUNER_RF`` tuner type is used for setting 518c2ecf20Sopenharmony_ciradio frequency. The tuner index of the RF tuner (if any) must always 528c2ecf20Sopenharmony_cifollow the SDR tuner index. Normally the SDR tuner is #0 and the RF 538c2ecf20Sopenharmony_cituner is #1. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciThe :ref:`VIDIOC_S_HW_FREQ_SEEK` ioctl is 568c2ecf20Sopenharmony_cinot supported. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciData Format Negotiation 608c2ecf20Sopenharmony_ci======================= 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciThe SDR device uses the :ref:`format` ioctls to select the 638c2ecf20Sopenharmony_cicapture and output format. Both the sampling resolution and the data 648c2ecf20Sopenharmony_cistreaming format are bound to that selectable format. In addition to the 658c2ecf20Sopenharmony_cibasic :ref:`format` ioctls, the 668c2ecf20Sopenharmony_ci:ref:`VIDIOC_ENUM_FMT` ioctl must be supported as 678c2ecf20Sopenharmony_ciwell. 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciTo use the :ref:`format` ioctls applications set the ``type`` 708c2ecf20Sopenharmony_cifield of a struct :c:type:`v4l2_format` to 718c2ecf20Sopenharmony_ci``V4L2_BUF_TYPE_SDR_CAPTURE`` or ``V4L2_BUF_TYPE_SDR_OUTPUT`` and use 728c2ecf20Sopenharmony_cithe struct :c:type:`v4l2_sdr_format` ``sdr`` member 738c2ecf20Sopenharmony_ciof the ``fmt`` union as needed per the desired operation. Currently 748c2ecf20Sopenharmony_cithere are two fields, ``pixelformat`` and ``buffersize``, of 758c2ecf20Sopenharmony_cistruct :c:type:`v4l2_sdr_format` which are used. 768c2ecf20Sopenharmony_ciContent of the ``pixelformat`` is V4L2 FourCC code of the data format. 778c2ecf20Sopenharmony_ciThe ``buffersize`` field is maximum buffer size in bytes required for 788c2ecf20Sopenharmony_cidata transfer, set by the driver in order to inform application. 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci.. c:type:: v4l2_sdr_format 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci.. flat-table:: struct v4l2_sdr_format 868c2ecf20Sopenharmony_ci :header-rows: 0 878c2ecf20Sopenharmony_ci :stub-columns: 0 888c2ecf20Sopenharmony_ci :widths: 1 1 2 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci * - __u32 918c2ecf20Sopenharmony_ci - ``pixelformat`` 928c2ecf20Sopenharmony_ci - The data format or type of compression, set by the application. 938c2ecf20Sopenharmony_ci This is a little endian 948c2ecf20Sopenharmony_ci :ref:`four character code <v4l2-fourcc>`. V4L2 defines SDR 958c2ecf20Sopenharmony_ci formats in :ref:`sdr-formats`. 968c2ecf20Sopenharmony_ci * - __u32 978c2ecf20Sopenharmony_ci - ``buffersize`` 988c2ecf20Sopenharmony_ci - Maximum size in bytes required for data. Value is set by the 998c2ecf20Sopenharmony_ci driver. 1008c2ecf20Sopenharmony_ci * - __u8 1018c2ecf20Sopenharmony_ci - ``reserved[24]`` 1028c2ecf20Sopenharmony_ci - This array is reserved for future extensions. Drivers and 1038c2ecf20Sopenharmony_ci applications must set it to zero. 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciAn SDR device may support :ref:`read/write <rw>` and/or streaming 1078c2ecf20Sopenharmony_ci(:ref:`memory mapping <mmap>` or :ref:`user pointer <userp>`) I/O. 108