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