Debian Codegraph @

lib/include/libdvbv5/desc_t2_delivery.h

raw
1 /*
2 * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation version 2.1 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17 *
18 * Based on ETSI EN 300 468 V1.11.1 (2010-04)
19 */
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 Lesser General Public License version 2.1 (LGPLv2.1)
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 [email protected]
34 */
35
36 #ifndef _T2_DELIVERY_H
37 #define _T2_DELIVERY_H
38
39 #include <libdvbv5/descriptors.h>
40
41 /**
42 * @struct dvb_desc_t2_delivery_subcell_old
43 * @ingroup descriptors
44 * @brief Structure to describe transponder subcell extension and frequencies
45 *
46 * @param cell_id_extension cell id extension
47 * @param transposer_frequency transposer frequency
48 *
49 * NOTE: This struct is deprecated and will never be filled.
50 * It is kept here just to avoid breaking ABI.
51 *
52 * All subcell transposer frequencies will be added to
53 * dvb_desc_t2_delivery::centre_frequency array.
54 */
55 struct dvb_desc_t2_delivery_subcell_old {
56 uint8_t cell_id_extension;
57 uint16_t transposer_frequency; // Should be 32 bits, instead
58 } __attribute__((packed));
59
60
61 /**
62 * @struct dvb_desc_t2_delivery_subcell
63 * @ingroup descriptors
64 * @brief Structure to describe transponder subcell extension and frequencies
65 *
66 * @param cell_id_extension cell id extension
67 * @param transposer_frequency pointer to transposer frequency
68 */
69 struct dvb_desc_t2_delivery_subcell {
70 uint8_t cell_id_extension;
71 uint32_t transposer_frequency;
72 } __attribute__((packed));
73
74
75 /**
76 * @struct dvb_desc_t2_delivery_cell
77 * @ingroup descriptors
78 * @brief Structure to describe transponder cells
79 *
80 * @param cell_id cell id extension
81 * @param num_freqs number of cell frequencies
82 * @param centre_frequency pointer to centre frequencies
83 * @param subcel_length number of subcells. May be zero
84 * @param subcell pointer to subcell array. May be NULL
85 */
86 struct dvb_desc_t2_delivery_cell {
87 uint16_t cell_id;
88 int num_freqs;
89 uint32_t *centre_frequency;
90 uint8_t subcel_length;
91 struct dvb_desc_t2_delivery_subcell *subcel;
92 } __attribute__((packed));
93
94 /**
95 * @struct dvb_desc_t2_delivery
96 * @ingroup descriptors
97 * @brief Structure containing the T2 delivery system descriptor
98 *
99 * @param plp_id data PLP id
100 * @param system_id T2 system id
101 * @param SISO_MISO SISO MISO
102 * @param bandwidth bandwidth
103 * @param guard_interval guard interval
104 * @param transmission_mode transmission mode
105 * @param other_frequency_flag other frequency flag
106 * @param tfs_flag tfs flag
107 *
108 * @param centre_frequency centre frequency vector. It contains the full
109 * frequencies for all cells and subcells.
110 * @param frequency_loop_length size of the dvb_desc_t2_delivery::centre_frequency
111 * vector
112 *
113 * @param subcel_info_loop_length unused. Always 0
114 * @param subcell unused. Always NULL
115 * @param num_cell number of cells
116 * @param cell cell array. Contains per-cell and per-subcell
117 * pointers to the frequencies parsed.
118 */
119 struct dvb_desc_t2_delivery {
120 /* extended descriptor */
121
122 uint8_t plp_id;
123 uint16_t system_id;
124 union {
125 uint16_t bitfield;
126 struct {
127 uint16_t tfs_flag:1;
128 uint16_t other_frequency_flag:1;
129 uint16_t transmission_mode:3;
130 uint16_t guard_interval:3;
131 uint16_t reserved:2;
132 uint16_t bandwidth:4;
133 uint16_t SISO_MISO:2;
134 } __attribute__((packed));
135 } __attribute__((packed));
136
137 uint32_t *centre_frequency;
138 uint8_t frequency_loop_length;
139
140 /* Unused, as the definitions here are incomplete. */
141 uint8_t subcel_info_loop_length;
142 struct dvb_desc_t2_delivery_subcell_old *subcell;
143
144 /* Since version 1.13 */
145 unsigned int num_cell;
146 struct dvb_desc_t2_delivery_cell *cell;
147
148 } __attribute__((packed));
149
150 struct dvb_v5_fe_parms;
151
152 #ifdef __cplusplus
153 extern "C" {
154 #endif
155
156 /**
157 * @brief Initializes and parses the T2 delivery system descriptor
158 * @ingroup descriptors
159 *
160 * @param parms struct dvb_v5_fe_parms pointer to the opened device
161 * @param buf buffer containing the descriptor's raw data
162 * @param ext struct dvb_extension_descriptor pointer
163 * @param desc pointer to struct dvb_desc to be allocated and filled
164 *
165 * This function allocates a the descriptor and fills the fields inside
166 * the struct. It also makes sure that all fields will follow the CPU
167 * endianness. Due to that, the content of the buffer may change.
168 *
169 * @return On success, it returns the size of the allocated struct.
170 * A negative value indicates an error.
171 */
172 int dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
173 const uint8_t *buf,
174 struct dvb_extension_descriptor *ext,
175 void *desc);
176
177 /**
178 * @brief Prints the content of the T2 delivery system descriptor
179 * @ingroup descriptors
180 *
181 * @param parms struct dvb_v5_fe_parms pointer to the opened device
182 * @param ext struct dvb_extension_descriptor pointer
183 * @param desc pointer to struct dvb_desc
184 */
185 void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms *parms,
186 const struct dvb_extension_descriptor *ext,
187 const void *desc);
188
189 /**
190 * @brief Frees all data allocated by the T2 delivery system descriptor
191 * @ingroup descriptors
192 *
193 * @param desc pointer to struct dvb_desc to be freed
194 */
195 void dvb_desc_t2_delivery_free(const void *desc);
196
197 /**
198 * @brief converts from internal representation into bandwidth in Hz
199 */
200 extern const unsigned dvbt2_bw[];
201
202 /**
203 * @brief converts from internal representation into enum fe_guard_interval,
204 * as defined at DVBv5 API.
205 */
206 extern const uint32_t dvbt2_interval[];
207
208 /**
209 * @brief converts from the descriptor's transmission mode into
210 * enum fe_transmit_mode, as defined by DVBv5 API.
211 */
212 extern const unsigned dvbt2_transmission_mode[];
213
214 /**
215 * @brief converts from internal representation to string the SISO_MISO
216 * field of dvb_desc_t2_delivery:SISO_MISO field.
217 */
218 extern const char *siso_miso[4];
219
220 #ifdef __cplusplus
221 }
222 #endif
223
224 #endif