diff options
Diffstat (limited to 'drivers/media/dvb/dibusb/dvb-dibusb.h')
-rw-r--r-- | drivers/media/dvb/dibusb/dvb-dibusb.h | 327 |
1 files changed, 327 insertions, 0 deletions
diff --git a/drivers/media/dvb/dibusb/dvb-dibusb.h b/drivers/media/dvb/dibusb/dvb-dibusb.h new file mode 100644 index 000000000000..52cd35dd9d83 --- /dev/null +++ b/drivers/media/dvb/dibusb/dvb-dibusb.h | |||
@@ -0,0 +1,327 @@ | |||
1 | /* | ||
2 | * dvb-dibusb.h | ||
3 | * | ||
4 | * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation, version 2. | ||
9 | * | ||
10 | * for more information see dvb-dibusb-core.c . | ||
11 | */ | ||
12 | #ifndef __DVB_DIBUSB_H__ | ||
13 | #define __DVB_DIBUSB_H__ | ||
14 | |||
15 | #include <linux/input.h> | ||
16 | #include <linux/config.h> | ||
17 | #include <linux/usb.h> | ||
18 | |||
19 | #include "dvb_frontend.h" | ||
20 | #include "dvb_demux.h" | ||
21 | #include "dvb_net.h" | ||
22 | #include "dmxdev.h" | ||
23 | |||
24 | #include "dib3000.h" | ||
25 | #include "mt352.h" | ||
26 | |||
27 | /* debug */ | ||
28 | #ifdef CONFIG_DVB_DIBCOM_DEBUG | ||
29 | #define dprintk(level,args...) \ | ||
30 | do { if ((dvb_dibusb_debug & level)) { printk(args); } } while (0) | ||
31 | |||
32 | #define debug_dump(b,l) {\ | ||
33 | int i; \ | ||
34 | for (i = 0; i < l; i++) deb_xfer("%02x ", b[i]); \ | ||
35 | deb_xfer("\n");\ | ||
36 | } | ||
37 | |||
38 | #else | ||
39 | #define dprintk(args...) | ||
40 | #define debug_dump(b,l) | ||
41 | #endif | ||
42 | |||
43 | extern int dvb_dibusb_debug; | ||
44 | |||
45 | /* Version information */ | ||
46 | #define DRIVER_VERSION "0.3" | ||
47 | #define DRIVER_DESC "DiBcom based USB Budget DVB-T device" | ||
48 | #define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de" | ||
49 | |||
50 | #define deb_info(args...) dprintk(0x01,args) | ||
51 | #define deb_xfer(args...) dprintk(0x02,args) | ||
52 | #define deb_alot(args...) dprintk(0x04,args) | ||
53 | #define deb_ts(args...) dprintk(0x08,args) | ||
54 | #define deb_err(args...) dprintk(0x10,args) | ||
55 | #define deb_rc(args...) dprintk(0x20,args) | ||
56 | |||
57 | /* generic log methods - taken from usb.h */ | ||
58 | #undef err | ||
59 | #define err(format, arg...) printk(KERN_ERR "dvb-dibusb: " format "\n" , ## arg) | ||
60 | #undef info | ||
61 | #define info(format, arg...) printk(KERN_INFO "dvb-dibusb: " format "\n" , ## arg) | ||
62 | #undef warn | ||
63 | #define warn(format, arg...) printk(KERN_WARNING "dvb-dibusb: " format "\n" , ## arg) | ||
64 | |||
65 | struct dibusb_usb_controller { | ||
66 | const char *name; /* name of the usb controller */ | ||
67 | u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */ | ||
68 | }; | ||
69 | |||
70 | typedef enum { | ||
71 | DIBUSB1_1 = 0, | ||
72 | DIBUSB1_1_AN2235, | ||
73 | DIBUSB2_0, | ||
74 | UMT2_0, | ||
75 | DIBUSB2_0B, | ||
76 | NOVAT_USB2, | ||
77 | DTT200U, | ||
78 | } dibusb_class_t; | ||
79 | |||
80 | typedef enum { | ||
81 | DIBUSB_TUNER_CABLE_THOMSON = 0, | ||
82 | DIBUSB_TUNER_COFDM_PANASONIC_ENV57H1XD5, | ||
83 | DIBUSB_TUNER_CABLE_LG_TDTP_E102P, | ||
84 | DIBUSB_TUNER_COFDM_PANASONIC_ENV77H11D5, | ||
85 | } dibusb_tuner_t; | ||
86 | |||
87 | typedef enum { | ||
88 | DIBUSB_DIB3000MB = 0, | ||
89 | DIBUSB_DIB3000MC, | ||
90 | DIBUSB_MT352, | ||
91 | DTT200U_FE, | ||
92 | } dibusb_demodulator_t; | ||
93 | |||
94 | typedef enum { | ||
95 | DIBUSB_RC_NO = 0, | ||
96 | DIBUSB_RC_NEC_PROTOCOL, | ||
97 | DIBUSB_RC_HAUPPAUGE_PROTO, | ||
98 | } dibusb_remote_t; | ||
99 | |||
100 | struct dibusb_tuner { | ||
101 | dibusb_tuner_t id; | ||
102 | |||
103 | u8 pll_addr; /* tuner i2c address */ | ||
104 | }; | ||
105 | extern struct dibusb_tuner dibusb_tuner[]; | ||
106 | |||
107 | #define DIBUSB_POSSIBLE_I2C_ADDR_NUM 4 | ||
108 | struct dibusb_demod { | ||
109 | dibusb_demodulator_t id; | ||
110 | |||
111 | int pid_filter_count; /* counter of the internal pid_filter */ | ||
112 | u8 i2c_addrs[DIBUSB_POSSIBLE_I2C_ADDR_NUM]; /* list of possible i2c addresses of the demod */ | ||
113 | }; | ||
114 | |||
115 | #define DIBUSB_MAX_TUNER_NUM 2 | ||
116 | struct dibusb_device_class { | ||
117 | dibusb_class_t id; | ||
118 | |||
119 | const struct dibusb_usb_controller *usb_ctrl; /* usb controller */ | ||
120 | const char *firmware; /* valid firmware filenames */ | ||
121 | |||
122 | int pipe_cmd; /* command pipe (read/write) */ | ||
123 | int pipe_data; /* data pipe */ | ||
124 | |||
125 | int urb_count; /* number of data URBs to be submitted */ | ||
126 | int urb_buffer_size; /* the size of the buffer for each URB */ | ||
127 | |||
128 | dibusb_remote_t remote_type; /* does this device have a ir-receiver */ | ||
129 | |||
130 | struct dibusb_demod *demod; /* which demodulator is mount */ | ||
131 | struct dibusb_tuner *tuner; /* which tuner can be found here */ | ||
132 | }; | ||
133 | |||
134 | #define DIBUSB_ID_MAX_NUM 15 | ||
135 | struct dibusb_usb_device { | ||
136 | const char *name; /* real name of the box */ | ||
137 | struct dibusb_device_class *dev_cl; /* which dibusb_device_class is this device part of */ | ||
138 | |||
139 | struct usb_device_id *cold_ids[DIBUSB_ID_MAX_NUM]; /* list of USB ids when this device is at pre firmware state */ | ||
140 | struct usb_device_id *warm_ids[DIBUSB_ID_MAX_NUM]; /* list of USB ids when this device is at post firmware state */ | ||
141 | }; | ||
142 | |||
143 | /* a PID for the pid_filter list, when in use */ | ||
144 | struct dibusb_pid | ||
145 | { | ||
146 | int index; | ||
147 | u16 pid; | ||
148 | int active; | ||
149 | }; | ||
150 | |||
151 | struct usb_dibusb { | ||
152 | /* usb */ | ||
153 | struct usb_device * udev; | ||
154 | |||
155 | struct dibusb_usb_device * dibdev; | ||
156 | |||
157 | #define DIBUSB_STATE_INIT 0x000 | ||
158 | #define DIBUSB_STATE_URB_LIST 0x001 | ||
159 | #define DIBUSB_STATE_URB_BUF 0x002 | ||
160 | #define DIBUSB_STATE_URB_INIT 0x004 | ||
161 | #define DIBUSB_STATE_DVB 0x008 | ||
162 | #define DIBUSB_STATE_I2C 0x010 | ||
163 | #define DIBUSB_STATE_REMOTE 0x020 | ||
164 | #define DIBUSB_STATE_URB_SUBMIT 0x040 | ||
165 | int init_state; | ||
166 | |||
167 | int feedcount; | ||
168 | struct dib_fe_xfer_ops xfer_ops; | ||
169 | |||
170 | struct dibusb_tuner *tuner; | ||
171 | |||
172 | struct urb **urb_list; | ||
173 | u8 *buffer; | ||
174 | dma_addr_t dma_handle; | ||
175 | |||
176 | /* I2C */ | ||
177 | struct i2c_adapter i2c_adap; | ||
178 | |||
179 | /* locking */ | ||
180 | struct semaphore usb_sem; | ||
181 | struct semaphore i2c_sem; | ||
182 | |||
183 | /* dvb */ | ||
184 | struct dvb_adapter *adapter; | ||
185 | struct dmxdev dmxdev; | ||
186 | struct dvb_demux demux; | ||
187 | struct dvb_net dvb_net; | ||
188 | struct dvb_frontend* fe; | ||
189 | |||
190 | int (*fe_sleep) (struct dvb_frontend *); | ||
191 | int (*fe_init) (struct dvb_frontend *); | ||
192 | |||
193 | /* remote control */ | ||
194 | struct input_dev rc_input_dev; | ||
195 | struct work_struct rc_query_work; | ||
196 | int last_event; | ||
197 | int last_state; /* for Hauppauge RC protocol */ | ||
198 | int repeat_key_count; | ||
199 | int rc_key_repeat_count; /* module parameter */ | ||
200 | |||
201 | /* module parameters */ | ||
202 | int pid_parse; | ||
203 | int rc_query_interval; | ||
204 | }; | ||
205 | |||
206 | /* commonly used functions in the separated files */ | ||
207 | |||
208 | /* dvb-dibusb-firmware.c */ | ||
209 | int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_usb_device *dibdev); | ||
210 | |||
211 | /* dvb-dibusb-remote.c */ | ||
212 | int dibusb_remote_exit(struct usb_dibusb *dib); | ||
213 | int dibusb_remote_init(struct usb_dibusb *dib); | ||
214 | |||
215 | /* dvb-dibusb-fe-i2c.c */ | ||
216 | int dibusb_fe_init(struct usb_dibusb* dib); | ||
217 | int dibusb_fe_exit(struct usb_dibusb *dib); | ||
218 | int dibusb_i2c_init(struct usb_dibusb *dib); | ||
219 | int dibusb_i2c_exit(struct usb_dibusb *dib); | ||
220 | |||
221 | /* dvb-dibusb-dvb.c */ | ||
222 | void dibusb_urb_complete(struct urb *urb, struct pt_regs *ptregs); | ||
223 | int dibusb_dvb_init(struct usb_dibusb *dib); | ||
224 | int dibusb_dvb_exit(struct usb_dibusb *dib); | ||
225 | |||
226 | /* dvb-dibusb-usb.c */ | ||
227 | int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf, | ||
228 | u16 rlen); | ||
229 | int dibusb_write_usb(struct usb_dibusb *dib, u8 *buf, u16 len); | ||
230 | |||
231 | int dibusb_hw_wakeup(struct dvb_frontend *); | ||
232 | int dibusb_hw_sleep(struct dvb_frontend *); | ||
233 | int dibusb_set_streaming_mode(struct usb_dibusb *,u8); | ||
234 | int dibusb_streaming(struct usb_dibusb *,int); | ||
235 | |||
236 | int dibusb_urb_init(struct usb_dibusb *); | ||
237 | int dibusb_urb_exit(struct usb_dibusb *); | ||
238 | |||
239 | /* dvb-fe-dtt200u.c */ | ||
240 | struct dvb_frontend* dtt200u_fe_attach(struct usb_dibusb *,struct dib_fe_xfer_ops *); | ||
241 | |||
242 | /* i2c and transfer stuff */ | ||
243 | #define DIBUSB_I2C_TIMEOUT 5000 | ||
244 | |||
245 | /* | ||
246 | * protocol of all dibusb related devices | ||
247 | */ | ||
248 | |||
249 | /* | ||
250 | * bulk msg to/from endpoint 0x01 | ||
251 | * | ||
252 | * general structure: | ||
253 | * request_byte parameter_bytes | ||
254 | */ | ||
255 | |||
256 | #define DIBUSB_REQ_START_READ 0x00 | ||
257 | #define DIBUSB_REQ_START_DEMOD 0x01 | ||
258 | |||
259 | /* | ||
260 | * i2c read | ||
261 | * bulk write: 0x02 ((7bit i2c_addr << 1) & 0x01) register_bytes length_word | ||
262 | * bulk read: byte_buffer (length_word bytes) | ||
263 | */ | ||
264 | #define DIBUSB_REQ_I2C_READ 0x02 | ||
265 | |||
266 | /* | ||
267 | * i2c write | ||
268 | * bulk write: 0x03 (7bit i2c_addr << 1) register_bytes value_bytes | ||
269 | */ | ||
270 | #define DIBUSB_REQ_I2C_WRITE 0x03 | ||
271 | |||
272 | /* | ||
273 | * polling the value of the remote control | ||
274 | * bulk write: 0x04 | ||
275 | * bulk read: byte_buffer (5 bytes) | ||
276 | * | ||
277 | * first byte of byte_buffer shows the status (0x00, 0x01, 0x02) | ||
278 | */ | ||
279 | #define DIBUSB_REQ_POLL_REMOTE 0x04 | ||
280 | |||
281 | #define DIBUSB_RC_NEC_EMPTY 0x00 | ||
282 | #define DIBUSB_RC_NEC_KEY_PRESSED 0x01 | ||
283 | #define DIBUSB_RC_NEC_KEY_REPEATED 0x02 | ||
284 | |||
285 | /* additional status values for Hauppauge Remote Control Protocol */ | ||
286 | #define DIBUSB_RC_HAUPPAUGE_KEY_PRESSED 0x01 | ||
287 | #define DIBUSB_RC_HAUPPAUGE_KEY_EMPTY 0x03 | ||
288 | |||
289 | /* streaming mode: | ||
290 | * bulk write: 0x05 mode_byte | ||
291 | * | ||
292 | * mode_byte is mostly 0x00 | ||
293 | */ | ||
294 | #define DIBUSB_REQ_SET_STREAMING_MODE 0x05 | ||
295 | |||
296 | /* interrupt the internal read loop, when blocking */ | ||
297 | #define DIBUSB_REQ_INTR_READ 0x06 | ||
298 | |||
299 | /* io control | ||
300 | * 0x07 cmd_byte param_bytes | ||
301 | * | ||
302 | * param_bytes can be up to 32 bytes | ||
303 | * | ||
304 | * cmd_byte function parameter name | ||
305 | * 0x00 power mode | ||
306 | * 0x00 sleep | ||
307 | * 0x01 wakeup | ||
308 | * | ||
309 | * 0x01 enable streaming | ||
310 | * 0x02 disable streaming | ||
311 | * | ||
312 | * | ||
313 | */ | ||
314 | #define DIBUSB_REQ_SET_IOCTL 0x07 | ||
315 | |||
316 | /* IOCTL commands */ | ||
317 | |||
318 | /* change the power mode in firmware */ | ||
319 | #define DIBUSB_IOCTL_CMD_POWER_MODE 0x00 | ||
320 | #define DIBUSB_IOCTL_POWER_SLEEP 0x00 | ||
321 | #define DIBUSB_IOCTL_POWER_WAKEUP 0x01 | ||
322 | |||
323 | /* modify streaming of the FX2 */ | ||
324 | #define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01 | ||
325 | #define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02 | ||
326 | |||
327 | #endif | ||