Linux-libre 3.5.4-gnu1
[librecmc/linux-libre.git] / include / linux / dvb / frontend.h
1 /*
2  * frontend.h
3  *
4  * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5  *                  Ralph  Metzler <ralph@convergence.de>
6  *                  Holger Waechtler <holger@convergence.de>
7  *                  Andre Draszik <ad@convergence.de>
8  *                  for convergence integrated media GmbH
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  *
24  */
25
26 #ifndef _DVBFRONTEND_H_
27 #define _DVBFRONTEND_H_
28
29 #include <linux/types.h>
30
31 typedef enum fe_type {
32         FE_QPSK,
33         FE_QAM,
34         FE_OFDM,
35         FE_ATSC
36 } fe_type_t;
37
38
39 typedef enum fe_caps {
40         FE_IS_STUPID                    = 0,
41         FE_CAN_INVERSION_AUTO           = 0x1,
42         FE_CAN_FEC_1_2                  = 0x2,
43         FE_CAN_FEC_2_3                  = 0x4,
44         FE_CAN_FEC_3_4                  = 0x8,
45         FE_CAN_FEC_4_5                  = 0x10,
46         FE_CAN_FEC_5_6                  = 0x20,
47         FE_CAN_FEC_6_7                  = 0x40,
48         FE_CAN_FEC_7_8                  = 0x80,
49         FE_CAN_FEC_8_9                  = 0x100,
50         FE_CAN_FEC_AUTO                 = 0x200,
51         FE_CAN_QPSK                     = 0x400,
52         FE_CAN_QAM_16                   = 0x800,
53         FE_CAN_QAM_32                   = 0x1000,
54         FE_CAN_QAM_64                   = 0x2000,
55         FE_CAN_QAM_128                  = 0x4000,
56         FE_CAN_QAM_256                  = 0x8000,
57         FE_CAN_QAM_AUTO                 = 0x10000,
58         FE_CAN_TRANSMISSION_MODE_AUTO   = 0x20000,
59         FE_CAN_BANDWIDTH_AUTO           = 0x40000,
60         FE_CAN_GUARD_INTERVAL_AUTO      = 0x80000,
61         FE_CAN_HIERARCHY_AUTO           = 0x100000,
62         FE_CAN_8VSB                     = 0x200000,
63         FE_CAN_16VSB                    = 0x400000,
64         FE_HAS_EXTENDED_CAPS            = 0x800000,   /* We need more bitspace for newer APIs, indicate this. */
65         FE_CAN_TURBO_FEC                = 0x8000000,  /* frontend supports "turbo fec modulation" */
66         FE_CAN_2G_MODULATION            = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */
67         FE_NEEDS_BENDING                = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */
68         FE_CAN_RECOVER                  = 0x40000000, /* frontend can recover from a cable unplug automatically */
69         FE_CAN_MUTE_TS                  = 0x80000000  /* frontend can stop spurious TS data output */
70 } fe_caps_t;
71
72
73 struct dvb_frontend_info {
74         char       name[128];
75         fe_type_t  type;                        /* DEPRECATED. Use DTV_ENUM_DELSYS instead */
76         __u32      frequency_min;
77         __u32      frequency_max;
78         __u32      frequency_stepsize;
79         __u32      frequency_tolerance;
80         __u32      symbol_rate_min;
81         __u32      symbol_rate_max;
82         __u32      symbol_rate_tolerance;       /* ppm */
83         __u32      notifier_delay;              /* DEPRECATED */
84         fe_caps_t  caps;
85 };
86
87
88 /**
89  *  Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
90  *  the meaning of this struct...
91  */
92 struct dvb_diseqc_master_cmd {
93         __u8 msg [6];   /*  { framing, address, command, data [3] } */
94         __u8 msg_len;   /*  valid values are 3...6  */
95 };
96
97
98 struct dvb_diseqc_slave_reply {
99         __u8 msg [4];   /*  { framing, data [3] } */
100         __u8 msg_len;   /*  valid values are 0...4, 0 means no msg  */
101         int  timeout;   /*  return from ioctl after timeout ms with */
102 };                      /*  errorcode when no message was received  */
103
104
105 typedef enum fe_sec_voltage {
106         SEC_VOLTAGE_13,
107         SEC_VOLTAGE_18,
108         SEC_VOLTAGE_OFF
109 } fe_sec_voltage_t;
110
111
112 typedef enum fe_sec_tone_mode {
113         SEC_TONE_ON,
114         SEC_TONE_OFF
115 } fe_sec_tone_mode_t;
116
117
118 typedef enum fe_sec_mini_cmd {
119         SEC_MINI_A,
120         SEC_MINI_B
121 } fe_sec_mini_cmd_t;
122
123
124 typedef enum fe_status {
125         FE_HAS_SIGNAL   = 0x01,   /* found something above the noise level */
126         FE_HAS_CARRIER  = 0x02,   /* found a DVB signal  */
127         FE_HAS_VITERBI  = 0x04,   /* FEC is stable  */
128         FE_HAS_SYNC     = 0x08,   /* found sync bytes  */
129         FE_HAS_LOCK     = 0x10,   /* everything's working... */
130         FE_TIMEDOUT     = 0x20,   /* no lock within the last ~2 seconds */
131         FE_REINIT       = 0x40    /* frontend was reinitialized,  */
132 } fe_status_t;                    /* application is recommended to reset */
133                                   /* DiSEqC, tone and parameters */
134
135 typedef enum fe_spectral_inversion {
136         INVERSION_OFF,
137         INVERSION_ON,
138         INVERSION_AUTO
139 } fe_spectral_inversion_t;
140
141
142 typedef enum fe_code_rate {
143         FEC_NONE = 0,
144         FEC_1_2,
145         FEC_2_3,
146         FEC_3_4,
147         FEC_4_5,
148         FEC_5_6,
149         FEC_6_7,
150         FEC_7_8,
151         FEC_8_9,
152         FEC_AUTO,
153         FEC_3_5,
154         FEC_9_10,
155 } fe_code_rate_t;
156
157
158 typedef enum fe_modulation {
159         QPSK,
160         QAM_16,
161         QAM_32,
162         QAM_64,
163         QAM_128,
164         QAM_256,
165         QAM_AUTO,
166         VSB_8,
167         VSB_16,
168         PSK_8,
169         APSK_16,
170         APSK_32,
171         DQPSK,
172 } fe_modulation_t;
173
174 typedef enum fe_transmit_mode {
175         TRANSMISSION_MODE_2K,
176         TRANSMISSION_MODE_8K,
177         TRANSMISSION_MODE_AUTO,
178         TRANSMISSION_MODE_4K,
179         TRANSMISSION_MODE_1K,
180         TRANSMISSION_MODE_16K,
181         TRANSMISSION_MODE_32K,
182 } fe_transmit_mode_t;
183
184 #if defined(__DVB_CORE__) || !defined (__KERNEL__)
185 typedef enum fe_bandwidth {
186         BANDWIDTH_8_MHZ,
187         BANDWIDTH_7_MHZ,
188         BANDWIDTH_6_MHZ,
189         BANDWIDTH_AUTO,
190         BANDWIDTH_5_MHZ,
191         BANDWIDTH_10_MHZ,
192         BANDWIDTH_1_712_MHZ,
193 } fe_bandwidth_t;
194 #endif
195
196 typedef enum fe_guard_interval {
197         GUARD_INTERVAL_1_32,
198         GUARD_INTERVAL_1_16,
199         GUARD_INTERVAL_1_8,
200         GUARD_INTERVAL_1_4,
201         GUARD_INTERVAL_AUTO,
202         GUARD_INTERVAL_1_128,
203         GUARD_INTERVAL_19_128,
204         GUARD_INTERVAL_19_256,
205 } fe_guard_interval_t;
206
207
208 typedef enum fe_hierarchy {
209         HIERARCHY_NONE,
210         HIERARCHY_1,
211         HIERARCHY_2,
212         HIERARCHY_4,
213         HIERARCHY_AUTO
214 } fe_hierarchy_t;
215
216
217 #if defined(__DVB_CORE__) || !defined (__KERNEL__)
218 struct dvb_qpsk_parameters {
219         __u32           symbol_rate;  /* symbol rate in Symbols per second */
220         fe_code_rate_t  fec_inner;    /* forward error correction (see above) */
221 };
222
223 struct dvb_qam_parameters {
224         __u32           symbol_rate; /* symbol rate in Symbols per second */
225         fe_code_rate_t  fec_inner;   /* forward error correction (see above) */
226         fe_modulation_t modulation;  /* modulation type (see above) */
227 };
228
229 struct dvb_vsb_parameters {
230         fe_modulation_t modulation;  /* modulation type (see above) */
231 };
232
233 struct dvb_ofdm_parameters {
234         fe_bandwidth_t      bandwidth;
235         fe_code_rate_t      code_rate_HP;  /* high priority stream code rate */
236         fe_code_rate_t      code_rate_LP;  /* low priority stream code rate */
237         fe_modulation_t     constellation; /* modulation type (see above) */
238         fe_transmit_mode_t  transmission_mode;
239         fe_guard_interval_t guard_interval;
240         fe_hierarchy_t      hierarchy_information;
241 };
242
243
244 struct dvb_frontend_parameters {
245         __u32 frequency;     /* (absolute) frequency in Hz for QAM/OFDM/ATSC */
246                              /* intermediate frequency in kHz for QPSK */
247         fe_spectral_inversion_t inversion;
248         union {
249                 struct dvb_qpsk_parameters qpsk;
250                 struct dvb_qam_parameters  qam;
251                 struct dvb_ofdm_parameters ofdm;
252                 struct dvb_vsb_parameters vsb;
253         } u;
254 };
255
256 struct dvb_frontend_event {
257         fe_status_t status;
258         struct dvb_frontend_parameters parameters;
259 };
260 #endif
261
262 /* S2API Commands */
263 #define DTV_UNDEFINED           0
264 #define DTV_TUNE                1
265 #define DTV_CLEAR               2
266 #define DTV_FREQUENCY           3
267 #define DTV_MODULATION          4
268 #define DTV_BANDWIDTH_HZ        5
269 #define DTV_INVERSION           6
270 #define DTV_DISEQC_MASTER       7
271 #define DTV_SYMBOL_RATE         8
272 #define DTV_INNER_FEC           9
273 #define DTV_VOLTAGE             10
274 #define DTV_TONE                11
275 #define DTV_PILOT               12
276 #define DTV_ROLLOFF             13
277 #define DTV_DISEQC_SLAVE_REPLY  14
278
279 /* Basic enumeration set for querying unlimited capabilities */
280 #define DTV_FE_CAPABILITY_COUNT 15
281 #define DTV_FE_CAPABILITY       16
282 #define DTV_DELIVERY_SYSTEM     17
283
284 /* ISDB-T and ISDB-Tsb */
285 #define DTV_ISDBT_PARTIAL_RECEPTION     18
286 #define DTV_ISDBT_SOUND_BROADCASTING    19
287
288 #define DTV_ISDBT_SB_SUBCHANNEL_ID      20
289 #define DTV_ISDBT_SB_SEGMENT_IDX        21
290 #define DTV_ISDBT_SB_SEGMENT_COUNT      22
291
292 #define DTV_ISDBT_LAYERA_FEC                    23
293 #define DTV_ISDBT_LAYERA_MODULATION             24
294 #define DTV_ISDBT_LAYERA_SEGMENT_COUNT          25
295 #define DTV_ISDBT_LAYERA_TIME_INTERLEAVING      26
296
297 #define DTV_ISDBT_LAYERB_FEC                    27
298 #define DTV_ISDBT_LAYERB_MODULATION             28
299 #define DTV_ISDBT_LAYERB_SEGMENT_COUNT          29
300 #define DTV_ISDBT_LAYERB_TIME_INTERLEAVING      30
301
302 #define DTV_ISDBT_LAYERC_FEC                    31
303 #define DTV_ISDBT_LAYERC_MODULATION             32
304 #define DTV_ISDBT_LAYERC_SEGMENT_COUNT          33
305 #define DTV_ISDBT_LAYERC_TIME_INTERLEAVING      34
306
307 #define DTV_API_VERSION         35
308
309 #define DTV_CODE_RATE_HP        36
310 #define DTV_CODE_RATE_LP        37
311 #define DTV_GUARD_INTERVAL      38
312 #define DTV_TRANSMISSION_MODE   39
313 #define DTV_HIERARCHY           40
314
315 #define DTV_ISDBT_LAYER_ENABLED 41
316
317 #define DTV_ISDBS_TS_ID         42
318
319 #define DTV_DVBT2_PLP_ID        43
320
321 #define DTV_ENUM_DELSYS         44
322
323 /* ATSC-MH */
324 #define DTV_ATSCMH_FIC_VER              45
325 #define DTV_ATSCMH_PARADE_ID            46
326 #define DTV_ATSCMH_NOG                  47
327 #define DTV_ATSCMH_TNOG                 48
328 #define DTV_ATSCMH_SGN                  49
329 #define DTV_ATSCMH_PRC                  50
330 #define DTV_ATSCMH_RS_FRAME_MODE        51
331 #define DTV_ATSCMH_RS_FRAME_ENSEMBLE    52
332 #define DTV_ATSCMH_RS_CODE_MODE_PRI     53
333 #define DTV_ATSCMH_RS_CODE_MODE_SEC     54
334 #define DTV_ATSCMH_SCCC_BLOCK_MODE      55
335 #define DTV_ATSCMH_SCCC_CODE_MODE_A     56
336 #define DTV_ATSCMH_SCCC_CODE_MODE_B     57
337 #define DTV_ATSCMH_SCCC_CODE_MODE_C     58
338 #define DTV_ATSCMH_SCCC_CODE_MODE_D     59
339
340 #define DTV_MAX_COMMAND                         DTV_ATSCMH_SCCC_CODE_MODE_D
341
342 typedef enum fe_pilot {
343         PILOT_ON,
344         PILOT_OFF,
345         PILOT_AUTO,
346 } fe_pilot_t;
347
348 typedef enum fe_rolloff {
349         ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
350         ROLLOFF_20,
351         ROLLOFF_25,
352         ROLLOFF_AUTO,
353 } fe_rolloff_t;
354
355 typedef enum fe_delivery_system {
356         SYS_UNDEFINED,
357         SYS_DVBC_ANNEX_A,
358         SYS_DVBC_ANNEX_B,
359         SYS_DVBT,
360         SYS_DSS,
361         SYS_DVBS,
362         SYS_DVBS2,
363         SYS_DVBH,
364         SYS_ISDBT,
365         SYS_ISDBS,
366         SYS_ISDBC,
367         SYS_ATSC,
368         SYS_ATSCMH,
369         SYS_DMBTH,
370         SYS_CMMB,
371         SYS_DAB,
372         SYS_DVBT2,
373         SYS_TURBO,
374         SYS_DVBC_ANNEX_C,
375 } fe_delivery_system_t;
376
377
378 #define SYS_DVBC_ANNEX_AC       SYS_DVBC_ANNEX_A
379
380 /* ATSC-MH */
381
382 enum atscmh_sccc_block_mode {
383         ATSCMH_SCCC_BLK_SEP      = 0,
384         ATSCMH_SCCC_BLK_COMB     = 1,
385         ATSCMH_SCCC_BLK_RES      = 2,
386 };
387
388 enum atscmh_sccc_code_mode {
389         ATSCMH_SCCC_CODE_HLF     = 0,
390         ATSCMH_SCCC_CODE_QTR     = 1,
391         ATSCMH_SCCC_CODE_RES     = 2,
392 };
393
394 enum atscmh_rs_frame_ensemble {
395         ATSCMH_RSFRAME_ENS_PRI   = 0,
396         ATSCMH_RSFRAME_ENS_SEC   = 1,
397 };
398
399 enum atscmh_rs_frame_mode {
400         ATSCMH_RSFRAME_PRI_ONLY  = 0,
401         ATSCMH_RSFRAME_PRI_SEC   = 1,
402         ATSCMH_RSFRAME_RES       = 2,
403 };
404
405 enum atscmh_rs_code_mode {
406         ATSCMH_RSCODE_211_187    = 0,
407         ATSCMH_RSCODE_223_187    = 1,
408         ATSCMH_RSCODE_235_187    = 2,
409         ATSCMH_RSCODE_RES        = 3,
410 };
411
412
413 struct dtv_cmds_h {
414         char    *name;          /* A display name for debugging purposes */
415
416         __u32   cmd;            /* A unique ID */
417
418         /* Flags */
419         __u32   set:1;          /* Either a set or get property */
420         __u32   buffer:1;       /* Does this property use the buffer? */
421         __u32   reserved:30;    /* Align */
422 };
423
424 struct dtv_property {
425         __u32 cmd;
426         __u32 reserved[3];
427         union {
428                 __u32 data;
429                 struct {
430                         __u8 data[32];
431                         __u32 len;
432                         __u32 reserved1[3];
433                         void *reserved2;
434                 } buffer;
435         } u;
436         int result;
437 } __attribute__ ((packed));
438
439 /* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
440 #define DTV_IOCTL_MAX_MSGS 64
441
442 struct dtv_properties {
443         __u32 num;
444         struct dtv_property *props;
445 };
446
447 #define FE_SET_PROPERTY            _IOW('o', 82, struct dtv_properties)
448 #define FE_GET_PROPERTY            _IOR('o', 83, struct dtv_properties)
449
450
451 /**
452  * When set, this flag will disable any zigzagging or other "normal" tuning
453  * behaviour. Additionally, there will be no automatic monitoring of the lock
454  * status, and hence no frontend events will be generated. If a frontend device
455  * is closed, this flag will be automatically turned off when the device is
456  * reopened read-write.
457  */
458 #define FE_TUNE_MODE_ONESHOT 0x01
459
460
461 #define FE_GET_INFO                _IOR('o', 61, struct dvb_frontend_info)
462
463 #define FE_DISEQC_RESET_OVERLOAD   _IO('o', 62)
464 #define FE_DISEQC_SEND_MASTER_CMD  _IOW('o', 63, struct dvb_diseqc_master_cmd)
465 #define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
466 #define FE_DISEQC_SEND_BURST       _IO('o', 65)  /* fe_sec_mini_cmd_t */
467
468 #define FE_SET_TONE                _IO('o', 66)  /* fe_sec_tone_mode_t */
469 #define FE_SET_VOLTAGE             _IO('o', 67)  /* fe_sec_voltage_t */
470 #define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68)  /* int */
471
472 #define FE_READ_STATUS             _IOR('o', 69, fe_status_t)
473 #define FE_READ_BER                _IOR('o', 70, __u32)
474 #define FE_READ_SIGNAL_STRENGTH    _IOR('o', 71, __u16)
475 #define FE_READ_SNR                _IOR('o', 72, __u16)
476 #define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
477
478 #define FE_SET_FRONTEND            _IOW('o', 76, struct dvb_frontend_parameters)
479 #define FE_GET_FRONTEND            _IOR('o', 77, struct dvb_frontend_parameters)
480 #define FE_SET_FRONTEND_TUNE_MODE  _IO('o', 81) /* unsigned int */
481 #define FE_GET_EVENT               _IOR('o', 78, struct dvb_frontend_event)
482
483 #define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
484
485 #endif /*_DVBFRONTEND_H_*/