dvbproperty.rst 4.2 KB

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