[XFRM]: skb_cow_data() does not set proper owner for new skbs.
[linux-2.6/verdex.git] / drivers / media / dvb / dibusb / dvb-dibusb.h
blobc965b64fb1ab61c37f39f0f8955cbb8d497444cb
1 /*
2 * dvb-dibusb.h
4 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
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.
10 * for more information see dvb-dibusb-core.c .
12 #ifndef __DVB_DIBUSB_H__
13 #define __DVB_DIBUSB_H__
15 #include <linux/input.h>
16 #include <linux/config.h>
17 #include <linux/usb.h>
19 #include "dvb_frontend.h"
20 #include "dvb_demux.h"
21 #include "dvb_net.h"
22 #include "dmxdev.h"
24 #include "dib3000.h"
25 #include "mt352.h"
27 /* debug */
28 #ifdef CONFIG_DVB_DIBCOM_DEBUG
29 #define dprintk(level,args...) \
30 do { if ((dvb_dibusb_debug & level)) { printk(args); } } while (0)
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");\
38 #else
39 #define dprintk(args...)
40 #define debug_dump(b,l)
41 #endif
43 extern int dvb_dibusb_debug;
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"
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)
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)
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. */
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;
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;
87 typedef enum {
88 DIBUSB_DIB3000MB = 0,
89 DIBUSB_DIB3000MC,
90 DIBUSB_MT352,
91 DTT200U_FE,
92 } dibusb_demodulator_t;
94 typedef enum {
95 DIBUSB_RC_NO = 0,
96 DIBUSB_RC_NEC_PROTOCOL,
97 DIBUSB_RC_HAUPPAUGE_PROTO,
98 } dibusb_remote_t;
100 struct dibusb_tuner {
101 dibusb_tuner_t id;
103 u8 pll_addr; /* tuner i2c address */
105 extern struct dibusb_tuner dibusb_tuner[];
107 #define DIBUSB_POSSIBLE_I2C_ADDR_NUM 4
108 struct dibusb_demod {
109 dibusb_demodulator_t id;
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 */
115 #define DIBUSB_MAX_TUNER_NUM 2
116 struct dibusb_device_class {
117 dibusb_class_t id;
119 const struct dibusb_usb_controller *usb_ctrl; /* usb controller */
120 const char *firmware; /* valid firmware filenames */
122 int pipe_cmd; /* command pipe (read/write) */
123 int pipe_data; /* data pipe */
125 int urb_count; /* number of data URBs to be submitted */
126 int urb_buffer_size; /* the size of the buffer for each URB */
128 dibusb_remote_t remote_type; /* does this device have a ir-receiver */
130 struct dibusb_demod *demod; /* which demodulator is mount */
131 struct dibusb_tuner *tuner; /* which tuner can be found here */
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 */
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 */
143 /* a PID for the pid_filter list, when in use */
144 struct dibusb_pid
146 int index;
147 u16 pid;
148 int active;
151 struct usb_dibusb {
152 /* usb */
153 struct usb_device * udev;
155 struct dibusb_usb_device * dibdev;
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;
167 int feedcount;
168 struct dib_fe_xfer_ops xfer_ops;
170 struct dibusb_tuner *tuner;
172 struct urb **urb_list;
173 u8 *buffer;
174 dma_addr_t dma_handle;
176 /* I2C */
177 struct i2c_adapter i2c_adap;
179 /* locking */
180 struct semaphore usb_sem;
181 struct semaphore i2c_sem;
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;
190 int (*fe_sleep) (struct dvb_frontend *);
191 int (*fe_init) (struct dvb_frontend *);
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 */
201 /* module parameters */
202 int pid_parse;
203 int rc_query_interval;
206 /* commonly used functions in the separated files */
208 /* dvb-dibusb-firmware.c */
209 int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_usb_device *dibdev);
211 /* dvb-dibusb-remote.c */
212 int dibusb_remote_exit(struct usb_dibusb *dib);
213 int dibusb_remote_init(struct usb_dibusb *dib);
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);
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);
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);
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);
236 int dibusb_urb_init(struct usb_dibusb *);
237 int dibusb_urb_exit(struct usb_dibusb *);
239 /* dvb-fe-dtt200u.c */
240 struct dvb_frontend* dtt200u_fe_attach(struct usb_dibusb *,struct dib_fe_xfer_ops *);
242 /* i2c and transfer stuff */
243 #define DIBUSB_I2C_TIMEOUT 5000
246 * protocol of all dibusb related devices
250 * bulk msg to/from endpoint 0x01
252 * general structure:
253 * request_byte parameter_bytes
256 #define DIBUSB_REQ_START_READ 0x00
257 #define DIBUSB_REQ_START_DEMOD 0x01
260 * i2c read
261 * bulk write: 0x02 ((7bit i2c_addr << 1) & 0x01) register_bytes length_word
262 * bulk read: byte_buffer (length_word bytes)
264 #define DIBUSB_REQ_I2C_READ 0x02
267 * i2c write
268 * bulk write: 0x03 (7bit i2c_addr << 1) register_bytes value_bytes
270 #define DIBUSB_REQ_I2C_WRITE 0x03
273 * polling the value of the remote control
274 * bulk write: 0x04
275 * bulk read: byte_buffer (5 bytes)
277 * first byte of byte_buffer shows the status (0x00, 0x01, 0x02)
279 #define DIBUSB_REQ_POLL_REMOTE 0x04
281 #define DIBUSB_RC_NEC_EMPTY 0x00
282 #define DIBUSB_RC_NEC_KEY_PRESSED 0x01
283 #define DIBUSB_RC_NEC_KEY_REPEATED 0x02
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
289 /* streaming mode:
290 * bulk write: 0x05 mode_byte
292 * mode_byte is mostly 0x00
294 #define DIBUSB_REQ_SET_STREAMING_MODE 0x05
296 /* interrupt the internal read loop, when blocking */
297 #define DIBUSB_REQ_INTR_READ 0x06
299 /* io control
300 * 0x07 cmd_byte param_bytes
302 * param_bytes can be up to 32 bytes
304 * cmd_byte function parameter name
305 * 0x00 power mode
306 * 0x00 sleep
307 * 0x01 wakeup
309 * 0x01 enable streaming
310 * 0x02 disable streaming
314 #define DIBUSB_REQ_SET_IOCTL 0x07
316 /* IOCTL commands */
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
323 /* modify streaming of the FX2 */
324 #define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01
325 #define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02
327 #endif