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 "Driver for 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 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
59 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
60 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
61
62 struct dibusb_usb_controller {
63 const char *name; /* name of the usb controller */
64 u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */
65 };
66
67 typedef enum {
68 DIBUSB1_1 = 0,
69 DIBUSB1_1_AN2235,
70 DIBUSB2_0,
71 UMT2_0,
72 } dibusb_class_t;
73
74 typedef enum {
75 DIBUSB_TUNER_CABLE_THOMSON = 0,
76 DIBUSB_TUNER_COFDM_PANASONIC_ENV57H1XD5,
77 DIBUSB_TUNER_CABLE_LG_TDTP_E102P,
78 DIBUSB_TUNER_COFDM_PANASONIC_ENV77H11D5,
79 } dibusb_tuner_t;
80
81 typedef enum {
82 DIBUSB_DIB3000MB = 0,
83 DIBUSB_DIB3000MC,
84 DIBUSB_MT352,
85 } dibusb_demodulator_t;
86
87 typedef enum {
88 DIBUSB_RC_NO = 0,
89 DIBUSB_RC_NEC_PROTOCOL = 1,
90 } dibusb_remote_t;
91
92 struct dibusb_tuner {
93 dibusb_tuner_t id;
94
95 u8 pll_addr; /* tuner i2c address */
96 };
97 extern struct dibusb_tuner dibusb_tuner[];
98
99 #define DIBUSB_POSSIBLE_I2C_ADDR_NUM 4
100 struct dibusb_demod {
101 dibusb_demodulator_t id;
102
103 int pid_filter_count; /* counter of the internal pid_filter */
104 u8 i2c_addrs[DIBUSB_POSSIBLE_I2C_ADDR_NUM]; /* list of possible i2c addresses of the demod */
105 };
106
107 #define DIBUSB_MAX_TUNER_NUM 2
108 struct dibusb_device_class {
109 dibusb_class_t id;
110
111 const struct dibusb_usb_controller *usb_ctrl; /* usb controller */
112 const char *firmware; /* valid firmware filenames */
113
114 int pipe_cmd; /* command pipe (read/write) */
115 int pipe_data; /* data pipe */
116
117 int urb_count; /* number of data URBs to be submitted */
118 int urb_buffer_size; /* the size of the buffer for each URB */
119
120 dibusb_remote_t remote_type; /* does this device have a ir-receiver */
121
122 struct dibusb_demod *demod; /* which demodulator is mount */
123 struct dibusb_tuner *tuner; /* which tuner can be found here */
124 };
125
126 #define DIBUSB_ID_MAX_NUM 15
127 struct dibusb_usb_device {
128 const char *name; /* real name of the box */
129 struct dibusb_device_class *dev_cl; /* which dibusb_device_class is this device part of */
130
131 struct usb_device_id *cold_ids[DIBUSB_ID_MAX_NUM]; /* list of USB ids when this device is at pre firmware state */
132 struct usb_device_id *warm_ids[DIBUSB_ID_MAX_NUM]; /* list of USB ids when this device is at post firmware state */
133 };
134
135 /* a PID for the pid_filter list, when in use */
136 struct dibusb_pid
137 {
138 int index;
139 u16 pid;
140 int active;
141 };
142
143 struct usb_dibusb {
144 /* usb */
145 struct usb_device * udev;
146
147 struct dibusb_usb_device * dibdev;
148
149 #define DIBUSB_STATE_INIT 0x000
150 #define DIBUSB_STATE_URB_LIST 0x001
151 #define DIBUSB_STATE_URB_BUF 0x002
152 #define DIBUSB_STATE_URB_SUBMIT 0x004
153 #define DIBUSB_STATE_DVB 0x008
154 #define DIBUSB_STATE_I2C 0x010
155 #define DIBUSB_STATE_REMOTE 0x020
156 #define DIBUSB_STATE_PIDLIST 0x040
157 int init_state;
158
159 int feedcount;
160 struct dib_fe_xfer_ops xfer_ops;
161
162 struct dibusb_tuner *tuner;
163
164 struct urb **urb_list;
165 u8 *buffer;
166 dma_addr_t dma_handle;
167
168 /* I2C */
169 struct i2c_adapter i2c_adap;
170
171 /* locking */
172 struct semaphore usb_sem;
173 struct semaphore i2c_sem;
174
175 /* pid filtering */
176 spinlock_t pid_list_lock;
177 struct dibusb_pid *pid_list;
178
179 /* dvb */
180 struct dvb_adapter *adapter;
181 struct dmxdev dmxdev;
182 struct dvb_demux demux;
183 struct dvb_net dvb_net;
184 struct dvb_frontend* fe;
185
186 int (*fe_sleep) (struct dvb_frontend *);
187 int (*fe_init) (struct dvb_frontend *);
188
189 /* remote control */
190 struct input_dev rc_input_dev;
191 struct work_struct rc_query_work;
192 int rc_input_event;
193
194 /* module parameters */
195 int pid_parse;
196 int rc_query_interval;
197 };
198
199 /* commonly used functions in the separated files */
200
201 /* dvb-dibusb-firmware.c */
202 int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_usb_device *dibdev);
203
204 /* dvb-dibusb-remote.c */
205 int dibusb_remote_exit(struct usb_dibusb *dib);
206 int dibusb_remote_init(struct usb_dibusb *dib);
207
208 /* dvb-dibusb-fe-i2c.c */
209 int dibusb_i2c_msg(struct usb_dibusb *dib, u8 addr,
210 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen);
211 int dibusb_fe_init(struct usb_dibusb* dib);
212 int dibusb_fe_exit(struct usb_dibusb *dib);
213 int dibusb_i2c_init(struct usb_dibusb *dib);
214 int dibusb_i2c_exit(struct usb_dibusb *dib);
215
216 /* dvb-dibusb-dvb.c */
217 void dibusb_urb_complete(struct urb *urb, struct pt_regs *ptregs);
218 int dibusb_dvb_init(struct usb_dibusb *dib);
219 int dibusb_dvb_exit(struct usb_dibusb *dib);
220
221 /* dvb-dibusb-usb.c */
222 int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf,
223 u16 rlen);
224
225 int dibusb_hw_wakeup(struct dvb_frontend *);
226 int dibusb_hw_sleep(struct dvb_frontend *);
227 int dibusb_set_streaming_mode(struct usb_dibusb *,u8);
228 int dibusb_streaming(struct usb_dibusb *,int);
229
230 int dibusb_urb_init(struct usb_dibusb *);
231 int dibusb_urb_exit(struct usb_dibusb *);
232
233 /* dvb-dibusb-pid.c */
234 int dibusb_pid_list_init(struct usb_dibusb *dib);
235 void dibusb_pid_list_exit(struct usb_dibusb *dib);
236 int dibusb_ctrl_pid(struct usb_dibusb *dib, struct dvb_demux_feed *dvbdmxfeed , int onoff);
237
238 /* i2c and transfer stuff */
239 #define DIBUSB_I2C_TIMEOUT HZ*5
240
241 /*
242 * protocol of all dibusb related devices
243 */
244
245 /*
246 * bulk msg to/from endpoint 0x01
247 *
248 * general structure:
249 * request_byte parameter_bytes
250 */
251
252 #define DIBUSB_REQ_START_READ 0x00
253 #define DIBUSB_REQ_START_DEMOD 0x01
254
255 /*
256 * i2c read
257 * bulk write: 0x02 ((7bit i2c_addr << 1) & 0x01) register_bytes length_word
258 * bulk read: byte_buffer (length_word bytes)
259 */
260 #define DIBUSB_REQ_I2C_READ 0x02
261
262 /*
263 * i2c write
264 * bulk write: 0x03 (7bit i2c_addr << 1) register_bytes value_bytes
265 */
266 #define DIBUSB_REQ_I2C_WRITE 0x03
267
268 /*
269 * polling the value of the remote control
270 * bulk write: 0x04
271 * bulk read: byte_buffer (5 bytes)
272 *
273 * first byte of byte_buffer shows the status (0x00, 0x01, 0x02)
274 */
275 #define DIBUSB_REQ_POLL_REMOTE 0x04
276
277 #define DIBUSB_RC_NEC_EMPTY 0x00
278 #define DIBUSB_RC_NEC_KEY_PRESSED 0x01
279 #define DIBUSB_RC_NEC_KEY_REPEATED 0x02
280
281 /* streaming mode:
282 * bulk write: 0x05 mode_byte
283 *
284 * mode_byte is mostly 0x00
285 */
286 #define DIBUSB_REQ_SET_STREAMING_MODE 0x05
287
288 /* interrupt the internal read loop, when blocking */
289 #define DIBUSB_REQ_INTR_READ 0x06
290
291 /* io control
292 * 0x07 cmd_byte param_bytes
293 *
294 * param_bytes can be up to 32 bytes
295 *
296 * cmd_byte function parameter name
297 * 0x00 power mode
298 * 0x00 sleep
299 * 0x01 wakeup
300 *
301 * 0x01 enable streaming
302 * 0x02 disable streaming
303 *
304 *
305 */
306 #define DIBUSB_REQ_SET_IOCTL 0x07
307
308 /* IOCTL commands */
309
310 /* change the power mode in firmware */
311 #define DIBUSB_IOCTL_CMD_POWER_MODE 0x00
312 #define DIBUSB_IOCTL_POWER_SLEEP 0x00
313 #define DIBUSB_IOCTL_POWER_WAKEUP 0x01
314
315 /* modify streaming of the FX2 */
316 #define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01
317 #define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02
318
319 #endif
320
|
This page was automatically generated by the
LXR engine.
|