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