Chuanzhi Wang | 742ba11 | 2020-09-15 11:43:55 +0800 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * Copyright (c) 2014 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * This source code is subject to the terms and conditions defined in the |
| 5 | * file 'LICENSE' which is part of this source code package. |
| 6 | * |
| 7 | * Description: |
| 8 | * |
| 9 | * @brief linux dvb frontend wrapper |
| 10 | * @file dvb_dmx_frontend.h |
| 11 | * |
| 12 | * \author chuanzhi wang <chaunzhi.wang@amlogic.com> |
| 13 | * \date 2020-09-11: create the document |
| 14 | ***************************************************************************/ |
| 15 | |
| 16 | #ifndef _AM_FE_H |
| 17 | #define _AM_FE_H |
| 18 | #include "dvb_utils.h" |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" |
| 22 | { |
| 23 | #endif |
| 24 | |
| 25 | typedef enum |
| 26 | { |
| 27 | DMD_DOWNLINK_INJECTION, |
| 28 | DMD_DOWNLINK_CUSTOM, |
| 29 | DMD_DOWNLINK_Ku_LOW, |
| 30 | DMD_DOWNLINK_Ku_HIGH, |
| 31 | DMD_DOWNLINK_C |
| 32 | } dmd_downlink_t; |
| 33 | |
| 34 | typedef enum |
| 35 | { |
| 36 | DMD_LNB_TONE_DEFAULT, |
| 37 | DMD_LNB_TONE_OFF, |
| 38 | DMD_LNB_TONE_22KHZ |
| 39 | } dmd_lnb_tone_state_t; |
| 40 | |
| 41 | typedef struct |
| 42 | { |
| 43 | uint_t band_start; |
| 44 | uint_t band_end; |
| 45 | uint_t lo; |
| 46 | dmd_downlink_t downlink; |
| 47 | } dmd_satellite_band_t; |
| 48 | |
| 49 | typedef enum |
| 50 | { |
| 51 | DMD_DISEQC_DEFAULT, |
| 52 | DMD_DISEQC_PORTA, |
| 53 | DMD_DISEQC_PORTB, |
| 54 | DMD_DISEQC_PORTC, |
| 55 | DMD_DISEQC_PORTD, |
| 56 | DMD_DISEQC_ALL |
| 57 | } dmd_diseqc_port_t; |
| 58 | |
| 59 | typedef enum |
| 60 | { |
| 61 | DMD_LNB_VOLTAGE_OFF = 0, |
| 62 | DMD_LNB_VOLTAGE_14V = 1, |
| 63 | DMD_LNB_VOLTAGE_18V = 2 |
| 64 | } dmd_lnb_voltage_t; |
| 65 | |
| 66 | typedef enum |
| 67 | { |
| 68 | DMD_PLR_HORIZONTAL = 0x01, |
| 69 | DMD_PLR_VERTICAL = 0x02, |
| 70 | DMD_PLR_NONE = 0x03, |
| 71 | DMD_PLR_CIRCULAR_LEFT = 0x04, |
| 72 | DMD_PLR_CIRCULAR_RIGHT = 0x05 |
| 73 | } dmd_polarization_t; |
| 74 | |
| 75 | typedef enum |
| 76 | { |
| 77 | DMD_ROLLOFF_035 = 0x00, |
| 78 | DMD_ROLLOFF_025 = 0x01, |
| 79 | DMD_ROLLOFF_020 = 0x02 |
| 80 | } dmd_rolloff_t; |
| 81 | |
| 82 | typedef enum |
| 83 | { |
| 84 | DMD_MODSYS_DVBS = 0x00, |
| 85 | DMD_MODSYS_DVBS2 = 0x01 |
| 86 | } dmd_modulation_system_t; |
| 87 | |
| 88 | typedef enum |
| 89 | { |
| 90 | DMD_FEC_NONE = 0x0000, |
| 91 | DMD_FEC_1_2 = 0x0001, |
| 92 | DMD_FEC_2_3 = 0x0002, |
| 93 | DMD_FEC_3_4 = 0x0004, |
| 94 | DMD_FEC_4_5 = 0x0008, |
| 95 | DMD_FEC_5_6 = 0x0010, |
| 96 | DMD_FEC_6_7 = 0x0020, |
| 97 | DMD_FEC_7_8 = 0x0040, |
| 98 | DMD_FEC_8_9 = 0x0080, |
| 99 | DMD_FEC_3_5 = 0x0100, |
| 100 | DMD_FEC_9_10 = 0x0200, |
| 101 | DMD_FEC_ALL = 0xFFFF |
| 102 | } dmd_fec_rate_t; |
| 103 | |
| 104 | typedef enum |
| 105 | { |
| 106 | DMD_FEC_OUTER_NONE = 0x00, |
| 107 | DMD_FEC_OUTER_NOT_DEFINED = 0x01, |
| 108 | DMD_FEC_OUTER_RS = 0x02 |
| 109 | } dmd_fec_rate_outer_t; |
| 110 | |
| 111 | typedef enum |
| 112 | { |
| 113 | DMD_MOD_NONE = 0x0000, |
| 114 | DMD_MOD_QPSK = 0x0001, |
| 115 | DMD_MOD_8PSK = 0x0002, |
| 116 | DMD_MOD_QAM = 0x0004, |
| 117 | DMD_MOD_4QAM = 0x0008, |
| 118 | DMD_MOD_16QAM = 0x0010, |
| 119 | DMD_MOD_32QAM = 0x0020, |
| 120 | DMD_MOD_64QAM = 0x0040, |
| 121 | DMD_MOD_128QAM = 0x0080, |
| 122 | DMD_MOD_256QAM = 0x0100, |
| 123 | DMD_MOD_BPSK = 0x0200, |
| 124 | DMD_MOD_ALL = 0xFFFF |
| 125 | } dmd_modulation_t; |
| 126 | |
| 127 | typedef enum |
| 128 | { |
| 129 | DMD_CONSTELLATION_NONE = 0x0000, |
| 130 | DMD_CONSTELLATION_QPSK = 0x0001, |
| 131 | DMD_CONSTELLATION_16QAM = 0x0002, |
| 132 | DMD_CONSTELLATION_64QAM = 0x0004, |
| 133 | DMD_CONSTELLATION_32QAM = 0x0008, |
| 134 | DMD_CONSTELLATION_128QAM = 0x0010, |
| 135 | DMD_CONSTELLATION_256QAM = 0x0020, |
| 136 | DMD_CONSTELLATION_1024QAM = 0x0040, |
| 137 | DMD_CONSTELLATION_ALL = 0xFFFF |
| 138 | } dmd_constellation_t; |
| 139 | |
| 140 | typedef enum |
| 141 | { |
| 142 | DMD_GUARD_INTERVAL_1_32 = 0x01, |
| 143 | DMD_GUARD_INTERVAL_1_16 = 0x02, |
| 144 | DMD_GUARD_INTERVAL_1_8 = 0x03, |
| 145 | DMD_GUARD_INTERVAL_1_4 = 0x04, |
| 146 | DMD_GUARD_INTERVAL_1_128 = 0x05, |
| 147 | DMD_GUARD_INTERVAL_19_128 = 0x06, |
| 148 | DMD_GUARD_INTERVAL_19_256 = 0x07 |
| 149 | } dmd_guard_interval_t; |
| 150 | |
| 151 | typedef enum |
| 152 | { |
| 153 | DMD_HIERARCHY_NONE = 0x01, |
| 154 | DMD_HIERARCHY_1 = 0x02, |
| 155 | DMD_HIERARCHY_2 = 0x03, |
| 156 | DMD_HIERARCHY_4 = 0x04 |
| 157 | } dmd_hierarchy_t; |
| 158 | |
| 159 | typedef enum |
| 160 | { |
| 161 | DMD_HIERARCHY_HP = 0x00, |
| 162 | DMD_HIERARCHY_LP = 0x01 |
| 163 | } dmd_hierarchy_hplp_t; |
| 164 | |
| 165 | typedef enum |
| 166 | { |
| 167 | DMD_PLP_COMMON, |
| 168 | DMD_PLP_DATA1, |
| 169 | DMD_PLP_DATA2 |
| 170 | } dmd_plp_type_t; |
| 171 | |
| 172 | typedef enum |
| 173 | { |
| 174 | TUNER_STATE_LOCKED, |
| 175 | TUNER_STATE_TIMEOUT, |
| 176 | TUNER_STATE_UNKNOW |
| 177 | } dmd_tuner_event_t; |
| 178 | |
| 179 | typedef struct |
| 180 | { |
| 181 | uint_t frequency; |
| 182 | uint_t symbol_rate; |
| 183 | dmd_modulation_system_t modulation_system; |
| 184 | dmd_polarization_t polarization; |
| 185 | dmd_modulation_t modulation; |
| 186 | dmd_fec_rate_t fec_rate; |
| 187 | dmd_rolloff_t roll_off; |
| 188 | //dmd_lnb_tone_state_t lnb_tone_state; |
| 189 | //dmd_diseqc_port_t diseqc_port; |
| 190 | //dmd_satellite_band_t band; |
| 191 | } dmd_satellite_desc_t; |
| 192 | |
| 193 | typedef struct |
| 194 | { |
| 195 | uint_t frequency; /* frequency in KHz */ |
| 196 | dmd_fec_rate_t fec_rate; /* select FEC rate(s) */ |
| 197 | dmd_fec_rate_outer_t fec_rate_outer; /* select FEC outer */ |
| 198 | dmd_modulation_t modulation; /* select modulation scheme */ |
| 199 | uint_t symbol_rate; /* symbol rate in KBAUD */ |
| 200 | } dmd_cable_desc_t; |
| 201 | |
| 202 | typedef enum |
| 203 | { |
| 204 | DMD_TRANSMISSION_2K = 0x01, |
| 205 | DMD_TRANSMISSION_8K = 0x02, |
| 206 | DMD_TRANSMISSION_4K = 0x03, |
| 207 | DMD_TRANSMISSION_1K = 0x04, |
| 208 | DMD_TRANSMISSION_16K = 0x05, |
| 209 | DMD_TRANSMISSION_32K = 0x06 |
| 210 | } dmd_transmission_mode_t; |
| 211 | |
| 212 | typedef enum |
| 213 | { |
| 214 | DMD_BANDWIDTH_8M = 0x01, |
| 215 | DMD_BANDWIDTH_7M = 0x02, |
| 216 | DMD_BANDWIDTH_6M = 0x03, |
| 217 | DMD_BANDWIDTH_5M = 0x04, |
| 218 | DMD_BANDWIDTH_10M = 0x05, |
| 219 | DMD_BANDWIDTH_17M = 0x06 |
| 220 | } dmd_bandwidth_t; |
| 221 | |
| 222 | typedef enum |
| 223 | { |
| 224 | DMD_DVBTYPE_DVBT, |
hualing chen | b6b96f5 | 2021-05-26 14:55:59 +0800 | [diff] [blame^] | 225 | DMD_DVBTYPE_DVBT2, |
| 226 | DMD_DVBTYPE_DTMB |
Chuanzhi Wang | 742ba11 | 2020-09-15 11:43:55 +0800 | [diff] [blame] | 227 | } dmd_terrestrial_dvbtype_t; |
| 228 | |
| 229 | typedef struct |
| 230 | { |
| 231 | uint_t frequency; |
| 232 | dmd_constellation_t constellation; |
| 233 | dmd_hierarchy_t hierarchy; |
| 234 | dmd_hierarchy_hplp_t hp_lp; |
| 235 | dmd_fec_rate_t HP_code_rate; |
| 236 | dmd_fec_rate_t LP_code_rate; |
| 237 | dmd_guard_interval_t guard_interval; |
| 238 | dmd_transmission_mode_t transmission_mode; |
| 239 | dmd_bandwidth_t bandwidth; |
| 240 | } dmd_terrestrial_dvbt_desc_t; |
| 241 | |
| 242 | typedef struct |
| 243 | { |
| 244 | uint_t frequency; |
| 245 | uint_t plp_id; |
| 246 | dmd_guard_interval_t guard_interval; |
| 247 | dmd_transmission_mode_t transmission_mode; |
| 248 | uint_t T2_system_id; |
| 249 | dmd_bandwidth_t bandwidth; |
| 250 | } dmd_terrestrial_dvbt2_desc_t; |
| 251 | |
| 252 | typedef struct |
| 253 | { |
hualing chen | b6b96f5 | 2021-05-26 14:55:59 +0800 | [diff] [blame^] | 254 | uint_t frequency; |
| 255 | dmd_bandwidth_t bandwidth; |
| 256 | } dmd_terrestrial_dtmb_desc_t; |
| 257 | |
| 258 | typedef struct |
| 259 | { |
Chuanzhi Wang | 742ba11 | 2020-09-15 11:43:55 +0800 | [diff] [blame] | 260 | dmd_terrestrial_dvbtype_t dvb_type; |
| 261 | union { |
| 262 | dmd_terrestrial_dvbt_desc_t dvbt; |
| 263 | dmd_terrestrial_dvbt2_desc_t dvbt2; |
hualing chen | b6b96f5 | 2021-05-26 14:55:59 +0800 | [diff] [blame^] | 264 | dmd_terrestrial_dtmb_desc_t dtmb; |
Chuanzhi Wang | 742ba11 | 2020-09-15 11:43:55 +0800 | [diff] [blame] | 265 | } desc; |
| 266 | } dmd_terrestrial_desc_t; |
| 267 | |
| 268 | /**\brief open frontend device |
| 269 | * \param FE device path |
| 270 | * \param FE device fd |
| 271 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 272 | */ |
| 273 | DVB_RESULT AML_FE_Open(const char *name, int *frontend_fd); |
| 274 | |
| 275 | /**\brief close frontend device |
| 276 | * \param FE device fd |
| 277 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 278 | */ |
| 279 | DVB_RESULT AML_FE_Colse(int frontend_fd); |
| 280 | |
| 281 | /**\brief get current tune status |
| 282 | * \param FE device fd |
| 283 | * \return whether it is locked |
| 284 | */ |
| 285 | dmd_tuner_event_t AML_FE_GetTuneStatus(int frontend_fd); |
| 286 | |
| 287 | /**\brief tune DVB-C |
| 288 | * \param FE device fd |
| 289 | * \param dvb cable parameter |
| 290 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 291 | */ |
| 292 | DVB_RESULT AML_FE_TuneDVB_C(int frontend_fd, const dmd_cable_desc_t *cable); |
| 293 | |
| 294 | /**\brief tune DVB-T |
| 295 | * \param FE device fd |
| 296 | * \param dvb terrestrial parameter |
| 297 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 298 | */ |
| 299 | DVB_RESULT AML_FE_TuneDVB_T(int frontend_fd, const dmd_terrestrial_desc_t *terr); |
| 300 | |
| 301 | /**\brief tune DVB-S |
| 302 | * \param FE device fd |
| 303 | * \param dvb satellite parameter |
| 304 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 305 | */ |
| 306 | DVB_RESULT AML_FE_TuneDVB_S(int frontend_fd, const dmd_satellite_desc_t *sate); |
| 307 | |
| 308 | /**\brief set lnb voltage |
| 309 | * \param FE device fd |
| 310 | * \param voltage |
| 311 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 312 | */ |
| 313 | DVB_RESULT AML_FE_LnbVoltage(int frontend_fd, dmd_lnb_voltage_t voltage); |
| 314 | |
| 315 | /**\brief set lnb tone |
| 316 | * \param FE device fd |
| 317 | * \param tone, 22khz |
| 318 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 319 | */ |
| 320 | DVB_RESULT AML_FE_LnbTone(int frontend_fd, dmd_lnb_tone_state_t tone_state); |
| 321 | |
| 322 | /**\brief send diseqc cmd |
| 323 | * \param FE device fd |
| 324 | * \param diseqc cmd data |
| 325 | * \param diseqc cmd data length |
| 326 | * \return DVB_SUCCESS On success, DVB_FAILURE on error. |
| 327 | */ |
| 328 | DVB_RESULT AML_FE_SendDISEQCMessage(int frontend_fd, uint8_t *data, uint8_t size); |
| 329 | |
| 330 | #ifdef __cplusplus |
| 331 | } |
| 332 | #endif |
| 333 | #endif |