1 /* 2 * Copyright (c) 2013 - Mauro Carvalho Chehab <mchehab@kernel.org> 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 * Described on IEC/CENELEC DS/EN 62216-1:2011 19 * 20 * I couldn't find the original version, so I used what's there at: 21 * http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf 22 */ 23 24 /** 25 * @file desc_logical_channel.h 26 * @ingroup descriptors 27 * @brief Provides the descriptors for the LCN - Logican Channel Number 28 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 29 * @author Mauro Carvalho Chehab 30 * 31 * @par Relevant specs 32 * The descriptor described herein is defined at: 33 * - IEC/CENELEC DS/EN 62216-1:2011 34 * 35 * @see http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf 36 * 37 * @par Bug Report 38 * Please submit bug reports and patches to linux-media@vger.kernel.org 39 */ 40 41 #ifndef _LCN_DESC_H 42 #define _LCN_DESC_H 43 44 #include <libdvbv5/descriptors.h> 45 46 /** 47 * @struct dvb_desc_logical_channel_number 48 * @ingroup descriptors 49 * @brief Structure containing the logical channel number entires 50 * 51 * @param service_id service id 52 * @param visible_service_flag visible service flag 53 * @param logical_channel_number logical channel number 54 */ 55 56 struct dvb_desc_logical_channel_number { 57 uint16_t service_id; 58 union { 59 uint16_t bitfield; 60 struct { 61 uint16_t logical_channel_number:10; 62 uint16_t reserved:5; 63 uint16_t visible_service_flag:1; 64 } __attribute__((packed)); 65 } __attribute__((packed)); 66 } __attribute__((packed)); 67 68 /** 69 * @struct dvb_desc_logical_channel 70 * @ingroup descriptors 71 * @brief Structure containing the logical channel number descriptor 72 * 73 * @param type descriptor tag 74 * @param length descriptor length 75 * @param next pointer to struct dvb_desc 76 * @param lcn pointer to struct dvb_desc_logical_channel_number 77 */ 78 struct dvb_desc_logical_channel { 79 uint8_t type; 80 uint8_t length; 81 struct dvb_desc *next; 82 83 struct dvb_desc_logical_channel_number *lcn; 84 } __attribute__((packed)); 85 86 struct dvb_v5_fe_parms; 87 88 #ifdef __cplusplus 89 extern "C" { 90 #endif 91 92 /** 93 * @brief Initializes and parses the logical channel number descriptor 94 * @ingroup descriptors 95 * 96 * @param parms struct dvb_v5_fe_parms pointer to the opened device 97 * @param buf buffer containing the descriptor's raw data 98 * @param desc pointer to struct dvb_desc to be allocated and filled 99 * 100 * This function allocates a the descriptor and fills the fields inside 101 * the struct. It also makes sure that all fields will follow the CPU 102 * endianness. Due to that, the content of the buffer may change. 103 * 104 * @return On success, it returns the size of the allocated struct. 105 * A negative value indicates an error. 106 */ 107 int dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms, 108 const uint8_t *buf, struct dvb_desc *desc); 109 110 /** 111 * @brief Prints the content of the logical channel number descriptor 112 * @ingroup descriptors 113 * 114 * @param parms struct dvb_v5_fe_parms pointer to the opened device 115 * @param desc pointer to struct dvb_desc 116 */ 117 void dvb_desc_logical_channel_print(struct dvb_v5_fe_parms *parms, 118 const struct dvb_desc *desc); 119 120 /** 121 * @brief Frees all data allocated by the logical channel number descriptor 122 * @ingroup descriptors 123 * 124 * @param desc pointer to struct dvb_desc to be freed 125 */ 126 void dvb_desc_logical_channel_free(struct dvb_desc *desc); 127 128 #ifdef __cplusplus 129 } 130 #endif 131 132 #endif 133