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