1 /* $NetBSD: dtvio_frontend.h,v 1.4 2025/11/15 19:12:13 jmcneill Exp $ */ 2 3 /*- 4 * Copyright (c) 2011 Jared D. McNeill <jmcneill (at) invisible.ca> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of The NetBSD Foundation nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _DEV_DTV_DTVIO_FRONTEND_H 33 #define _DEV_DTV_DTVIO_FRONTEND_H 34 35 #include <sys/types.h> 36 #include <sys/ioccom.h> 37 38 /* 39 * DVB Frontend API 40 */ 41 42 /* Frontend types */ 43 typedef enum fe_type { 44 FE_QPSK, /* DVB-S */ 45 FE_QAM, /* DVB-C annex A/C */ 46 FE_OFDM, /* DVB-T */ 47 FE_ATSC, /* ATSC or DVB-C annex B */ 48 } fe_type_t; 49 50 /* Frontend capabilities */ 51 typedef enum fe_caps { 52 FE_IS_STUPID = 0, 53 FE_CAN_INVERSION_AUTO = 0x1, 54 FE_CAN_FEC_1_2 = 0x2, 55 FE_CAN_FEC_2_3 = 0x4, 56 FE_CAN_FEC_3_4 = 0x8, 57 FE_CAN_FEC_4_5 = 0x10, 58 FE_CAN_FEC_5_6 = 0x20, 59 FE_CAN_FEC_6_7 = 0x40, 60 FE_CAN_FEC_7_8 = 0x80, 61 FE_CAN_FEC_8_9 = 0x100, 62 FE_CAN_FEC_AUTO = 0x200, 63 FE_CAN_QPSK = 0x400, 64 FE_CAN_QAM_16 = 0x800, 65 FE_CAN_QAM_32 = 0x1000, 66 FE_CAN_QAM_64 = 0x2000, 67 FE_CAN_QAM_128 = 0x4000, 68 FE_CAN_QAM_256 = 0x8000, 69 FE_CAN_QAM_AUTO = 0x10000, 70 FE_CAN_TRANSMISSION_MODE_AUTO = 0x20000, 71 FE_CAN_BANDWIDTH_AUTO = 0x40000, 72 FE_CAN_GUARD_INTERVAL_AUTO = 0x80000, 73 FE_CAN_HIERARCHY_AUTO = 0x100000, 74 FE_CAN_8VSB = 0x200000, 75 FE_CAN_16VSB = 0x400000, 76 FE_HAS_EXTENDED_CAPS = 0x800000, 77 FE_CAN_TURBO_FEC = 0x8000000, 78 FE_CAN_2G_MODULATION = 0x10000000, 79 FE_NEEDS_BENDING = 0x20000000, 80 FE_CAN_RECOVER = 0x40000000, 81 FE_CAN_MUTE_TS = 0x80000000, 82 } fe_caps_t; 83 84 /* Frontend information */ 85 struct dvb_frontend_info { 86 char name[128]; 87 fe_type_t type; 88 uint32_t frequency_min; 89 uint32_t frequency_max; 90 uint32_t frequency_stepsize; 91 uint32_t frequency_tolerance; 92 uint32_t symbol_rate_min; 93 uint32_t symbol_rate_max; 94 uint32_t symbol_rate_tolerance; /* ppm */ 95 uint32_t notifier_delay; /* ms */ 96 fe_caps_t caps; 97 }; 98 99 /* Frontend status */ 100 typedef enum fe_status { 101 FE_HAS_SIGNAL = 0x01, /* found something above the noise level */ 102 FE_HAS_CARRIER = 0x02, /* found a DVB signal */ 103 FE_HAS_VITERBI = 0x04, /* FEC is stable */ 104 FE_HAS_SYNC = 0x08, /* found sync bytes */ 105 FE_HAS_LOCK = 0x10, /* everything's working... */ 106 FE_TIMEDOUT = 0x20, /* no lock within the last ~2 seconds */ 107 FE_REINIT = 0x40, /* frontend was reinitialized */ 108 } fe_status_t; 109 110 /* Frontend spectral inversion */ 111 typedef enum fe_spectral_inversion { 112 INVERSION_OFF, 113 INVERSION_ON, 114 INVERSION_AUTO, 115 } fe_spectral_inversion_t; 116 117 /* Frontend code rate */ 118 typedef enum fe_code_rate { 119 FEC_NONE = 0, 120 FEC_1_2, 121 FEC_2_3, 122 FEC_3_4, 123 FEC_4_5, 124 FEC_5_6, 125 FEC_6_7, 126 FEC_7_8, 127 FEC_8_9, 128 FEC_AUTO, 129 FEC_3_5, 130 FEC_9_10, 131 } fe_code_rate_t; 132 133 /* Frontend modulation type for QAM, OFDM, and VSB */ 134 typedef enum fe_modulation { 135 QPSK, 136 QAM_16, 137 QAM_32, 138 QAM_64, 139 QAM_128, 140 QAM_256, 141 QAM_AUTO, 142 VSB_8, 143 VSB_16, 144 PSK_8, 145 APSK_16, 146 APSK_32, 147 DQPSK, 148 } fe_modulation_t; 149 150 /* Number of carriers per channel */ 151 typedef enum fe_transmit_mode { 152 TRANSMISSION_MODE_2K, 153 TRANSMISSION_MODE_8K, 154 TRANSMISSION_MODE_AUTO, 155 TRANSMISSION_MODE_4K, 156 TRANSMISSION_MODE_1K, 157 TRANSMISSION_MODE_16K, 158 TRANSMISSION_MODE_32K, 159 } fe_transmit_mode_t; 160 161 /* Frontend bandwidth */ 162 typedef enum fe_bandwidth { 163 BANDWIDTH_8_MHZ, 164 BANDWIDTH_7_MHZ, 165 BANDWIDTH_6_MHZ, 166 BANDWIDTH_AUTO, 167 BANDWIDTH_5_MHZ, 168 BANDWIDTH_10_MHZ, 169 BANDWIDTH_1_172_MHZ, 170 } fe_bandwidth_t; 171 172 /* Frontend guard interval */ 173 typedef enum fe_guard_interval { 174 GUARD_INTERVAL_1_32, 175 GUARD_INTERVAL_1_16, 176 GUARD_INTERVAL_1_8, 177 GUARD_INTERVAL_1_4, 178 GUARD_INTERVAL_AUTO, 179 GUARD_INTERVAL_1_128, 180 GUARD_INTERVAL_19_128, 181 GUARD_INTERVAL_19_256, 182 } fe_guard_interval_t; 183 184 /* Frontend hierarchy */ 185 typedef enum fe_hierarchy { 186 HIERARCHY_NONE, 187 HIERARCHY_1, 188 HIERARCHY_2, 189 HIERARCHY_4, 190 HIERARCHY_AUTO 191 } fe_hierarchy_t; 192 193 /* QPSK parameters */ 194 struct dvb_qpsk_parameters { 195 uint32_t symbol_rate; 196 fe_code_rate_t fec_inner; 197 }; 198 199 /* QAM parameters */ 200 struct dvb_qam_parameters { 201 uint32_t symbol_rate; 202 fe_code_rate_t fec_inner; 203 fe_modulation_t modulation; 204 }; 205 206 /* VSB parameters */ 207 struct dvb_vsb_parameters { 208 fe_modulation_t modulation; 209 }; 210 211 /* OFDM parameters */ 212 struct dvb_ofdm_parameters { 213 fe_bandwidth_t bandwidth; 214 fe_code_rate_t code_rate_HP; 215 fe_code_rate_t code_rate_LP; 216 fe_modulation_t constellation; 217 fe_transmit_mode_t transmission_mode; 218 fe_guard_interval_t guard_interval; 219 fe_hierarchy_t hierarchy_information; 220 }; 221 222 /* Frontend parameters */ 223 struct dvb_frontend_parameters { 224 uint32_t frequency; 225 fe_spectral_inversion_t inversion; 226 union { 227 struct dvb_qpsk_parameters qpsk; 228 struct dvb_qam_parameters qam; 229 struct dvb_ofdm_parameters ofdm; 230 struct dvb_vsb_parameters vsb; 231 } u; 232 }; 233 234 /* Frontend events */ 235 struct dvb_frontend_event { 236 fe_status_t status; 237 struct dvb_frontend_parameters parameters; 238 }; 239 240 /* DiSEqC master command */ 241 struct dvb_diseqc_master_cmd { 242 uint8_t msg[6]; 243 uint8_t msg_len; 244 }; 245 246 /* DiSEqC slave reply */ 247 struct dvb_diseqc_slave_reply { 248 uint8_t msg[4]; 249 uint8_t msg_len; 250 int timeout; 251 }; 252 253 /* SEC voltage */ 254 typedef enum fe_sec_voltage { 255 SEC_VOLTAGE_13, 256 SEC_VOLTAGE_18, 257 SEC_VOLTAGE_OFF, 258 } fe_sec_voltage_t; 259 260 /* SEC continuous tone */ 261 typedef enum fe_sec_tone_mode { 262 SEC_TONE_ON, 263 SEC_TONE_OFF, 264 } fe_sec_tone_mode_t; 265 266 /* SEC tone burst */ 267 typedef enum fe_sec_mini_cmd { 268 SEC_MINI_A, 269 SEC_MINI_B, 270 } fe_sec_mini_cmd_t; 271 272 #define FE_READ_STATUS _IOR('D', 0, fe_status_t) 273 #define FE_READ_BER _IOR('D', 1, uint32_t) 274 #define FE_READ_SNR _IOR('D', 2, uint16_t) 275 #define FE_READ_SIGNAL_STRENGTH _IOR('D', 3, uint16_t) 276 #define FE_READ_UNCORRECTED_BLOCKS _IOR('D', 4, uint32_t) 277 #define FE_SET_FRONTEND _IOWR('D', 5, struct dvb_frontend_parameters) 278 #define FE_GET_FRONTEND _IOR('D', 6, struct dvb_frontend_parameters) 279 #define FE_GET_EVENT _IOR('D', 7, struct dvb_frontend_event) 280 #define FE_GET_INFO _IOR('D', 8, struct dvb_frontend_info) 281 #define FE_DISEQC_RESET_OVERLOAD _IO('D', 9) 282 #define FE_DISEQC_SEND_MASTER_CMD _IOW('D', 10, struct dvb_diseqc_master_cmd) 283 #define FE_DISEQC_RECV_SLAVE_REPLY _IOR('D', 11, struct dvb_diseqc_slave_reply) 284 #define FE_DISEQC_SEND_BURST _IOW('D', 12, fe_sec_mini_cmd_t) 285 #define FE_SET_TONE _IOW('D', 13, fe_sec_tone_mode_t) 286 #define FE_SET_VOLTAGE _IOW('D', 14, fe_sec_voltage_t) 287 #define FE_ENABLE_HIGH_LNB_VOLTAGE _IOW('D', 15, int) 288 #define FE_SET_FRONTEND_TUNE_MODE _IOW('D', 16, unsigned int) 289 #define FE_DISHNETWORK_SEND_LEGACY_CMD _IOW('D', 17, unsigned long) 290 291 #endif /* !_DEV_DTV_DTVIO_FRONTEND_H */ 292