V4L/DVB (7399): Removes video_dev from tuner-xc2028 config struct
[pandora-kernel.git] / drivers / media / dvb / dvb-usb / cxusb.c
1 /* DVB USB compliant linux driver for Conexant USB reference design.
2  *
3  * The Conexant reference design I saw on their website was only for analogue
4  * capturing (using the cx25842). The box I took to write this driver (reverse
5  * engineered) is the one labeled Medion MD95700. In addition to the cx25842
6  * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
7  * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
8  *
9  * Maybe it is a little bit premature to call this driver cxusb, but I assume
10  * the USB protocol is identical or at least inherited from the reference
11  * design, so it can be reused for the "analogue-only" device (if it will
12  * appear at all).
13  *
14  * TODO: Use the cx25840-driver for the analogue part
15  *
16  * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
17  * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
18  * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
19  *
20  *   This program is free software; you can redistribute it and/or modify it
21  *   under the terms of the GNU General Public License as published by the Free
22  *   Software Foundation, version 2.
23  *
24  * see Documentation/dvb/README.dvb-usb for more information
25  */
26 #include "cxusb.h"
27
28 #include "cx22702.h"
29 #include "lgdt330x.h"
30 #include "mt352.h"
31 #include "mt352_priv.h"
32 #include "zl10353.h"
33 #include "tuner-xc2028.h"
34 #include "tuner-xc2028-types.h"
35
36 /* debug */
37 static int dvb_usb_cxusb_debug;
38 module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
39 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
40 #define deb_info(args...)   dprintk(dvb_usb_cxusb_debug,0x01,args)
41 #define deb_i2c(args...)    if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
42                                 dprintk(dvb_usb_cxusb_debug,0x01,args)
43
44 static int cxusb_ctrl_msg(struct dvb_usb_device *d,
45                           u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
46 {
47         int wo = (rbuf == NULL || rlen == 0); /* write-only */
48         u8 sndbuf[1+wlen];
49         memset(sndbuf, 0, 1+wlen);
50
51         sndbuf[0] = cmd;
52         memcpy(&sndbuf[1], wbuf, wlen);
53         if (wo)
54                 return dvb_usb_generic_write(d, sndbuf, 1+wlen);
55         else
56                 return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
57 }
58
59 /* GPIO */
60 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
61 {
62         struct cxusb_state *st = d->priv;
63         u8 o[2], i;
64
65         if (st->gpio_write_state[GPIO_TUNER] == onoff)
66                 return;
67
68         o[0] = GPIO_TUNER;
69         o[1] = onoff;
70         cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
71
72         if (i != 0x01)
73                 deb_info("gpio_write failed.\n");
74
75         st->gpio_write_state[GPIO_TUNER] = onoff;
76 }
77
78 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
79                                  u8 newval)
80 {
81         u8 o[2], gpio_state;
82         int rc;
83
84         o[0] = 0xff & ~changemask;      /* mask of bits to keep */
85         o[1] = newval & changemask;     /* new values for bits  */
86
87         rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
88         if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
89                 deb_info("bluebird_gpio_write failed.\n");
90
91         return rc < 0 ? rc : gpio_state;
92 }
93
94 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
95 {
96         cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
97         msleep(5);
98         cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
99 }
100
101 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
102 {
103         cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
104 }
105
106 /* I2C */
107 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
108                           int num)
109 {
110         struct dvb_usb_device *d = i2c_get_adapdata(adap);
111         int i;
112
113         if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
114                 return -EAGAIN;
115
116         for (i = 0; i < num; i++) {
117
118                 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
119                         switch (msg[i].addr) {
120                         case 0x63:
121                                 cxusb_gpio_tuner(d, 0);
122                                 break;
123                         default:
124                                 cxusb_gpio_tuner(d, 1);
125                                 break;
126                         }
127
128                 if (msg[i].flags & I2C_M_RD) {
129                         /* read only */
130                         u8 obuf[3], ibuf[1+msg[i].len];
131                         obuf[0] = 0;
132                         obuf[1] = msg[i].len;
133                         obuf[2] = msg[i].addr;
134                         if (cxusb_ctrl_msg(d, CMD_I2C_READ,
135                                            obuf, 3,
136                                            ibuf, 1+msg[i].len) < 0) {
137                                 warn("i2c read failed");
138                                 break;
139                         }
140                         memcpy(msg[i].buf, &ibuf[1], msg[i].len);
141                 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
142                            msg[i].addr == msg[i+1].addr) {
143                         /* write to then read from same address */
144                         u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
145                         obuf[0] = msg[i].len;
146                         obuf[1] = msg[i+1].len;
147                         obuf[2] = msg[i].addr;
148                         memcpy(&obuf[3], msg[i].buf, msg[i].len);
149
150                         if (cxusb_ctrl_msg(d, CMD_I2C_READ,
151                                            obuf, 3+msg[i].len,
152                                            ibuf, 1+msg[i+1].len) < 0)
153                                 break;
154
155                         if (ibuf[0] != 0x08)
156                                 deb_i2c("i2c read may have failed\n");
157
158                         memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
159
160                         i++;
161                 } else {
162                         /* write only */
163                         u8 obuf[2+msg[i].len], ibuf;
164                         obuf[0] = msg[i].addr;
165                         obuf[1] = msg[i].len;
166                         memcpy(&obuf[2], msg[i].buf, msg[i].len);
167
168                         if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
169                                            2+msg[i].len, &ibuf,1) < 0)
170                                 break;
171                         if (ibuf != 0x08)
172                                 deb_i2c("i2c write may have failed\n");
173                 }
174         }
175
176         mutex_unlock(&d->i2c_mutex);
177         return i == num ? num : -EREMOTEIO;
178 }
179
180 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
181 {
182         return I2C_FUNC_I2C;
183 }
184
185 static struct i2c_algorithm cxusb_i2c_algo = {
186         .master_xfer   = cxusb_i2c_xfer,
187         .functionality = cxusb_i2c_func,
188 };
189
190 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
191 {
192         u8 b = 0;
193         if (onoff)
194                 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
195         else
196                 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
197 }
198
199 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
200 {
201         u8 b = 0;
202         if (onoff)
203                 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
204         else
205                 return 0;
206 }
207
208 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
209 {
210         int rc = 0;
211
212         rc = cxusb_power_ctrl(d, onoff);
213         if (!onoff)
214                 cxusb_nano2_led(d, 0);
215
216         return rc;
217 }
218
219 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
220 {
221         u8 buf[2] = { 0x03, 0x00 };
222         if (onoff)
223                 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
224         else
225                 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
226
227         return 0;
228 }
229
230 static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
231 {
232         struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
233         u8 ircode[4];
234         int i;
235
236         cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
237
238         *event = 0;
239         *state = REMOTE_NO_KEY_PRESSED;
240
241         for (i = 0; i < d->props.rc_key_map_size; i++) {
242                 if (keymap[i].custom == ircode[2] &&
243                     keymap[i].data == ircode[3]) {
244                         *event = keymap[i].event;
245                         *state = REMOTE_KEY_PRESSED;
246
247                         return 0;
248                 }
249         }
250
251         return 0;
252 }
253
254 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
255                                     int *state)
256 {
257         struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
258         u8 ircode[4];
259         int i;
260         struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
261                                .buf = ircode, .len = 4 };
262
263         *event = 0;
264         *state = REMOTE_NO_KEY_PRESSED;
265
266         if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
267                 return 0;
268
269         for (i = 0; i < d->props.rc_key_map_size; i++) {
270                 if (keymap[i].custom == ircode[1] &&
271                     keymap[i].data == ircode[2]) {
272                         *event = keymap[i].event;
273                         *state = REMOTE_KEY_PRESSED;
274
275                         return 0;
276                 }
277         }
278
279         return 0;
280 }
281
282 static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
283         { 0xfe, 0x02, KEY_TV },
284         { 0xfe, 0x0e, KEY_MP3 },
285         { 0xfe, 0x1a, KEY_DVD },
286         { 0xfe, 0x1e, KEY_FAVORITES },
287         { 0xfe, 0x16, KEY_SETUP },
288         { 0xfe, 0x46, KEY_POWER2 },
289         { 0xfe, 0x0a, KEY_EPG },
290         { 0xfe, 0x49, KEY_BACK },
291         { 0xfe, 0x4d, KEY_MENU },
292         { 0xfe, 0x51, KEY_UP },
293         { 0xfe, 0x5b, KEY_LEFT },
294         { 0xfe, 0x5f, KEY_RIGHT },
295         { 0xfe, 0x53, KEY_DOWN },
296         { 0xfe, 0x5e, KEY_OK },
297         { 0xfe, 0x59, KEY_INFO },
298         { 0xfe, 0x55, KEY_TAB },
299         { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
300         { 0xfe, 0x12, KEY_NEXTSONG },   /* Skip */
301         { 0xfe, 0x42, KEY_ENTER  },     /* Windows/Start */
302         { 0xfe, 0x15, KEY_VOLUMEUP },
303         { 0xfe, 0x05, KEY_VOLUMEDOWN },
304         { 0xfe, 0x11, KEY_CHANNELUP },
305         { 0xfe, 0x09, KEY_CHANNELDOWN },
306         { 0xfe, 0x52, KEY_CAMERA },
307         { 0xfe, 0x5a, KEY_TUNER },      /* Live */
308         { 0xfe, 0x19, KEY_OPEN },
309         { 0xfe, 0x0b, KEY_1 },
310         { 0xfe, 0x17, KEY_2 },
311         { 0xfe, 0x1b, KEY_3 },
312         { 0xfe, 0x07, KEY_4 },
313         { 0xfe, 0x50, KEY_5 },
314         { 0xfe, 0x54, KEY_6 },
315         { 0xfe, 0x48, KEY_7 },
316         { 0xfe, 0x4c, KEY_8 },
317         { 0xfe, 0x58, KEY_9 },
318         { 0xfe, 0x13, KEY_ANGLE },      /* Aspect */
319         { 0xfe, 0x03, KEY_0 },
320         { 0xfe, 0x1f, KEY_ZOOM },
321         { 0xfe, 0x43, KEY_REWIND },
322         { 0xfe, 0x47, KEY_PLAYPAUSE },
323         { 0xfe, 0x4f, KEY_FASTFORWARD },
324         { 0xfe, 0x57, KEY_MUTE },
325         { 0xfe, 0x0d, KEY_STOP },
326         { 0xfe, 0x01, KEY_RECORD },
327         { 0xfe, 0x4e, KEY_POWER },
328 };
329
330 static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
331         { 0xfc, 0x02, KEY_SETUP },       /* Profile */
332         { 0xfc, 0x43, KEY_POWER2 },
333         { 0xfc, 0x06, KEY_EPG },
334         { 0xfc, 0x5a, KEY_BACK },
335         { 0xfc, 0x05, KEY_MENU },
336         { 0xfc, 0x47, KEY_INFO },
337         { 0xfc, 0x01, KEY_TAB },
338         { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
339         { 0xfc, 0x49, KEY_VOLUMEUP },
340         { 0xfc, 0x09, KEY_VOLUMEDOWN },
341         { 0xfc, 0x54, KEY_CHANNELUP },
342         { 0xfc, 0x0b, KEY_CHANNELDOWN },
343         { 0xfc, 0x16, KEY_CAMERA },
344         { 0xfc, 0x40, KEY_TUNER },      /* ATV/DTV */
345         { 0xfc, 0x45, KEY_OPEN },
346         { 0xfc, 0x19, KEY_1 },
347         { 0xfc, 0x18, KEY_2 },
348         { 0xfc, 0x1b, KEY_3 },
349         { 0xfc, 0x1a, KEY_4 },
350         { 0xfc, 0x58, KEY_5 },
351         { 0xfc, 0x59, KEY_6 },
352         { 0xfc, 0x15, KEY_7 },
353         { 0xfc, 0x14, KEY_8 },
354         { 0xfc, 0x17, KEY_9 },
355         { 0xfc, 0x44, KEY_ANGLE },      /* Aspect */
356         { 0xfc, 0x55, KEY_0 },
357         { 0xfc, 0x07, KEY_ZOOM },
358         { 0xfc, 0x0a, KEY_REWIND },
359         { 0xfc, 0x08, KEY_PLAYPAUSE },
360         { 0xfc, 0x4b, KEY_FASTFORWARD },
361         { 0xfc, 0x5b, KEY_MUTE },
362         { 0xfc, 0x04, KEY_STOP },
363         { 0xfc, 0x56, KEY_RECORD },
364         { 0xfc, 0x57, KEY_POWER },
365         { 0xfc, 0x41, KEY_UNKNOWN },    /* INPUT */
366         { 0xfc, 0x00, KEY_UNKNOWN },    /* HD */
367 };
368
369 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
370 {
371         static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
372         static u8 reset []         = { RESET,      0x80 };
373         static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
374         static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0x20 };
375         static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
376         static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
377
378         mt352_write(fe, clock_config,   sizeof(clock_config));
379         udelay(200);
380         mt352_write(fe, reset,          sizeof(reset));
381         mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
382
383         mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
384         mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
385         mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
386
387         return 0;
388 }
389
390 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
391 {       /* used in both lgz201 and th7579 */
392         static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x29 };
393         static u8 reset []         = { RESET,      0x80 };
394         static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
395         static u8 agc_cfg []       = { AGC_TARGET, 0x24, 0x20 };
396         static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x33 };
397         static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
398
399         mt352_write(fe, clock_config,   sizeof(clock_config));
400         udelay(200);
401         mt352_write(fe, reset,          sizeof(reset));
402         mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
403
404         mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
405         mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
406         mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
407         return 0;
408 }
409
410 static struct cx22702_config cxusb_cx22702_config = {
411         .demod_address = 0x63,
412         .output_mode = CX22702_PARALLEL_OUTPUT,
413 };
414
415 static struct lgdt330x_config cxusb_lgdt3303_config = {
416         .demod_address = 0x0e,
417         .demod_chip    = LGDT3303,
418 };
419
420 static struct mt352_config cxusb_dee1601_config = {
421         .demod_address = 0x0f,
422         .demod_init    = cxusb_dee1601_demod_init,
423 };
424
425 static struct zl10353_config cxusb_zl10353_dee1601_config = {
426         .demod_address = 0x0f,
427         .parallel_ts = 1,
428 };
429
430 static struct mt352_config cxusb_mt352_config = {
431         /* used in both lgz201 and th7579 */
432         .demod_address = 0x0f,
433         .demod_init    = cxusb_mt352_demod_init,
434 };
435
436 static struct zl10353_config cxusb_zl10353_xc3028_config = {
437         .demod_address = 0x0f,
438         .if2 = 45600,
439         .no_tuner = 1,
440         .parallel_ts = 1,
441 };
442
443 static struct mt352_config cxusb_mt352_xc3028_config = {
444         .demod_address = 0x0f,
445         .if2 = 4560,
446         .no_tuner = 1,
447         .demod_init = cxusb_mt352_demod_init,
448 };
449
450 /* Callbacks for DVB USB */
451 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
452 {
453         dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
454                    DVB_PLL_FMD1216ME);
455         return 0;
456 }
457
458 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
459 {
460         dvb_attach(dvb_pll_attach, adap->fe, 0x61,
461                    NULL, DVB_PLL_THOMSON_DTT7579);
462         return 0;
463 }
464
465 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
466 {
467         dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
468         return 0;
469 }
470
471 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
472 {
473         dvb_attach(dvb_pll_attach, adap->fe, 0x60,
474                    NULL, DVB_PLL_THOMSON_DTT7579);
475         return 0;
476 }
477
478 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
479 {
480         dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
481                    DVB_PLL_LG_TDVS_H06XF);
482         return 0;
483 }
484
485 static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
486 {
487         struct dvb_usb_device *d = ptr;
488
489         switch (command) {
490         case XC2028_TUNER_RESET:
491                 deb_info("%s: XC2028_TUNER_RESET %d\n", __FUNCTION__, arg);
492                 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
493                 break;
494         case XC2028_RESET_CLK:
495                 deb_info("%s: XC2028_RESET_CLK %d\n", __FUNCTION__, arg);
496                 break;
497         default:
498                 deb_info("%s: unknown command %d, arg %d\n", __FUNCTION__,
499                          command, arg);
500                 return -EINVAL;
501         }
502
503         return 0;
504 }
505
506 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
507 {
508         struct dvb_frontend      *fe;
509         struct xc2028_config      cfg = {
510                 .i2c_adap  = &adap->dev->i2c_adap,
511                 .i2c_addr  = 0x61,
512                 .callback  = dvico_bluebird_xc2028_callback,
513         };
514         static struct xc2028_ctrl ctl = {
515                 .fname       = "xc3028-dvico-au-01.fw",
516                 .max_len     = 64,
517                 .scode_table = ZARLINK456,
518         };
519
520         fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
521         if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
522                 return -EIO;
523
524         fe->ops.tuner_ops.set_config(fe, &ctl);
525
526         return 0;
527 }
528
529 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
530 {
531         u8 b;
532         if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
533                 err("set interface failed");
534
535         cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
536
537         if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
538                                    &adap->dev->i2c_adap)) != NULL)
539                 return 0;
540
541         return -EIO;
542 }
543
544 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
545 {
546         if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
547                 err("set interface failed");
548
549         cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
550
551         if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
552                                    &adap->dev->i2c_adap)) != NULL)
553                 return 0;
554
555         return -EIO;
556 }
557
558 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
559 {
560         /* used in both lgz201 and th7579 */
561         if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
562                 err("set interface failed");
563
564         cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
565
566         if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
567                                    &adap->dev->i2c_adap)) != NULL)
568                 return 0;
569
570         return -EIO;
571 }
572
573 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
574 {
575         if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
576                 err("set interface failed");
577
578         cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
579
580         if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
581                                     &adap->dev->i2c_adap)) != NULL) ||
582                 ((adap->fe = dvb_attach(zl10353_attach,
583                                         &cxusb_zl10353_dee1601_config,
584                                         &adap->dev->i2c_adap)) != NULL))
585                 return 0;
586
587         return -EIO;
588 }
589
590 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
591 {
592         u8 ircode[4];
593         int i;
594         struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
595                                .buf = ircode, .len = 4 };
596
597         if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
598                 err("set interface failed");
599
600         cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
601
602         /* reset the tuner and demodulator */
603         cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
604         cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
605         cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
606
607         if ((adap->fe = dvb_attach(zl10353_attach,
608                                    &cxusb_zl10353_xc3028_config,
609                                    &adap->dev->i2c_adap)) == NULL)
610                 return -EIO;
611
612         /* try to determine if there is no IR decoder on the I2C bus */
613         for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
614                 msleep(20);
615                 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
616                         goto no_IR;
617                 if (ircode[0] == 0 && ircode[1] == 0)
618                         continue;
619                 if (ircode[2] + ircode[3] != 0xff) {
620 no_IR:
621                         adap->dev->props.rc_key_map = NULL;
622                         info("No IR receiver detected on this device.");
623                         break;
624                 }
625         }
626
627         return 0;
628 }
629
630 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
631 {
632         if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
633                 err("set interface failed");
634
635         cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
636
637         /* reset the tuner and demodulator */
638         cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
639         cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
640         cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
641
642         if ((adap->fe = dvb_attach(zl10353_attach,
643                                    &cxusb_zl10353_xc3028_config,
644                                    &adap->dev->i2c_adap)) != NULL)
645                 return 0;
646
647         if ((adap->fe = dvb_attach(mt352_attach,
648                                    &cxusb_mt352_xc3028_config,
649                                    &adap->dev->i2c_adap)) != NULL)
650                 return 0;
651
652         return -EIO;
653 }
654
655 /*
656  * DViCO has shipped two devices with the same USB ID, but only one of them
657  * needs a firmware download.  Check the device class details to see if they
658  * have non-default values to decide whether the device is actually cold or
659  * not, and forget a match if it turns out we selected the wrong device.
660  */
661 static int bluebird_fx2_identify_state(struct usb_device *udev,
662                                        struct dvb_usb_device_properties *props,
663                                        struct dvb_usb_device_description **desc,
664                                        int *cold)
665 {
666         int wascold = *cold;
667
668         *cold = udev->descriptor.bDeviceClass == 0xff &&
669                 udev->descriptor.bDeviceSubClass == 0xff &&
670                 udev->descriptor.bDeviceProtocol == 0xff;
671
672         if (*cold && !wascold)
673                 *desc = NULL;
674
675         return 0;
676 }
677
678 /*
679  * DViCO bluebird firmware needs the "warm" product ID to be patched into the
680  * firmware file before download.
681  */
682
683 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
684 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
685                                                   const struct firmware *fw)
686 {
687         int pos;
688
689         for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
690                 int idoff = dvico_firmware_id_offsets[pos];
691
692                 if (fw->size < idoff + 4)
693                         continue;
694
695                 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
696                     fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
697                         fw->data[idoff + 2] =
698                                 le16_to_cpu(udev->descriptor.idProduct) + 1;
699                         fw->data[idoff + 3] =
700                                 le16_to_cpu(udev->descriptor.idProduct) >> 8;
701
702                         return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
703                 }
704         }
705
706         return -EINVAL;
707 }
708
709 /* DVB USB Driver stuff */
710 static struct dvb_usb_device_properties cxusb_medion_properties;
711 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
712 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
713 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
714 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
715 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
716 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
717 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
718
719 static int cxusb_probe(struct usb_interface *intf,
720                        const struct usb_device_id *id)
721 {
722         if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
723                 dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
724                 dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
725                 dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
726                 dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0 ||
727                 dvb_usb_device_init(intf,&cxusb_bluebird_dualdig4_properties,THIS_MODULE,NULL) == 0 ||
728                 dvb_usb_device_init(intf,&cxusb_bluebird_nano2_properties,THIS_MODULE,NULL) == 0 ||
729                 dvb_usb_device_init(intf,&cxusb_bluebird_nano2_needsfirmware_properties,THIS_MODULE,NULL) == 0) {
730                 return 0;
731         }
732
733         return -EINVAL;
734 }
735
736 static struct usb_device_id cxusb_table [] = {
737         { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
738         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
739         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
740         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
741         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
742         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
743         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
744         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
745         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
746         { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
747         { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
748         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
749         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
750         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
751         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
752         { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
753         {}              /* Terminating entry */
754 };
755 MODULE_DEVICE_TABLE (usb, cxusb_table);
756
757 static struct dvb_usb_device_properties cxusb_medion_properties = {
758         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
759
760         .usb_ctrl = CYPRESS_FX2,
761
762         .size_of_priv     = sizeof(struct cxusb_state),
763
764         .num_adapters = 1,
765         .adapter = {
766                 {
767                         .streaming_ctrl   = cxusb_streaming_ctrl,
768                         .frontend_attach  = cxusb_cx22702_frontend_attach,
769                         .tuner_attach     = cxusb_fmd1216me_tuner_attach,
770                         /* parameter for the MPEG2-data transfer */
771                                         .stream = {
772                                                 .type = USB_BULK,
773                                 .count = 5,
774                                 .endpoint = 0x02,
775                                 .u = {
776                                         .bulk = {
777                                                 .buffersize = 8192,
778                                         }
779                                 }
780                         },
781
782                 },
783         },
784         .power_ctrl       = cxusb_power_ctrl,
785
786         .i2c_algo         = &cxusb_i2c_algo,
787
788         .generic_bulk_ctrl_endpoint = 0x01,
789
790         .num_device_descs = 1,
791         .devices = {
792                 {   "Medion MD95700 (MDUSBTV-HYBRID)",
793                         { NULL },
794                         { &cxusb_table[0], NULL },
795                 },
796         }
797 };
798
799 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
800         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
801
802         .usb_ctrl          = DEVICE_SPECIFIC,
803         .firmware          = "dvb-usb-bluebird-01.fw",
804         .download_firmware = bluebird_patch_dvico_firmware_download,
805         /* use usb alt setting 0 for EP4 transfer (dvb-t),
806            use usb alt setting 7 for EP2 transfer (atsc) */
807
808         .size_of_priv     = sizeof(struct cxusb_state),
809
810         .num_adapters = 1,
811         .adapter = {
812                 {
813                         .streaming_ctrl   = cxusb_streaming_ctrl,
814                         .frontend_attach  = cxusb_lgdt3303_frontend_attach,
815                         .tuner_attach     = cxusb_lgh064f_tuner_attach,
816
817                         /* parameter for the MPEG2-data transfer */
818                                         .stream = {
819                                                 .type = USB_BULK,
820                                 .count = 5,
821                                 .endpoint = 0x02,
822                                 .u = {
823                                         .bulk = {
824                                                 .buffersize = 8192,
825                                         }
826                                 }
827                         },
828                 },
829         },
830
831         .power_ctrl       = cxusb_bluebird_power_ctrl,
832
833         .i2c_algo         = &cxusb_i2c_algo,
834
835         .rc_interval      = 100,
836         .rc_key_map       = dvico_portable_rc_keys,
837         .rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
838         .rc_query         = cxusb_rc_query,
839
840         .generic_bulk_ctrl_endpoint = 0x01,
841
842         .num_device_descs = 1,
843         .devices = {
844                 {   "DViCO FusionHDTV5 USB Gold",
845                         { &cxusb_table[1], NULL },
846                         { &cxusb_table[2], NULL },
847                 },
848         }
849 };
850
851 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
852         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
853
854         .usb_ctrl          = DEVICE_SPECIFIC,
855         .firmware          = "dvb-usb-bluebird-01.fw",
856         .download_firmware = bluebird_patch_dvico_firmware_download,
857         /* use usb alt setting 0 for EP4 transfer (dvb-t),
858            use usb alt setting 7 for EP2 transfer (atsc) */
859
860         .size_of_priv     = sizeof(struct cxusb_state),
861
862         .num_adapters = 1,
863         .adapter = {
864                 {
865                         .streaming_ctrl   = cxusb_streaming_ctrl,
866                         .frontend_attach  = cxusb_dee1601_frontend_attach,
867                         .tuner_attach     = cxusb_dee1601_tuner_attach,
868                         /* parameter for the MPEG2-data transfer */
869                         .stream = {
870                                 .type = USB_BULK,
871                                 .count = 5,
872                                 .endpoint = 0x04,
873                                 .u = {
874                                         .bulk = {
875                                                 .buffersize = 8192,
876                                         }
877                                 }
878                         },
879                 },
880         },
881
882         .power_ctrl       = cxusb_bluebird_power_ctrl,
883
884         .i2c_algo         = &cxusb_i2c_algo,
885
886         .rc_interval      = 150,
887         .rc_key_map       = dvico_mce_rc_keys,
888         .rc_key_map_size  = ARRAY_SIZE(dvico_mce_rc_keys),
889         .rc_query         = cxusb_rc_query,
890
891         .generic_bulk_ctrl_endpoint = 0x01,
892
893         .num_device_descs = 3,
894         .devices = {
895                 {   "DViCO FusionHDTV DVB-T Dual USB",
896                         { &cxusb_table[3], NULL },
897                         { &cxusb_table[4], NULL },
898                 },
899                 {   "DigitalNow DVB-T Dual USB",
900                         { &cxusb_table[9],  NULL },
901                         { &cxusb_table[10], NULL },
902                 },
903                 {   "DViCO FusionHDTV DVB-T Dual Digital 2",
904                         { &cxusb_table[11], NULL },
905                         { &cxusb_table[12], NULL },
906                 },
907         }
908 };
909
910 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
911         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
912
913         .usb_ctrl          = DEVICE_SPECIFIC,
914         .firmware          = "dvb-usb-bluebird-01.fw",
915         .download_firmware = bluebird_patch_dvico_firmware_download,
916         /* use usb alt setting 0 for EP4 transfer (dvb-t),
917            use usb alt setting 7 for EP2 transfer (atsc) */
918
919         .size_of_priv     = sizeof(struct cxusb_state),
920
921         .num_adapters = 2,
922         .adapter = {
923                 {
924                         .streaming_ctrl   = cxusb_streaming_ctrl,
925                         .frontend_attach  = cxusb_mt352_frontend_attach,
926                         .tuner_attach     = cxusb_lgz201_tuner_attach,
927
928                         /* parameter for the MPEG2-data transfer */
929                         .stream = {
930                                 .type = USB_BULK,
931                                 .count = 5,
932                                 .endpoint = 0x04,
933                                 .u = {
934                                         .bulk = {
935                                                 .buffersize = 8192,
936                                         }
937                                 }
938                         },
939                 },
940         },
941         .power_ctrl       = cxusb_bluebird_power_ctrl,
942
943         .i2c_algo         = &cxusb_i2c_algo,
944
945         .rc_interval      = 100,
946         .rc_key_map       = dvico_portable_rc_keys,
947         .rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
948         .rc_query         = cxusb_rc_query,
949
950         .generic_bulk_ctrl_endpoint = 0x01,
951         .num_device_descs = 1,
952         .devices = {
953                 {   "DViCO FusionHDTV DVB-T USB (LGZ201)",
954                         { &cxusb_table[5], NULL },
955                         { &cxusb_table[6], NULL },
956                 },
957         }
958 };
959
960 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
961         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
962
963         .usb_ctrl          = DEVICE_SPECIFIC,
964         .firmware          = "dvb-usb-bluebird-01.fw",
965         .download_firmware = bluebird_patch_dvico_firmware_download,
966         /* use usb alt setting 0 for EP4 transfer (dvb-t),
967            use usb alt setting 7 for EP2 transfer (atsc) */
968
969         .size_of_priv     = sizeof(struct cxusb_state),
970
971         .num_adapters = 1,
972         .adapter = {
973                 {
974                         .streaming_ctrl   = cxusb_streaming_ctrl,
975                         .frontend_attach  = cxusb_mt352_frontend_attach,
976                         .tuner_attach     = cxusb_dtt7579_tuner_attach,
977
978                         /* parameter for the MPEG2-data transfer */
979                         .stream = {
980                                 .type = USB_BULK,
981                                 .count = 5,
982                                 .endpoint = 0x04,
983                                 .u = {
984                                         .bulk = {
985                                                 .buffersize = 8192,
986                                         }
987                                 }
988                         },
989                 },
990         },
991         .power_ctrl       = cxusb_bluebird_power_ctrl,
992
993         .i2c_algo         = &cxusb_i2c_algo,
994
995         .rc_interval      = 100,
996         .rc_key_map       = dvico_portable_rc_keys,
997         .rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
998         .rc_query         = cxusb_rc_query,
999
1000         .generic_bulk_ctrl_endpoint = 0x01,
1001
1002         .num_device_descs = 1,
1003         .devices = {
1004                 {   "DViCO FusionHDTV DVB-T USB (TH7579)",
1005                         { &cxusb_table[7], NULL },
1006                         { &cxusb_table[8], NULL },
1007                 },
1008         }
1009 };
1010
1011 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1012         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1013
1014         .usb_ctrl         = CYPRESS_FX2,
1015
1016         .size_of_priv     = sizeof(struct cxusb_state),
1017
1018         .num_adapters = 1,
1019         .adapter = {
1020                 {
1021                         .streaming_ctrl   = cxusb_streaming_ctrl,
1022                         .frontend_attach  = cxusb_dualdig4_frontend_attach,
1023                         .tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
1024                         /* parameter for the MPEG2-data transfer */
1025                         .stream = {
1026                                 .type = USB_BULK,
1027                                 .count = 5,
1028                                 .endpoint = 0x02,
1029                                 .u = {
1030                                         .bulk = {
1031                                                 .buffersize = 8192,
1032                                         }
1033                                 }
1034                         },
1035                 },
1036         },
1037
1038         .power_ctrl       = cxusb_power_ctrl,
1039
1040         .i2c_algo         = &cxusb_i2c_algo,
1041
1042         .generic_bulk_ctrl_endpoint = 0x01,
1043
1044         .rc_interval      = 100,
1045         .rc_key_map       = dvico_mce_rc_keys,
1046         .rc_key_map_size  = ARRAY_SIZE(dvico_mce_rc_keys),
1047         .rc_query         = cxusb_bluebird2_rc_query,
1048
1049         .num_device_descs = 1,
1050         .devices = {
1051                 {   "DViCO FusionHDTV DVB-T Dual Digital 4",
1052                         { NULL },
1053                         { &cxusb_table[13], NULL },
1054                 },
1055         }
1056 };
1057
1058 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1059         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1060
1061         .usb_ctrl         = CYPRESS_FX2,
1062         .identify_state   = bluebird_fx2_identify_state,
1063
1064         .size_of_priv     = sizeof(struct cxusb_state),
1065
1066         .num_adapters = 1,
1067         .adapter = {
1068                 {
1069                         .streaming_ctrl   = cxusb_streaming_ctrl,
1070                         .frontend_attach  = cxusb_nano2_frontend_attach,
1071                         .tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
1072                         /* parameter for the MPEG2-data transfer */
1073                         .stream = {
1074                                 .type = USB_BULK,
1075                                 .count = 5,
1076                                 .endpoint = 0x02,
1077                                 .u = {
1078                                         .bulk = {
1079                                                 .buffersize = 8192,
1080                                         }
1081                                 }
1082                         },
1083                 },
1084         },
1085
1086         .power_ctrl       = cxusb_nano2_power_ctrl,
1087
1088         .i2c_algo         = &cxusb_i2c_algo,
1089
1090         .generic_bulk_ctrl_endpoint = 0x01,
1091
1092         .rc_interval      = 100,
1093         .rc_key_map       = dvico_portable_rc_keys,
1094         .rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
1095         .rc_query         = cxusb_bluebird2_rc_query,
1096
1097         .num_device_descs = 1,
1098         .devices = {
1099                 {   "DViCO FusionHDTV DVB-T NANO2",
1100                         { NULL },
1101                         { &cxusb_table[14], NULL },
1102                 },
1103         }
1104 };
1105
1106 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1107         .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1108
1109         .usb_ctrl          = DEVICE_SPECIFIC,
1110         .firmware          = "dvb-usb-bluebird-02.fw",
1111         .download_firmware = bluebird_patch_dvico_firmware_download,
1112         .identify_state    = bluebird_fx2_identify_state,
1113
1114         .size_of_priv      = sizeof(struct cxusb_state),
1115
1116         .num_adapters = 1,
1117         .adapter = {
1118                 {
1119                         .streaming_ctrl   = cxusb_streaming_ctrl,
1120                         .frontend_attach  = cxusb_nano2_frontend_attach,
1121                         .tuner_attach     = cxusb_dvico_xc3028_tuner_attach,
1122                         /* parameter for the MPEG2-data transfer */
1123                         .stream = {
1124                                 .type = USB_BULK,
1125                                 .count = 5,
1126                                 .endpoint = 0x02,
1127                                 .u = {
1128                                         .bulk = {
1129                                                 .buffersize = 8192,
1130                                         }
1131                                 }
1132                         },
1133                 },
1134         },
1135
1136         .power_ctrl       = cxusb_nano2_power_ctrl,
1137
1138         .i2c_algo         = &cxusb_i2c_algo,
1139
1140         .generic_bulk_ctrl_endpoint = 0x01,
1141
1142         .rc_interval      = 100,
1143         .rc_key_map       = dvico_portable_rc_keys,
1144         .rc_key_map_size  = ARRAY_SIZE(dvico_portable_rc_keys),
1145         .rc_query         = cxusb_rc_query,
1146
1147         .num_device_descs = 1,
1148         .devices = {
1149                 {   "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1150                         { &cxusb_table[14], NULL },
1151                         { &cxusb_table[15], NULL },
1152                 },
1153         }
1154 };
1155
1156 static struct usb_driver cxusb_driver = {
1157         .name           = "dvb_usb_cxusb",
1158         .probe          = cxusb_probe,
1159         .disconnect     = dvb_usb_device_exit,
1160         .id_table       = cxusb_table,
1161 };
1162
1163 /* module stuff */
1164 static int __init cxusb_module_init(void)
1165 {
1166         int result;
1167         if ((result = usb_register(&cxusb_driver))) {
1168                 err("usb_register failed. Error number %d",result);
1169                 return result;
1170         }
1171
1172         return 0;
1173 }
1174
1175 static void __exit cxusb_module_exit(void)
1176 {
1177         /* deregister this driver from the USB subsystem */
1178         usb_deregister(&cxusb_driver);
1179 }
1180
1181 module_init (cxusb_module_init);
1182 module_exit (cxusb_module_exit);
1183
1184 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
1185 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
1186 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
1187 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1188 MODULE_VERSION("1.0-alpha");
1189 MODULE_LICENSE("GPL");