18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci.. _frontend-properties: 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci************** 68c2ecf20Sopenharmony_ciProperty types 78c2ecf20Sopenharmony_ci************** 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciTuning into a Digital TV physical channel and starting decoding it 108c2ecf20Sopenharmony_cirequires changing a set of parameters, in order to control the tuner, 118c2ecf20Sopenharmony_cithe demodulator, the Linear Low-noise Amplifier (LNA) and to set the 128c2ecf20Sopenharmony_ciantenna subsystem via Satellite Equipment Control - SEC (on satellite 138c2ecf20Sopenharmony_cisystems). The actual parameters are specific to each particular digital 148c2ecf20Sopenharmony_ciTV standards, and may change as the digital TV specs evolves. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciIn the past (up to DVB API version 3 - DVBv3), the strategy used was to have a 178c2ecf20Sopenharmony_ciunion with the parameters needed to tune for DVB-S, DVB-C, DVB-T and 188c2ecf20Sopenharmony_ciATSC delivery systems grouped there. The problem is that, as the second 198c2ecf20Sopenharmony_cigeneration standards appeared, the size of such union was not big 208c2ecf20Sopenharmony_cienough to group the structs that would be required for those new 218c2ecf20Sopenharmony_cistandards. Also, extending it would break userspace. 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciSo, the legacy union/struct based approach was deprecated, in favor 248c2ecf20Sopenharmony_ciof a properties set approach. On such approach, 258c2ecf20Sopenharmony_ci:ref:`FE_GET_PROPERTY and FE_SET_PROPERTY <FE_GET_PROPERTY>` are used 268c2ecf20Sopenharmony_cito setup the frontend and read its status. 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ciThe actual action is determined by a set of dtv_property cmd/data pairs. 298c2ecf20Sopenharmony_ciWith one single ioctl, is possible to get/set up to 64 properties. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ciThis section describes the new and recommended way to set the frontend, 328c2ecf20Sopenharmony_ciwith supports all digital TV delivery systems. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci.. note:: 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci 1. On Linux DVB API version 3, setting a frontend was done via 378c2ecf20Sopenharmony_ci struct :c:type:`dvb_frontend_parameters`. 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci 2. Don't use DVB API version 3 calls on hardware with supports 408c2ecf20Sopenharmony_ci newer standards. Such API provides no support or a very limited 418c2ecf20Sopenharmony_ci support to new standards and/or new hardware. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci 3. Nowadays, most frontends support multiple delivery systems. 448c2ecf20Sopenharmony_ci Only with DVB API version 5 calls it is possible to switch between 458c2ecf20Sopenharmony_ci the multiple delivery systems supported by a frontend. 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci 4. DVB API version 5 is also called *S2API*, as the first 488c2ecf20Sopenharmony_ci new standard added to it was DVB-S2. 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci**Example**: in order to set the hardware to tune into a DVB-C channel 518c2ecf20Sopenharmony_ciat 651 kHz, modulated with 256-QAM, FEC 3/4 and symbol rate of 5.217 528c2ecf20Sopenharmony_ciMbauds, those properties should be sent to 538c2ecf20Sopenharmony_ci:ref:`FE_SET_PROPERTY <FE_GET_PROPERTY>` ioctl: 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci :ref:`DTV_DELIVERY_SYSTEM <DTV-DELIVERY-SYSTEM>` = SYS_DVBC_ANNEX_A 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci :ref:`DTV_FREQUENCY <DTV-FREQUENCY>` = 651000000 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci :ref:`DTV_MODULATION <DTV-MODULATION>` = QAM_256 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci :ref:`DTV_INVERSION <DTV-INVERSION>` = INVERSION_AUTO 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci :ref:`DTV_SYMBOL_RATE <DTV-SYMBOL-RATE>` = 5217000 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci :ref:`DTV_INNER_FEC <DTV-INNER-FEC>` = FEC_3_4 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci :ref:`DTV_TUNE <DTV-TUNE>` 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciThe code that would that would do the above is show in 708c2ecf20Sopenharmony_ci:ref:`dtv-prop-example`. 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci.. code-block:: c 738c2ecf20Sopenharmony_ci :caption: Example: Setting digital TV frontend properties 748c2ecf20Sopenharmony_ci :name: dtv-prop-example 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci #include <stdio.h> 778c2ecf20Sopenharmony_ci #include <fcntl.h> 788c2ecf20Sopenharmony_ci #include <sys/ioctl.h> 798c2ecf20Sopenharmony_ci #include <linux/dvb/frontend.h> 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci static struct dtv_property props[] = { 828c2ecf20Sopenharmony_ci { .cmd = DTV_DELIVERY_SYSTEM, .u.data = SYS_DVBC_ANNEX_A }, 838c2ecf20Sopenharmony_ci { .cmd = DTV_FREQUENCY, .u.data = 651000000 }, 848c2ecf20Sopenharmony_ci { .cmd = DTV_MODULATION, .u.data = QAM_256 }, 858c2ecf20Sopenharmony_ci { .cmd = DTV_INVERSION, .u.data = INVERSION_AUTO }, 868c2ecf20Sopenharmony_ci { .cmd = DTV_SYMBOL_RATE, .u.data = 5217000 }, 878c2ecf20Sopenharmony_ci { .cmd = DTV_INNER_FEC, .u.data = FEC_3_4 }, 888c2ecf20Sopenharmony_ci { .cmd = DTV_TUNE } 898c2ecf20Sopenharmony_ci }; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci static struct dtv_properties dtv_prop = { 928c2ecf20Sopenharmony_ci .num = 6, .props = props 938c2ecf20Sopenharmony_ci }; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci int main(void) 968c2ecf20Sopenharmony_ci { 978c2ecf20Sopenharmony_ci int fd = open("/dev/dvb/adapter0/frontend0", O_RDWR); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci if (!fd) { 1008c2ecf20Sopenharmony_ci perror ("open"); 1018c2ecf20Sopenharmony_ci return -1; 1028c2ecf20Sopenharmony_ci } 1038c2ecf20Sopenharmony_ci if (ioctl(fd, FE_SET_PROPERTY, &dtv_prop) == -1) { 1048c2ecf20Sopenharmony_ci perror("ioctl"); 1058c2ecf20Sopenharmony_ci return -1; 1068c2ecf20Sopenharmony_ci } 1078c2ecf20Sopenharmony_ci printf("Frontend set\\n"); 1088c2ecf20Sopenharmony_ci return 0; 1098c2ecf20Sopenharmony_ci } 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci.. attention:: While it is possible to directly call the Kernel code like the 1128c2ecf20Sopenharmony_ci above example, it is strongly recommended to use 1138c2ecf20Sopenharmony_ci `libdvbv5 <https://linuxtv.org/docs/libdvbv5/index.html>`__, as it 1148c2ecf20Sopenharmony_ci provides abstraction to work with the supported digital TV standards and 1158c2ecf20Sopenharmony_ci provides methods for usual operations like program scanning and to 1168c2ecf20Sopenharmony_ci read/write channel descriptor files. 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci.. toctree:: 1198c2ecf20Sopenharmony_ci :maxdepth: 1 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci fe_property_parameters 1228c2ecf20Sopenharmony_ci frontend-stat-properties 1238c2ecf20Sopenharmony_ci frontend-property-terrestrial-systems 1248c2ecf20Sopenharmony_ci frontend-property-cable-systems 1258c2ecf20Sopenharmony_ci frontend-property-satellite-systems 1268c2ecf20Sopenharmony_ci frontend-header 127