desc_sat.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
  3. * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation version 2
  8. * of the License.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. *
  20. */
  21. /**
  22. * @file desc_sat.h
  23. * @ingroup descriptors
  24. * @brief Provides the descriptors for the satellite delivery system descriptor
  25. * @copyright GNU General Public License version 2 (GPLv2)
  26. * @author Mauro Carvalho Chehab
  27. * @author Andre Roth
  28. *
  29. * @par Relevant specs
  30. * The descriptor described herein is defined at:
  31. * - ETSI EN 300 468 V1.11.1
  32. *
  33. * @par Bug Report
  34. * Please submit bug reports and patches to linux-media@vger.kernel.org
  35. */
  36. #ifndef _SAT_H
  37. #define _SAT_H
  38. #include <libdvbv5/descriptors.h>
  39. /**
  40. * @struct dvb_desc_sat
  41. * @ingroup descriptors
  42. * @brief Structure containing the satellite delivery system descriptor
  43. *
  44. * @param type descriptor tag
  45. * @param length descriptor length
  46. * @param next pointer to struct dvb_desc
  47. * @param frequency frequency in kHz
  48. * @param orbit orbital position in degrees (multiplied by 10)
  49. * @param west_east west east flag. 0 = west, 1 = east
  50. * @param polarization polarization. 0 = horizontal, 1 = vertical,
  51. * 2 = left, 3 = right.
  52. * @param roll_off roll off alpha factor. 0 = 0.35, 1 = 0.25,
  53. * 2 = 0.20, 3 = reserved.
  54. * @param modulation_system modulation system. 0 = DVB-S, 1 = DVB-S2.
  55. * @param modulation_type modulation type. 0 = auto, 1 = QPSK, 2 = 8PSK,
  56. * 3 = 16-QAM (only for DVB-S2).
  57. * @param symbol_rate symbol rate in Kbauds.
  58. * @param fec inner FEC (convolutional code)
  59. */
  60. struct dvb_desc_sat {
  61. uint8_t type;
  62. uint8_t length;
  63. struct dvb_desc *next;
  64. uint32_t frequency;
  65. uint16_t orbit;
  66. uint8_t modulation_type:2;
  67. uint8_t modulation_system:1;
  68. uint8_t roll_off:2;
  69. uint8_t polarization:2;
  70. uint8_t west_east:1;
  71. union {
  72. uint32_t bitfield;
  73. struct {
  74. uint32_t fec:4;
  75. uint32_t symbol_rate:28;
  76. } __attribute__((packed));
  77. } __attribute__((packed));
  78. } __attribute__((packed));
  79. struct dvb_v5_fe_parms;
  80. #ifdef __cplusplus
  81. extern "C" {
  82. #endif
  83. /**
  84. * @brief Initializes and parses the satellite delivery system descriptor
  85. * @ingroup descriptors
  86. *
  87. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  88. * @param buf buffer containing the descriptor's raw data
  89. * @param desc pointer to struct dvb_desc to be allocated and filled
  90. *
  91. * This function initializes and makes sure that all fields will follow the CPU
  92. * endianness. Due to that, the content of the buffer may change.
  93. *
  94. * Currently, no memory is allocated internally.
  95. *
  96. * @return On success, it returns the size of the allocated struct.
  97. * A negative value indicates an error.
  98. */
  99. int dvb_desc_sat_init(struct dvb_v5_fe_parms *parms,
  100. const uint8_t *buf, struct dvb_desc *desc);
  101. /**
  102. * @brief Prints the content of the satellite delivery system descriptor
  103. * @ingroup descriptors
  104. *
  105. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  106. * @param desc pointer to struct dvb_desc
  107. */
  108. void dvb_desc_sat_print(struct dvb_v5_fe_parms *parms,
  109. const struct dvb_desc *desc);
  110. /**
  111. * @brief converts from the descriptor's FEC into enum fe_code_rate,
  112. * as defined by DVBv5 API.
  113. */
  114. extern const unsigned dvbs_dvbc_dvbs_freq_inner[];
  115. /**
  116. * @brief converts from the descriptor's polarization into
  117. * enum dvb_sat_polarization, as defined at dvb-v5-std.h.
  118. */
  119. extern const unsigned dvbs_polarization[];
  120. /**
  121. * @brief converts from the descriptor's rolloff into enum fe_rolloff,
  122. * as defined by DVBv5 API.
  123. */
  124. extern const unsigned dvbs_rolloff[];
  125. /**
  126. * @brief converts from the descriptor's modulation into enum fe_modulation,
  127. * as defined by DVBv5 API.
  128. */
  129. extern const unsigned dvbs_modulation[];
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif