1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun.. _frontend-properties: 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun************** 6*4882a593SmuzhiyunProperty types 7*4882a593Smuzhiyun************** 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunTuning into a Digital TV physical channel and starting decoding it 10*4882a593Smuzhiyunrequires changing a set of parameters, in order to control the tuner, 11*4882a593Smuzhiyunthe demodulator, the Linear Low-noise Amplifier (LNA) and to set the 12*4882a593Smuzhiyunantenna subsystem via Satellite Equipment Control - SEC (on satellite 13*4882a593Smuzhiyunsystems). The actual parameters are specific to each particular digital 14*4882a593SmuzhiyunTV standards, and may change as the digital TV specs evolves. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunIn the past (up to DVB API version 3 - DVBv3), the strategy used was to have a 17*4882a593Smuzhiyununion with the parameters needed to tune for DVB-S, DVB-C, DVB-T and 18*4882a593SmuzhiyunATSC delivery systems grouped there. The problem is that, as the second 19*4882a593Smuzhiyungeneration standards appeared, the size of such union was not big 20*4882a593Smuzhiyunenough to group the structs that would be required for those new 21*4882a593Smuzhiyunstandards. Also, extending it would break userspace. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunSo, the legacy union/struct based approach was deprecated, in favor 24*4882a593Smuzhiyunof a properties set approach. On such approach, 25*4882a593Smuzhiyun:ref:`FE_GET_PROPERTY and FE_SET_PROPERTY <FE_GET_PROPERTY>` are used 26*4882a593Smuzhiyunto setup the frontend and read its status. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunThe actual action is determined by a set of dtv_property cmd/data pairs. 29*4882a593SmuzhiyunWith one single ioctl, is possible to get/set up to 64 properties. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunThis section describes the new and recommended way to set the frontend, 32*4882a593Smuzhiyunwith supports all digital TV delivery systems. 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun.. note:: 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun 1. On Linux DVB API version 3, setting a frontend was done via 37*4882a593Smuzhiyun struct :c:type:`dvb_frontend_parameters`. 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun 2. Don't use DVB API version 3 calls on hardware with supports 40*4882a593Smuzhiyun newer standards. Such API provides no support or a very limited 41*4882a593Smuzhiyun support to new standards and/or new hardware. 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun 3. Nowadays, most frontends support multiple delivery systems. 44*4882a593Smuzhiyun Only with DVB API version 5 calls it is possible to switch between 45*4882a593Smuzhiyun the multiple delivery systems supported by a frontend. 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun 4. DVB API version 5 is also called *S2API*, as the first 48*4882a593Smuzhiyun new standard added to it was DVB-S2. 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun**Example**: in order to set the hardware to tune into a DVB-C channel 51*4882a593Smuzhiyunat 651 kHz, modulated with 256-QAM, FEC 3/4 and symbol rate of 5.217 52*4882a593SmuzhiyunMbauds, those properties should be sent to 53*4882a593Smuzhiyun:ref:`FE_SET_PROPERTY <FE_GET_PROPERTY>` ioctl: 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun :ref:`DTV_DELIVERY_SYSTEM <DTV-DELIVERY-SYSTEM>` = SYS_DVBC_ANNEX_A 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun :ref:`DTV_FREQUENCY <DTV-FREQUENCY>` = 651000000 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun :ref:`DTV_MODULATION <DTV-MODULATION>` = QAM_256 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun :ref:`DTV_INVERSION <DTV-INVERSION>` = INVERSION_AUTO 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun :ref:`DTV_SYMBOL_RATE <DTV-SYMBOL-RATE>` = 5217000 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun :ref:`DTV_INNER_FEC <DTV-INNER-FEC>` = FEC_3_4 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun :ref:`DTV_TUNE <DTV-TUNE>` 68*4882a593Smuzhiyun 69*4882a593SmuzhiyunThe code that would that would do the above is show in 70*4882a593Smuzhiyun:ref:`dtv-prop-example`. 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun.. code-block:: c 73*4882a593Smuzhiyun :caption: Example: Setting digital TV frontend properties 74*4882a593Smuzhiyun :name: dtv-prop-example 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun #include <stdio.h> 77*4882a593Smuzhiyun #include <fcntl.h> 78*4882a593Smuzhiyun #include <sys/ioctl.h> 79*4882a593Smuzhiyun #include <linux/dvb/frontend.h> 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun static struct dtv_property props[] = { 82*4882a593Smuzhiyun { .cmd = DTV_DELIVERY_SYSTEM, .u.data = SYS_DVBC_ANNEX_A }, 83*4882a593Smuzhiyun { .cmd = DTV_FREQUENCY, .u.data = 651000000 }, 84*4882a593Smuzhiyun { .cmd = DTV_MODULATION, .u.data = QAM_256 }, 85*4882a593Smuzhiyun { .cmd = DTV_INVERSION, .u.data = INVERSION_AUTO }, 86*4882a593Smuzhiyun { .cmd = DTV_SYMBOL_RATE, .u.data = 5217000 }, 87*4882a593Smuzhiyun { .cmd = DTV_INNER_FEC, .u.data = FEC_3_4 }, 88*4882a593Smuzhiyun { .cmd = DTV_TUNE } 89*4882a593Smuzhiyun }; 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun static struct dtv_properties dtv_prop = { 92*4882a593Smuzhiyun .num = 6, .props = props 93*4882a593Smuzhiyun }; 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun int main(void) 96*4882a593Smuzhiyun { 97*4882a593Smuzhiyun int fd = open("/dev/dvb/adapter0/frontend0", O_RDWR); 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun if (!fd) { 100*4882a593Smuzhiyun perror ("open"); 101*4882a593Smuzhiyun return -1; 102*4882a593Smuzhiyun } 103*4882a593Smuzhiyun if (ioctl(fd, FE_SET_PROPERTY, &dtv_prop) == -1) { 104*4882a593Smuzhiyun perror("ioctl"); 105*4882a593Smuzhiyun return -1; 106*4882a593Smuzhiyun } 107*4882a593Smuzhiyun printf("Frontend set\\n"); 108*4882a593Smuzhiyun return 0; 109*4882a593Smuzhiyun } 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun.. attention:: While it is possible to directly call the Kernel code like the 112*4882a593Smuzhiyun above example, it is strongly recommended to use 113*4882a593Smuzhiyun `libdvbv5 <https://linuxtv.org/docs/libdvbv5/index.html>`__, as it 114*4882a593Smuzhiyun provides abstraction to work with the supported digital TV standards and 115*4882a593Smuzhiyun provides methods for usual operations like program scanning and to 116*4882a593Smuzhiyun read/write channel descriptor files. 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun.. toctree:: 119*4882a593Smuzhiyun :maxdepth: 1 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun fe_property_parameters 122*4882a593Smuzhiyun frontend-stat-properties 123*4882a593Smuzhiyun frontend-property-terrestrial-systems 124*4882a593Smuzhiyun frontend-property-cable-systems 125*4882a593Smuzhiyun frontend-property-satellite-systems 126*4882a593Smuzhiyun frontend-header 127