desc_t2_delivery.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation version 2
  7. * of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18. *
  19. * Based on ETSI EN 300 468 V1.11.1 (2010-04)
  20. */
  21. /**
  22. * @file desc_t2_delivery.h
  23. * @ingroup descriptors
  24. * @brief Provides the descriptors for the DVB-T2 delivery system descriptor
  25. * @copyright GNU General Public License version 2 (GPLv2)
  26. * @author Mauro Carvalho Chehab
  27. *
  28. * @par Relevant specs
  29. * The descriptor described herein is defined at:
  30. * - ETSI EN 300 468 V1.11.1
  31. *
  32. * @par Bug Report
  33. * Please submit bug reports and patches to linux-media@vger.kernel.org
  34. */
  35. #ifndef _T2_DELIVERY_H
  36. #define _T2_DELIVERY_H
  37. #include <libdvbv5/descriptors.h>
  38. /**
  39. * @struct dvb_desc_t2_delivery_subcell
  40. * @ingroup descriptors
  41. * @brief Structure to describe transponder subcell extension and frequencies
  42. *
  43. * @param cell_id_extension cell id extension
  44. * @param transposer_frequency transposer frequency
  45. */
  46. struct dvb_desc_t2_delivery_subcell {
  47. uint8_t cell_id_extension;
  48. uint16_t transposer_frequency;
  49. } __attribute__((packed));
  50. /**
  51. * @struct dvb_desc_t2_delivery
  52. * @ingroup descriptors
  53. * @brief Structure containing the T2 delivery system descriptor
  54. *
  55. * @param plp_id data PLP id
  56. * @param system_id T2 system id
  57. * @param SISO_MISO SISO MISO
  58. * @param bandwidth bandwidth
  59. * @param guard_interval guard interval
  60. * @param transmission_mode transmission mode
  61. * @param other_frequency_flag other frequency flag
  62. * @param tfs_flag tfs flag
  63. *
  64. * @param centre_frequency centre frequency vector
  65. * @param frequency_loop_length size of the dvb_desc_t2_delivery::centre_frequency
  66. * vector
  67. *
  68. * @param subcel_info_loop_length size of the dvb_desc_t2_delivery::subcell
  69. * vector
  70. * @param subcell pointer to struct dvb_desc_t2_delivery_subcell
  71. */
  72. struct dvb_desc_t2_delivery {
  73. /* extended descriptor */
  74. uint8_t plp_id;
  75. uint16_t system_id;
  76. union {
  77. uint16_t bitfield;
  78. struct {
  79. uint16_t tfs_flag:1;
  80. uint16_t other_frequency_flag:1;
  81. uint16_t transmission_mode:3;
  82. uint16_t guard_interval:3;
  83. uint16_t reserved:2;
  84. uint16_t bandwidth:3;
  85. uint16_t SISO_MISO:2;
  86. } __attribute__((packed));
  87. } __attribute__((packed));
  88. uint32_t *centre_frequency;
  89. uint8_t frequency_loop_length;
  90. uint8_t subcel_info_loop_length;
  91. struct dvb_desc_t2_delivery_subcell *subcell;
  92. } __attribute__((packed));
  93. struct dvb_v5_fe_parms;
  94. #ifdef __cplusplus
  95. extern "C" {
  96. #endif
  97. /**
  98. * @brief Initializes and parses the T2 delivery system descriptor
  99. * @ingroup descriptors
  100. *
  101. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  102. * @param buf buffer containing the descriptor's raw data
  103. * @param ext struct dvb_extension_descriptor pointer
  104. * @param desc pointer to struct dvb_desc to be allocated and filled
  105. *
  106. * This function allocates a the descriptor and fills the fields inside
  107. * the struct. It also makes sure that all fields will follow the CPU
  108. * endianness. Due to that, the content of the buffer may change.
  109. *
  110. * @return On success, it returns the size of the allocated struct.
  111. * A negative value indicates an error.
  112. */
  113. int dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
  114. const uint8_t *buf,
  115. struct dvb_extension_descriptor *ext,
  116. void *desc);
  117. /**
  118. * @brief Prints the content of the T2 delivery system descriptor
  119. * @ingroup descriptors
  120. *
  121. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  122. * @param ext struct dvb_extension_descriptor pointer
  123. * @param desc pointer to struct dvb_desc
  124. */
  125. void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms *parms,
  126. const struct dvb_extension_descriptor *ext,
  127. const void *desc);
  128. /**
  129. * @brief Frees all data allocated by the T2 delivery system descriptor
  130. * @ingroup descriptors
  131. *
  132. * @param desc pointer to struct dvb_desc to be freed
  133. */
  134. void dvb_desc_t2_delivery_free(const void *desc);
  135. /**
  136. * @brief converts from internal representation into bandwidth in Hz
  137. */
  138. extern const unsigned dvbt2_bw[];
  139. /**
  140. * @brief converts from internal representation into enum fe_guard_interval,
  141. * as defined at DVBv5 API.
  142. */
  143. extern const uint32_t dvbt2_interval[];
  144. /**
  145. * @brief converts from the descriptor's transmission mode into
  146. * enum fe_transmit_mode, as defined by DVBv5 API.
  147. */
  148. extern const unsigned dvbt2_transmission_mode[];
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152. #endif