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