GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / media / dvb / dvb-usb / cxusb.c
blobbd2b95b5575e7ee537584e8a75c3d5628688e285
1 /* DVB USB compliant linux driver for Conexant USB reference design.
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.
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).
14 * TODO: Use the cx25840-driver for the analogue part
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)
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.
24 * see Documentation/dvb/README.dvb-usb for more information
26 #include <media/tuner.h>
27 #include <linux/vmalloc.h>
28 #include <linux/slab.h>
30 #include "cxusb.h"
32 #include "cx22702.h"
33 #include "lgdt330x.h"
34 #include "mt352.h"
35 #include "mt352_priv.h"
36 #include "zl10353.h"
37 #include "tuner-xc2028.h"
38 #include "tuner-simple.h"
39 #include "mxl5005s.h"
40 #include "max2165.h"
41 #include "dib7000p.h"
42 #include "dib0070.h"
43 #include "lgs8gxx.h"
44 #include "atbm8830.h"
46 /* debug */
47 static int dvb_usb_cxusb_debug;
48 module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
49 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
51 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
53 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
54 #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
56 static int cxusb_ctrl_msg(struct dvb_usb_device *d,
57 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
59 int wo = (rbuf == NULL || rlen == 0); /* write-only */
60 u8 sndbuf[1+wlen];
61 memset(sndbuf, 0, 1+wlen);
63 sndbuf[0] = cmd;
64 memcpy(&sndbuf[1], wbuf, wlen);
65 if (wo)
66 return dvb_usb_generic_write(d, sndbuf, 1+wlen);
67 else
68 return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
71 /* GPIO */
72 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
74 struct cxusb_state *st = d->priv;
75 u8 o[2], i;
77 if (st->gpio_write_state[GPIO_TUNER] == onoff)
78 return;
80 o[0] = GPIO_TUNER;
81 o[1] = onoff;
82 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
84 if (i != 0x01)
85 deb_info("gpio_write failed.\n");
87 st->gpio_write_state[GPIO_TUNER] = onoff;
90 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
91 u8 newval)
93 u8 o[2], gpio_state;
94 int rc;
96 o[0] = 0xff & ~changemask; /* mask of bits to keep */
97 o[1] = newval & changemask; /* new values for bits */
99 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
100 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
101 deb_info("bluebird_gpio_write failed.\n");
103 return rc < 0 ? rc : gpio_state;
106 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
108 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
109 msleep(5);
110 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
113 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
115 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
118 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
119 u8 addr, int onoff)
121 u8 o[2] = {addr, onoff};
122 u8 i;
123 int rc;
125 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
127 if (rc < 0)
128 return rc;
129 if (i == 0x01)
130 return 0;
131 else {
132 deb_info("gpio_write failed.\n");
133 return -EIO;
137 /* I2C */
138 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
139 int num)
141 struct dvb_usb_device *d = i2c_get_adapdata(adap);
142 int i;
144 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
145 return -EAGAIN;
147 for (i = 0; i < num; i++) {
149 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
150 switch (msg[i].addr) {
151 case 0x63:
152 cxusb_gpio_tuner(d, 0);
153 break;
154 default:
155 cxusb_gpio_tuner(d, 1);
156 break;
159 if (msg[i].flags & I2C_M_RD) {
160 /* read only */
161 u8 obuf[3], ibuf[1+msg[i].len];
162 obuf[0] = 0;
163 obuf[1] = msg[i].len;
164 obuf[2] = msg[i].addr;
165 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
166 obuf, 3,
167 ibuf, 1+msg[i].len) < 0) {
168 warn("i2c read failed");
169 break;
171 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
172 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
173 msg[i].addr == msg[i+1].addr) {
174 /* write to then read from same address */
175 u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
176 obuf[0] = msg[i].len;
177 obuf[1] = msg[i+1].len;
178 obuf[2] = msg[i].addr;
179 memcpy(&obuf[3], msg[i].buf, msg[i].len);
181 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
182 obuf, 3+msg[i].len,
183 ibuf, 1+msg[i+1].len) < 0)
184 break;
186 if (ibuf[0] != 0x08)
187 deb_i2c("i2c read may have failed\n");
189 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
191 i++;
192 } else {
193 /* write only */
194 u8 obuf[2+msg[i].len], ibuf;
195 obuf[0] = msg[i].addr;
196 obuf[1] = msg[i].len;
197 memcpy(&obuf[2], msg[i].buf, msg[i].len);
199 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
200 2+msg[i].len, &ibuf,1) < 0)
201 break;
202 if (ibuf != 0x08)
203 deb_i2c("i2c write may have failed\n");
207 mutex_unlock(&d->i2c_mutex);
208 return i == num ? num : -EREMOTEIO;
211 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
213 return I2C_FUNC_I2C;
216 static struct i2c_algorithm cxusb_i2c_algo = {
217 .master_xfer = cxusb_i2c_xfer,
218 .functionality = cxusb_i2c_func,
221 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
223 u8 b = 0;
224 if (onoff)
225 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
226 else
227 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
230 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
232 int ret;
233 if (!onoff)
234 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
235 if (d->state == DVB_USB_STATE_INIT &&
236 usb_set_interface(d->udev, 0, 0) < 0)
237 err("set interface failed");
238 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
239 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
240 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
241 if (!ret) {
242 int i;
243 u8 buf, bufs[] = {
244 0x0e, 0x2, 0x00, 0x7f,
245 0x0e, 0x2, 0x02, 0xfe,
246 0x0e, 0x2, 0x02, 0x01,
247 0x0e, 0x2, 0x00, 0x03,
248 0x0e, 0x2, 0x0d, 0x40,
249 0x0e, 0x2, 0x0e, 0x87,
250 0x0e, 0x2, 0x0f, 0x8e,
251 0x0e, 0x2, 0x10, 0x01,
252 0x0e, 0x2, 0x14, 0xd7,
253 0x0e, 0x2, 0x47, 0x88,
255 msleep(20);
256 for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
257 ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
258 bufs+i, 4, &buf, 1);
259 if (ret)
260 break;
261 if (buf != 0x8)
262 return -EREMOTEIO;
265 return ret;
268 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
270 u8 b = 0;
271 if (onoff)
272 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
273 else
274 return 0;
277 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
279 int rc = 0;
281 rc = cxusb_power_ctrl(d, onoff);
282 if (!onoff)
283 cxusb_nano2_led(d, 0);
285 return rc;
288 static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
290 int ret;
291 u8 b;
292 ret = cxusb_power_ctrl(d, onoff);
293 if (!onoff)
294 return ret;
296 msleep(128);
297 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
298 msleep(100);
299 return ret;
302 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
304 u8 buf[2] = { 0x03, 0x00 };
305 if (onoff)
306 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
307 else
308 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
310 return 0;
313 static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
315 if (onoff)
316 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
317 else
318 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
319 NULL, 0, NULL, 0);
320 return 0;
323 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
325 int ep = d->props.generic_bulk_ctrl_endpoint;
326 const int timeout = 100;
327 const int junk_len = 32;
328 u8 *junk;
329 int rd_count;
331 /* Discard remaining data in video pipe */
332 junk = kmalloc(junk_len, GFP_KERNEL);
333 if (!junk)
334 return;
335 while (1) {
336 if (usb_bulk_msg(d->udev,
337 usb_rcvbulkpipe(d->udev, ep),
338 junk, junk_len, &rd_count, timeout) < 0)
339 break;
340 if (!rd_count)
341 break;
343 kfree(junk);
346 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
348 struct usb_data_stream_properties *p = &d->props.adapter[0].stream;
349 const int timeout = 100;
350 const int junk_len = p->u.bulk.buffersize;
351 u8 *junk;
352 int rd_count;
354 /* Discard remaining data in video pipe */
355 junk = kmalloc(junk_len, GFP_KERNEL);
356 if (!junk)
357 return;
358 while (1) {
359 if (usb_bulk_msg(d->udev,
360 usb_rcvbulkpipe(d->udev, p->endpoint),
361 junk, junk_len, &rd_count, timeout) < 0)
362 break;
363 if (!rd_count)
364 break;
366 kfree(junk);
369 static int cxusb_d680_dmb_streaming_ctrl(
370 struct dvb_usb_adapter *adap, int onoff)
372 if (onoff) {
373 u8 buf[2] = { 0x03, 0x00 };
374 cxusb_d680_dmb_drain_video(adap->dev);
375 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
376 buf, sizeof(buf), NULL, 0);
377 } else {
378 int ret = cxusb_ctrl_msg(adap->dev,
379 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
380 return ret;
384 static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
386 struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map;
387 u8 ircode[4];
388 int i;
390 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
392 *event = 0;
393 *state = REMOTE_NO_KEY_PRESSED;
395 for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) {
396 if (rc5_custom(&keymap[i]) == ircode[2] &&
397 rc5_data(&keymap[i]) == ircode[3]) {
398 *event = keymap[i].keycode;
399 *state = REMOTE_KEY_PRESSED;
401 return 0;
405 return 0;
408 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
409 int *state)
411 struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map;
412 u8 ircode[4];
413 int i;
414 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
415 .buf = ircode, .len = 4 };
417 *event = 0;
418 *state = REMOTE_NO_KEY_PRESSED;
420 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
421 return 0;
423 for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) {
424 if (rc5_custom(&keymap[i]) == ircode[1] &&
425 rc5_data(&keymap[i]) == ircode[2]) {
426 *event = keymap[i].keycode;
427 *state = REMOTE_KEY_PRESSED;
429 return 0;
433 return 0;
436 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
437 int *state)
439 struct ir_scancode *keymap = d->props.rc.legacy.rc_key_map;
440 u8 ircode[2];
441 int i;
443 *event = 0;
444 *state = REMOTE_NO_KEY_PRESSED;
446 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
447 return 0;
449 for (i = 0; i < d->props.rc.legacy.rc_key_map_size; i++) {
450 if (rc5_custom(&keymap[i]) == ircode[0] &&
451 rc5_data(&keymap[i]) == ircode[1]) {
452 *event = keymap[i].keycode;
453 *state = REMOTE_KEY_PRESSED;
455 return 0;
459 return 0;
462 static struct ir_scancode ir_codes_dvico_mce_table[] = {
463 { 0xfe02, KEY_TV },
464 { 0xfe0e, KEY_MP3 },
465 { 0xfe1a, KEY_DVD },
466 { 0xfe1e, KEY_FAVORITES },
467 { 0xfe16, KEY_SETUP },
468 { 0xfe46, KEY_POWER2 },
469 { 0xfe0a, KEY_EPG },
470 { 0xfe49, KEY_BACK },
471 { 0xfe4d, KEY_MENU },
472 { 0xfe51, KEY_UP },
473 { 0xfe5b, KEY_LEFT },
474 { 0xfe5f, KEY_RIGHT },
475 { 0xfe53, KEY_DOWN },
476 { 0xfe5e, KEY_OK },
477 { 0xfe59, KEY_INFO },
478 { 0xfe55, KEY_TAB },
479 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
480 { 0xfe12, KEY_NEXTSONG }, /* Skip */
481 { 0xfe42, KEY_ENTER }, /* Windows/Start */
482 { 0xfe15, KEY_VOLUMEUP },
483 { 0xfe05, KEY_VOLUMEDOWN },
484 { 0xfe11, KEY_CHANNELUP },
485 { 0xfe09, KEY_CHANNELDOWN },
486 { 0xfe52, KEY_CAMERA },
487 { 0xfe5a, KEY_TUNER }, /* Live */
488 { 0xfe19, KEY_OPEN },
489 { 0xfe0b, KEY_1 },
490 { 0xfe17, KEY_2 },
491 { 0xfe1b, KEY_3 },
492 { 0xfe07, KEY_4 },
493 { 0xfe50, KEY_5 },
494 { 0xfe54, KEY_6 },
495 { 0xfe48, KEY_7 },
496 { 0xfe4c, KEY_8 },
497 { 0xfe58, KEY_9 },
498 { 0xfe13, KEY_ANGLE }, /* Aspect */
499 { 0xfe03, KEY_0 },
500 { 0xfe1f, KEY_ZOOM },
501 { 0xfe43, KEY_REWIND },
502 { 0xfe47, KEY_PLAYPAUSE },
503 { 0xfe4f, KEY_FASTFORWARD },
504 { 0xfe57, KEY_MUTE },
505 { 0xfe0d, KEY_STOP },
506 { 0xfe01, KEY_RECORD },
507 { 0xfe4e, KEY_POWER },
510 static struct ir_scancode ir_codes_dvico_portable_table[] = {
511 { 0xfc02, KEY_SETUP }, /* Profile */
512 { 0xfc43, KEY_POWER2 },
513 { 0xfc06, KEY_EPG },
514 { 0xfc5a, KEY_BACK },
515 { 0xfc05, KEY_MENU },
516 { 0xfc47, KEY_INFO },
517 { 0xfc01, KEY_TAB },
518 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
519 { 0xfc49, KEY_VOLUMEUP },
520 { 0xfc09, KEY_VOLUMEDOWN },
521 { 0xfc54, KEY_CHANNELUP },
522 { 0xfc0b, KEY_CHANNELDOWN },
523 { 0xfc16, KEY_CAMERA },
524 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
525 { 0xfc45, KEY_OPEN },
526 { 0xfc19, KEY_1 },
527 { 0xfc18, KEY_2 },
528 { 0xfc1b, KEY_3 },
529 { 0xfc1a, KEY_4 },
530 { 0xfc58, KEY_5 },
531 { 0xfc59, KEY_6 },
532 { 0xfc15, KEY_7 },
533 { 0xfc14, KEY_8 },
534 { 0xfc17, KEY_9 },
535 { 0xfc44, KEY_ANGLE }, /* Aspect */
536 { 0xfc55, KEY_0 },
537 { 0xfc07, KEY_ZOOM },
538 { 0xfc0a, KEY_REWIND },
539 { 0xfc08, KEY_PLAYPAUSE },
540 { 0xfc4b, KEY_FASTFORWARD },
541 { 0xfc5b, KEY_MUTE },
542 { 0xfc04, KEY_STOP },
543 { 0xfc56, KEY_RECORD },
544 { 0xfc57, KEY_POWER },
545 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
546 { 0xfc00, KEY_UNKNOWN }, /* HD */
549 static struct ir_scancode ir_codes_d680_dmb_table[] = {
550 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
551 { 0x080c, KEY_ZOOM },
552 { 0x0800, KEY_0 },
553 { 0x0001, KEY_1 },
554 { 0x0802, KEY_2 },
555 { 0x0003, KEY_3 },
556 { 0x0804, KEY_4 },
557 { 0x0005, KEY_5 },
558 { 0x0806, KEY_6 },
559 { 0x0007, KEY_7 },
560 { 0x0808, KEY_8 },
561 { 0x0009, KEY_9 },
562 { 0x000a, KEY_MUTE },
563 { 0x0829, KEY_BACK },
564 { 0x0012, KEY_CHANNELUP },
565 { 0x0813, KEY_CHANNELDOWN },
566 { 0x002b, KEY_VOLUMEUP },
567 { 0x082c, KEY_VOLUMEDOWN },
568 { 0x0020, KEY_UP },
569 { 0x0821, KEY_DOWN },
570 { 0x0011, KEY_LEFT },
571 { 0x0810, KEY_RIGHT },
572 { 0x000d, KEY_OK },
573 { 0x081f, KEY_RECORD },
574 { 0x0017, KEY_PLAYPAUSE },
575 { 0x0816, KEY_PLAYPAUSE },
576 { 0x000b, KEY_STOP },
577 { 0x0827, KEY_FASTFORWARD },
578 { 0x0026, KEY_REWIND },
579 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
580 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
581 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
582 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
583 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
584 { 0x0025, KEY_POWER },
587 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
589 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
590 static u8 reset [] = { RESET, 0x80 };
591 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
592 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
593 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
594 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
596 mt352_write(fe, clock_config, sizeof(clock_config));
597 udelay(200);
598 mt352_write(fe, reset, sizeof(reset));
599 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
601 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
602 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
603 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
605 return 0;
608 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
609 { /* used in both lgz201 and th7579 */
610 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
611 static u8 reset [] = { RESET, 0x80 };
612 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
613 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
614 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
615 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
617 mt352_write(fe, clock_config, sizeof(clock_config));
618 udelay(200);
619 mt352_write(fe, reset, sizeof(reset));
620 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
622 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
623 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
624 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
625 return 0;
628 static struct cx22702_config cxusb_cx22702_config = {
629 .demod_address = 0x63,
630 .output_mode = CX22702_PARALLEL_OUTPUT,
633 static struct lgdt330x_config cxusb_lgdt3303_config = {
634 .demod_address = 0x0e,
635 .demod_chip = LGDT3303,
638 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
639 .demod_address = 0x0e,
640 .demod_chip = LGDT3303,
641 .clock_polarity_flip = 2,
644 static struct mt352_config cxusb_dee1601_config = {
645 .demod_address = 0x0f,
646 .demod_init = cxusb_dee1601_demod_init,
649 static struct zl10353_config cxusb_zl10353_dee1601_config = {
650 .demod_address = 0x0f,
651 .parallel_ts = 1,
654 static struct mt352_config cxusb_mt352_config = {
655 /* used in both lgz201 and th7579 */
656 .demod_address = 0x0f,
657 .demod_init = cxusb_mt352_demod_init,
660 static struct zl10353_config cxusb_zl10353_xc3028_config = {
661 .demod_address = 0x0f,
662 .if2 = 45600,
663 .no_tuner = 1,
664 .parallel_ts = 1,
667 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
668 .demod_address = 0x0f,
669 .if2 = 45600,
670 .no_tuner = 1,
671 .parallel_ts = 1,
672 .disable_i2c_gate_ctrl = 1,
675 static struct mt352_config cxusb_mt352_xc3028_config = {
676 .demod_address = 0x0f,
677 .if2 = 4560,
678 .no_tuner = 1,
679 .demod_init = cxusb_mt352_demod_init,
682 static struct mxl5005s_config aver_a868r_tuner = {
683 .i2c_address = 0x63,
684 .if_freq = 6000000UL,
685 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
686 .agc_mode = MXL_SINGLE_AGC,
687 .tracking_filter = MXL_TF_C,
688 .rssi_enable = MXL_RSSI_ENABLE,
689 .cap_select = MXL_CAP_SEL_ENABLE,
690 .div_out = MXL_DIV_OUT_4,
691 .clock_out = MXL_CLOCK_OUT_DISABLE,
692 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
693 .top = MXL5005S_TOP_25P2,
694 .mod_mode = MXL_DIGITAL_MODE,
695 .if_mode = MXL_ZERO_IF,
696 .AgcMasterByte = 0x00,
699 static struct mxl5005s_config d680_dmb_tuner = {
700 .i2c_address = 0x63,
701 .if_freq = 36125000UL,
702 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
703 .agc_mode = MXL_SINGLE_AGC,
704 .tracking_filter = MXL_TF_C,
705 .rssi_enable = MXL_RSSI_ENABLE,
706 .cap_select = MXL_CAP_SEL_ENABLE,
707 .div_out = MXL_DIV_OUT_4,
708 .clock_out = MXL_CLOCK_OUT_DISABLE,
709 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
710 .top = MXL5005S_TOP_25P2,
711 .mod_mode = MXL_DIGITAL_MODE,
712 .if_mode = MXL_ZERO_IF,
713 .AgcMasterByte = 0x00,
716 static struct max2165_config mygica_d689_max2165_cfg = {
717 .i2c_address = 0x60,
718 .osc_clk = 20
721 /* Callbacks for DVB USB */
722 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
724 dvb_attach(simple_tuner_attach, adap->fe,
725 &adap->dev->i2c_adap, 0x61,
726 TUNER_PHILIPS_FMD1216ME_MK3);
727 return 0;
730 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
732 dvb_attach(dvb_pll_attach, adap->fe, 0x61,
733 NULL, DVB_PLL_THOMSON_DTT7579);
734 return 0;
737 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
739 dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
740 return 0;
743 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
745 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
746 NULL, DVB_PLL_THOMSON_DTT7579);
747 return 0;
750 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
752 dvb_attach(simple_tuner_attach, adap->fe,
753 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
754 return 0;
757 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
758 int command, int arg)
760 struct dvb_usb_adapter *adap = ptr;
761 struct dvb_usb_device *d = adap->dev;
763 switch (command) {
764 case XC2028_TUNER_RESET:
765 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
766 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
767 break;
768 case XC2028_RESET_CLK:
769 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
770 break;
771 default:
772 deb_info("%s: unknown command %d, arg %d\n", __func__,
773 command, arg);
774 return -EINVAL;
777 return 0;
780 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
782 struct dvb_frontend *fe;
783 struct xc2028_config cfg = {
784 .i2c_adap = &adap->dev->i2c_adap,
785 .i2c_addr = 0x61,
787 static struct xc2028_ctrl ctl = {
788 .fname = XC2028_DEFAULT_FIRMWARE,
789 .max_len = 64,
790 .demod = XC3028_FE_ZARLINK456,
793 adap->fe->callback = dvico_bluebird_xc2028_callback;
795 fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
796 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
797 return -EIO;
799 fe->ops.tuner_ops.set_config(fe, &ctl);
801 return 0;
804 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
806 dvb_attach(mxl5005s_attach, adap->fe,
807 &adap->dev->i2c_adap, &aver_a868r_tuner);
808 return 0;
811 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
813 struct dvb_frontend *fe;
814 fe = dvb_attach(mxl5005s_attach, adap->fe,
815 &adap->dev->i2c_adap, &d680_dmb_tuner);
816 return (fe == NULL) ? -EIO : 0;
819 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
821 struct dvb_frontend *fe;
822 fe = dvb_attach(max2165_attach, adap->fe,
823 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
824 return (fe == NULL) ? -EIO : 0;
827 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
829 u8 b;
830 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
831 err("set interface failed");
833 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
835 if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
836 &adap->dev->i2c_adap)) != NULL)
837 return 0;
839 return -EIO;
842 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
844 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
845 err("set interface failed");
847 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
849 if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
850 &adap->dev->i2c_adap)) != NULL)
851 return 0;
853 return -EIO;
856 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
858 adap->fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
859 &adap->dev->i2c_adap);
860 if (adap->fe != NULL)
861 return 0;
863 return -EIO;
866 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
868 /* used in both lgz201 and th7579 */
869 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
870 err("set interface failed");
872 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
874 if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
875 &adap->dev->i2c_adap)) != NULL)
876 return 0;
878 return -EIO;
881 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
883 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
884 err("set interface failed");
886 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
888 if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
889 &adap->dev->i2c_adap)) != NULL) ||
890 ((adap->fe = dvb_attach(zl10353_attach,
891 &cxusb_zl10353_dee1601_config,
892 &adap->dev->i2c_adap)) != NULL))
893 return 0;
895 return -EIO;
898 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
900 u8 ircode[4];
901 int i;
902 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
903 .buf = ircode, .len = 4 };
905 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
906 err("set interface failed");
908 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
910 /* reset the tuner and demodulator */
911 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
912 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
913 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
915 if ((adap->fe = dvb_attach(zl10353_attach,
916 &cxusb_zl10353_xc3028_config_no_i2c_gate,
917 &adap->dev->i2c_adap)) == NULL)
918 return -EIO;
920 /* try to determine if there is no IR decoder on the I2C bus */
921 for (i = 0; adap->dev->props.rc.legacy.rc_key_map != NULL && i < 5; i++) {
922 msleep(20);
923 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
924 goto no_IR;
925 if (ircode[0] == 0 && ircode[1] == 0)
926 continue;
927 if (ircode[2] + ircode[3] != 0xff) {
928 no_IR:
929 adap->dev->props.rc.legacy.rc_key_map = NULL;
930 info("No IR receiver detected on this device.");
931 break;
935 return 0;
938 static struct dibx000_agc_config dib7070_agc_config = {
939 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
942 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
943 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
944 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
946 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
947 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
948 .inv_gain = 600,
949 .time_stabiliz = 10,
950 .alpha_level = 0,
951 .thlock = 118,
952 .wbd_inv = 0,
953 .wbd_ref = 3530,
954 .wbd_sel = 1,
955 .wbd_alpha = 5,
956 .agc1_max = 65535,
957 .agc1_min = 0,
958 .agc2_max = 65535,
959 .agc2_min = 0,
960 .agc1_pt1 = 0,
961 .agc1_pt2 = 40,
962 .agc1_pt3 = 183,
963 .agc1_slope1 = 206,
964 .agc1_slope2 = 255,
965 .agc2_pt1 = 72,
966 .agc2_pt2 = 152,
967 .agc2_slope1 = 88,
968 .agc2_slope2 = 90,
969 .alpha_mant = 17,
970 .alpha_exp = 27,
971 .beta_mant = 23,
972 .beta_exp = 51,
973 .perform_agc_softsplit = 0,
976 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
977 .internal = 60000,
978 .sampling = 15000,
979 .pll_prediv = 1,
980 .pll_ratio = 20,
981 .pll_range = 3,
982 .pll_reset = 1,
983 .pll_bypass = 0,
984 .enable_refdiv = 0,
985 .bypclk_div = 0,
986 .IO_CLK_en_core = 1,
987 .ADClkSrc = 1,
988 .modulo = 2,
989 /* refsel, sel, freq_15k */
990 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
991 .ifreq = (0 << 25) | 0,
992 .timf = 20452225,
993 .xtal_hz = 12000000,
996 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
997 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
998 .output_mpeg2_in_188_bytes = 1,
1000 .agc_config_count = 1,
1001 .agc = &dib7070_agc_config,
1002 .bw = &dib7070_bw_config_12_mhz,
1003 .tuner_is_baseband = 1,
1004 .spur_protect = 1,
1006 .gpio_dir = 0xfcef,
1007 .gpio_val = 0x0110,
1009 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1011 .hostbus_diversity = 1,
1014 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
1016 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1017 err("set interface failed");
1019 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1021 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1023 if (dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1024 &cxusb_dualdig4_rev2_config) < 0) {
1025 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1026 return -ENODEV;
1029 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1030 &cxusb_dualdig4_rev2_config);
1031 if (adap->fe == NULL)
1032 return -EIO;
1034 return 0;
1037 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
1039 return dib7000p_set_gpio(fe, 8, 0, !onoff);
1042 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1044 return 0;
1047 static struct dib0070_config dib7070p_dib0070_config = {
1048 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1049 .reset = dib7070_tuner_reset,
1050 .sleep = dib7070_tuner_sleep,
1051 .clock_khz = 12000,
1054 struct dib0700_adapter_state {
1055 int (*set_param_save) (struct dvb_frontend *,
1056 struct dvb_frontend_parameters *);
1059 static int dib7070_set_param_override(struct dvb_frontend *fe,
1060 struct dvb_frontend_parameters *fep)
1062 struct dvb_usb_adapter *adap = fe->dvb->priv;
1063 struct dib0700_adapter_state *state = adap->priv;
1065 u16 offset;
1066 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1067 switch (band) {
1068 case BAND_VHF: offset = 950; break;
1069 default:
1070 case BAND_UHF: offset = 550; break;
1073 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1075 return state->set_param_save(fe, fep);
1078 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1080 struct dib0700_adapter_state *st = adap->priv;
1081 struct i2c_adapter *tun_i2c =
1082 dib7000p_get_i2c_master(adap->fe,
1083 DIBX000_I2C_INTERFACE_TUNER, 1);
1085 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1086 &dib7070p_dib0070_config) == NULL)
1087 return -ENODEV;
1089 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1090 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1091 return 0;
1094 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1096 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1097 err("set interface failed");
1099 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1101 /* reset the tuner and demodulator */
1102 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1103 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1104 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1106 if ((adap->fe = dvb_attach(zl10353_attach,
1107 &cxusb_zl10353_xc3028_config,
1108 &adap->dev->i2c_adap)) != NULL)
1109 return 0;
1111 if ((adap->fe = dvb_attach(mt352_attach,
1112 &cxusb_mt352_xc3028_config,
1113 &adap->dev->i2c_adap)) != NULL)
1114 return 0;
1116 return -EIO;
1119 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1120 .prod = LGS8GXX_PROD_LGS8GL5,
1121 .demod_address = 0x19,
1122 .serial_ts = 0,
1123 .ts_clk_pol = 0,
1124 .ts_clk_gated = 1,
1125 .if_clk_freq = 30400, /* 30.4 MHz */
1126 .if_freq = 5725, /* 5.725 MHz */
1127 .if_neg_center = 0,
1128 .ext_adc = 0,
1129 .adc_signed = 0,
1130 .if_neg_edge = 0,
1133 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1135 struct dvb_usb_device *d = adap->dev;
1136 int n;
1138 /* Select required USB configuration */
1139 if (usb_set_interface(d->udev, 0, 0) < 0)
1140 err("set interface failed");
1142 /* Unblock all USB pipes */
1143 usb_clear_halt(d->udev,
1144 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1145 usb_clear_halt(d->udev,
1146 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1147 usb_clear_halt(d->udev,
1148 usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
1150 /* Drain USB pipes to avoid hang after reboot */
1151 for (n = 0; n < 5; n++) {
1152 cxusb_d680_dmb_drain_message(d);
1153 cxusb_d680_dmb_drain_video(d);
1154 msleep(200);
1157 /* Reset the tuner */
1158 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1159 err("clear tuner gpio failed");
1160 return -EIO;
1162 msleep(100);
1163 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1164 err("set tuner gpio failed");
1165 return -EIO;
1167 msleep(100);
1169 /* Attach frontend */
1170 adap->fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1171 if (adap->fe == NULL)
1172 return -EIO;
1174 return 0;
1177 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1178 .prod = ATBM8830_PROD_8830,
1179 .demod_address = 0x40,
1180 .serial_ts = 0,
1181 .ts_sampling_edge = 1,
1182 .ts_clk_gated = 0,
1183 .osc_clk_freq = 30400, /* in kHz */
1184 .if_freq = 0, /* zero IF */
1185 .zif_swap_iq = 1,
1186 .agc_min = 0x2E,
1187 .agc_max = 0x90,
1188 .agc_hold_loop = 0,
1191 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1193 struct dvb_usb_device *d = adap->dev;
1195 /* Select required USB configuration */
1196 if (usb_set_interface(d->udev, 0, 0) < 0)
1197 err("set interface failed");
1199 /* Unblock all USB pipes */
1200 usb_clear_halt(d->udev,
1201 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1202 usb_clear_halt(d->udev,
1203 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1204 usb_clear_halt(d->udev,
1205 usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
1208 /* Reset the tuner */
1209 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1210 err("clear tuner gpio failed");
1211 return -EIO;
1213 msleep(100);
1214 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1215 err("set tuner gpio failed");
1216 return -EIO;
1218 msleep(100);
1220 /* Attach frontend */
1221 adap->fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1222 &d->i2c_adap);
1223 if (adap->fe == NULL)
1224 return -EIO;
1226 return 0;
1230 * DViCO has shipped two devices with the same USB ID, but only one of them
1231 * needs a firmware download. Check the device class details to see if they
1232 * have non-default values to decide whether the device is actually cold or
1233 * not, and forget a match if it turns out we selected the wrong device.
1235 static int bluebird_fx2_identify_state(struct usb_device *udev,
1236 struct dvb_usb_device_properties *props,
1237 struct dvb_usb_device_description **desc,
1238 int *cold)
1240 int wascold = *cold;
1242 *cold = udev->descriptor.bDeviceClass == 0xff &&
1243 udev->descriptor.bDeviceSubClass == 0xff &&
1244 udev->descriptor.bDeviceProtocol == 0xff;
1246 if (*cold && !wascold)
1247 *desc = NULL;
1249 return 0;
1253 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1254 * firmware file before download.
1257 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
1258 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1259 const struct firmware *fw)
1261 int pos;
1263 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1264 int idoff = dvico_firmware_id_offsets[pos];
1266 if (fw->size < idoff + 4)
1267 continue;
1269 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1270 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1271 struct firmware new_fw;
1272 u8 *new_fw_data = vmalloc(fw->size);
1273 int ret;
1275 if (!new_fw_data)
1276 return -ENOMEM;
1278 memcpy(new_fw_data, fw->data, fw->size);
1279 new_fw.size = fw->size;
1280 new_fw.data = new_fw_data;
1282 new_fw_data[idoff + 2] =
1283 le16_to_cpu(udev->descriptor.idProduct) + 1;
1284 new_fw_data[idoff + 3] =
1285 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1287 ret = usb_cypress_load_firmware(udev, &new_fw,
1288 CYPRESS_FX2);
1289 vfree(new_fw_data);
1290 return ret;
1294 return -EINVAL;
1297 /* DVB USB Driver stuff */
1298 static struct dvb_usb_device_properties cxusb_medion_properties;
1299 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1300 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1301 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1302 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1303 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1304 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1305 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1306 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1307 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1308 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1309 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1311 static int cxusb_probe(struct usb_interface *intf,
1312 const struct usb_device_id *id)
1314 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1315 THIS_MODULE, NULL, adapter_nr) ||
1316 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1317 THIS_MODULE, NULL, adapter_nr) ||
1318 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1319 THIS_MODULE, NULL, adapter_nr) ||
1320 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1321 THIS_MODULE, NULL, adapter_nr) ||
1322 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1323 THIS_MODULE, NULL, adapter_nr) ||
1324 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1325 THIS_MODULE, NULL, adapter_nr) ||
1326 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1327 THIS_MODULE, NULL, adapter_nr) ||
1328 0 == dvb_usb_device_init(intf,
1329 &cxusb_bluebird_nano2_needsfirmware_properties,
1330 THIS_MODULE, NULL, adapter_nr) ||
1331 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1332 THIS_MODULE, NULL, adapter_nr) ||
1333 0 == dvb_usb_device_init(intf,
1334 &cxusb_bluebird_dualdig4_rev2_properties,
1335 THIS_MODULE, NULL, adapter_nr) ||
1336 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1337 THIS_MODULE, NULL, adapter_nr) ||
1338 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1339 THIS_MODULE, NULL, adapter_nr) ||
1341 return 0;
1343 return -EINVAL;
1346 static struct usb_device_id cxusb_table [] = {
1347 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
1348 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
1349 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
1350 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
1351 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
1352 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
1353 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
1354 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
1355 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
1356 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
1357 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
1358 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
1359 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
1360 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
1361 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
1362 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
1363 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
1364 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
1365 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
1366 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
1367 {} /* Terminating entry */
1369 MODULE_DEVICE_TABLE (usb, cxusb_table);
1371 static struct dvb_usb_device_properties cxusb_medion_properties = {
1372 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1374 .usb_ctrl = CYPRESS_FX2,
1376 .size_of_priv = sizeof(struct cxusb_state),
1378 .num_adapters = 1,
1379 .adapter = {
1381 .streaming_ctrl = cxusb_streaming_ctrl,
1382 .frontend_attach = cxusb_cx22702_frontend_attach,
1383 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1384 /* parameter for the MPEG2-data transfer */
1385 .stream = {
1386 .type = USB_BULK,
1387 .count = 5,
1388 .endpoint = 0x02,
1389 .u = {
1390 .bulk = {
1391 .buffersize = 8192,
1398 .power_ctrl = cxusb_power_ctrl,
1400 .i2c_algo = &cxusb_i2c_algo,
1402 .generic_bulk_ctrl_endpoint = 0x01,
1404 .num_device_descs = 1,
1405 .devices = {
1406 { "Medion MD95700 (MDUSBTV-HYBRID)",
1407 { NULL },
1408 { &cxusb_table[0], NULL },
1413 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1414 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1416 .usb_ctrl = DEVICE_SPECIFIC,
1417 .firmware = "dvb-usb-bluebird-01.fw",
1418 .download_firmware = bluebird_patch_dvico_firmware_download,
1419 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1420 use usb alt setting 7 for EP2 transfer (atsc) */
1422 .size_of_priv = sizeof(struct cxusb_state),
1424 .num_adapters = 1,
1425 .adapter = {
1427 .streaming_ctrl = cxusb_streaming_ctrl,
1428 .frontend_attach = cxusb_lgdt3303_frontend_attach,
1429 .tuner_attach = cxusb_lgh064f_tuner_attach,
1431 /* parameter for the MPEG2-data transfer */
1432 .stream = {
1433 .type = USB_BULK,
1434 .count = 5,
1435 .endpoint = 0x02,
1436 .u = {
1437 .bulk = {
1438 .buffersize = 8192,
1445 .power_ctrl = cxusb_bluebird_power_ctrl,
1447 .i2c_algo = &cxusb_i2c_algo,
1449 .rc.legacy = {
1450 .rc_interval = 100,
1451 .rc_key_map = ir_codes_dvico_portable_table,
1452 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1453 .rc_query = cxusb_rc_query,
1456 .generic_bulk_ctrl_endpoint = 0x01,
1458 .num_device_descs = 1,
1459 .devices = {
1460 { "DViCO FusionHDTV5 USB Gold",
1461 { &cxusb_table[1], NULL },
1462 { &cxusb_table[2], NULL },
1467 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1468 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1470 .usb_ctrl = DEVICE_SPECIFIC,
1471 .firmware = "dvb-usb-bluebird-01.fw",
1472 .download_firmware = bluebird_patch_dvico_firmware_download,
1473 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1474 use usb alt setting 7 for EP2 transfer (atsc) */
1476 .size_of_priv = sizeof(struct cxusb_state),
1478 .num_adapters = 1,
1479 .adapter = {
1481 .streaming_ctrl = cxusb_streaming_ctrl,
1482 .frontend_attach = cxusb_dee1601_frontend_attach,
1483 .tuner_attach = cxusb_dee1601_tuner_attach,
1484 /* parameter for the MPEG2-data transfer */
1485 .stream = {
1486 .type = USB_BULK,
1487 .count = 5,
1488 .endpoint = 0x04,
1489 .u = {
1490 .bulk = {
1491 .buffersize = 8192,
1498 .power_ctrl = cxusb_bluebird_power_ctrl,
1500 .i2c_algo = &cxusb_i2c_algo,
1502 .rc.legacy = {
1503 .rc_interval = 150,
1504 .rc_key_map = ir_codes_dvico_mce_table,
1505 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1506 .rc_query = cxusb_rc_query,
1509 .generic_bulk_ctrl_endpoint = 0x01,
1511 .num_device_descs = 3,
1512 .devices = {
1513 { "DViCO FusionHDTV DVB-T Dual USB",
1514 { &cxusb_table[3], NULL },
1515 { &cxusb_table[4], NULL },
1517 { "DigitalNow DVB-T Dual USB",
1518 { &cxusb_table[9], NULL },
1519 { &cxusb_table[10], NULL },
1521 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1522 { &cxusb_table[11], NULL },
1523 { &cxusb_table[12], NULL },
1528 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1529 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1531 .usb_ctrl = DEVICE_SPECIFIC,
1532 .firmware = "dvb-usb-bluebird-01.fw",
1533 .download_firmware = bluebird_patch_dvico_firmware_download,
1534 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1535 use usb alt setting 7 for EP2 transfer (atsc) */
1537 .size_of_priv = sizeof(struct cxusb_state),
1539 .num_adapters = 2,
1540 .adapter = {
1542 .streaming_ctrl = cxusb_streaming_ctrl,
1543 .frontend_attach = cxusb_mt352_frontend_attach,
1544 .tuner_attach = cxusb_lgz201_tuner_attach,
1546 /* parameter for the MPEG2-data transfer */
1547 .stream = {
1548 .type = USB_BULK,
1549 .count = 5,
1550 .endpoint = 0x04,
1551 .u = {
1552 .bulk = {
1553 .buffersize = 8192,
1559 .power_ctrl = cxusb_bluebird_power_ctrl,
1561 .i2c_algo = &cxusb_i2c_algo,
1563 .rc.legacy = {
1564 .rc_interval = 100,
1565 .rc_key_map = ir_codes_dvico_portable_table,
1566 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1567 .rc_query = cxusb_rc_query,
1570 .generic_bulk_ctrl_endpoint = 0x01,
1571 .num_device_descs = 1,
1572 .devices = {
1573 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1574 { &cxusb_table[5], NULL },
1575 { &cxusb_table[6], NULL },
1580 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1581 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1583 .usb_ctrl = DEVICE_SPECIFIC,
1584 .firmware = "dvb-usb-bluebird-01.fw",
1585 .download_firmware = bluebird_patch_dvico_firmware_download,
1586 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1587 use usb alt setting 7 for EP2 transfer (atsc) */
1589 .size_of_priv = sizeof(struct cxusb_state),
1591 .num_adapters = 1,
1592 .adapter = {
1594 .streaming_ctrl = cxusb_streaming_ctrl,
1595 .frontend_attach = cxusb_mt352_frontend_attach,
1596 .tuner_attach = cxusb_dtt7579_tuner_attach,
1598 /* parameter for the MPEG2-data transfer */
1599 .stream = {
1600 .type = USB_BULK,
1601 .count = 5,
1602 .endpoint = 0x04,
1603 .u = {
1604 .bulk = {
1605 .buffersize = 8192,
1611 .power_ctrl = cxusb_bluebird_power_ctrl,
1613 .i2c_algo = &cxusb_i2c_algo,
1615 .rc.legacy = {
1616 .rc_interval = 100,
1617 .rc_key_map = ir_codes_dvico_portable_table,
1618 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1619 .rc_query = cxusb_rc_query,
1622 .generic_bulk_ctrl_endpoint = 0x01,
1624 .num_device_descs = 1,
1625 .devices = {
1626 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1627 { &cxusb_table[7], NULL },
1628 { &cxusb_table[8], NULL },
1633 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1634 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1636 .usb_ctrl = CYPRESS_FX2,
1638 .size_of_priv = sizeof(struct cxusb_state),
1640 .num_adapters = 1,
1641 .adapter = {
1643 .streaming_ctrl = cxusb_streaming_ctrl,
1644 .frontend_attach = cxusb_dualdig4_frontend_attach,
1645 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1646 /* parameter for the MPEG2-data transfer */
1647 .stream = {
1648 .type = USB_BULK,
1649 .count = 5,
1650 .endpoint = 0x02,
1651 .u = {
1652 .bulk = {
1653 .buffersize = 8192,
1660 .power_ctrl = cxusb_power_ctrl,
1662 .i2c_algo = &cxusb_i2c_algo,
1664 .generic_bulk_ctrl_endpoint = 0x01,
1666 .rc.legacy = {
1667 .rc_interval = 100,
1668 .rc_key_map = ir_codes_dvico_mce_table,
1669 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1670 .rc_query = cxusb_bluebird2_rc_query,
1673 .num_device_descs = 1,
1674 .devices = {
1675 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1676 { NULL },
1677 { &cxusb_table[13], NULL },
1682 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1683 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1685 .usb_ctrl = CYPRESS_FX2,
1686 .identify_state = bluebird_fx2_identify_state,
1688 .size_of_priv = sizeof(struct cxusb_state),
1690 .num_adapters = 1,
1691 .adapter = {
1693 .streaming_ctrl = cxusb_streaming_ctrl,
1694 .frontend_attach = cxusb_nano2_frontend_attach,
1695 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1696 /* parameter for the MPEG2-data transfer */
1697 .stream = {
1698 .type = USB_BULK,
1699 .count = 5,
1700 .endpoint = 0x02,
1701 .u = {
1702 .bulk = {
1703 .buffersize = 8192,
1710 .power_ctrl = cxusb_nano2_power_ctrl,
1712 .i2c_algo = &cxusb_i2c_algo,
1714 .generic_bulk_ctrl_endpoint = 0x01,
1716 .rc.legacy = {
1717 .rc_interval = 100,
1718 .rc_key_map = ir_codes_dvico_portable_table,
1719 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1720 .rc_query = cxusb_bluebird2_rc_query,
1723 .num_device_descs = 1,
1724 .devices = {
1725 { "DViCO FusionHDTV DVB-T NANO2",
1726 { NULL },
1727 { &cxusb_table[14], NULL },
1732 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1733 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1735 .usb_ctrl = DEVICE_SPECIFIC,
1736 .firmware = "dvb-usb-bluebird-02.fw",
1737 .download_firmware = bluebird_patch_dvico_firmware_download,
1738 .identify_state = bluebird_fx2_identify_state,
1740 .size_of_priv = sizeof(struct cxusb_state),
1742 .num_adapters = 1,
1743 .adapter = {
1745 .streaming_ctrl = cxusb_streaming_ctrl,
1746 .frontend_attach = cxusb_nano2_frontend_attach,
1747 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1748 /* parameter for the MPEG2-data transfer */
1749 .stream = {
1750 .type = USB_BULK,
1751 .count = 5,
1752 .endpoint = 0x02,
1753 .u = {
1754 .bulk = {
1755 .buffersize = 8192,
1762 .power_ctrl = cxusb_nano2_power_ctrl,
1764 .i2c_algo = &cxusb_i2c_algo,
1766 .generic_bulk_ctrl_endpoint = 0x01,
1768 .rc.legacy = {
1769 .rc_interval = 100,
1770 .rc_key_map = ir_codes_dvico_portable_table,
1771 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_portable_table),
1772 .rc_query = cxusb_rc_query,
1775 .num_device_descs = 1,
1776 .devices = {
1777 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1778 { &cxusb_table[14], NULL },
1779 { &cxusb_table[15], NULL },
1784 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
1785 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1787 .usb_ctrl = CYPRESS_FX2,
1789 .size_of_priv = sizeof(struct cxusb_state),
1791 .num_adapters = 1,
1792 .adapter = {
1794 .streaming_ctrl = cxusb_aver_streaming_ctrl,
1795 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
1796 .tuner_attach = cxusb_mxl5003s_tuner_attach,
1797 /* parameter for the MPEG2-data transfer */
1798 .stream = {
1799 .type = USB_BULK,
1800 .count = 5,
1801 .endpoint = 0x04,
1802 .u = {
1803 .bulk = {
1804 .buffersize = 8192,
1811 .power_ctrl = cxusb_aver_power_ctrl,
1813 .i2c_algo = &cxusb_i2c_algo,
1815 .generic_bulk_ctrl_endpoint = 0x01,
1817 .num_device_descs = 1,
1818 .devices = {
1819 { "AVerMedia AVerTVHD Volar (A868R)",
1820 { NULL },
1821 { &cxusb_table[16], NULL },
1826 static
1827 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
1828 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1830 .usb_ctrl = CYPRESS_FX2,
1832 .size_of_priv = sizeof(struct cxusb_state),
1834 .num_adapters = 1,
1835 .adapter = {
1837 .streaming_ctrl = cxusb_streaming_ctrl,
1838 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
1839 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
1840 .size_of_priv = sizeof(struct dib0700_adapter_state),
1841 /* parameter for the MPEG2-data transfer */
1842 .stream = {
1843 .type = USB_BULK,
1844 .count = 7,
1845 .endpoint = 0x02,
1846 .u = {
1847 .bulk = {
1848 .buffersize = 4096,
1855 .power_ctrl = cxusb_bluebird_power_ctrl,
1857 .i2c_algo = &cxusb_i2c_algo,
1859 .generic_bulk_ctrl_endpoint = 0x01,
1861 .rc.legacy = {
1862 .rc_interval = 100,
1863 .rc_key_map = ir_codes_dvico_mce_table,
1864 .rc_key_map_size = ARRAY_SIZE(ir_codes_dvico_mce_table),
1865 .rc_query = cxusb_rc_query,
1868 .num_device_descs = 1,
1869 .devices = {
1870 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
1871 { NULL },
1872 { &cxusb_table[17], NULL },
1877 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
1878 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1880 .usb_ctrl = CYPRESS_FX2,
1882 .size_of_priv = sizeof(struct cxusb_state),
1884 .num_adapters = 1,
1885 .adapter = {
1887 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
1888 .frontend_attach = cxusb_d680_dmb_frontend_attach,
1889 .tuner_attach = cxusb_d680_dmb_tuner_attach,
1891 /* parameter for the MPEG2-data transfer */
1892 .stream = {
1893 .type = USB_BULK,
1894 .count = 5,
1895 .endpoint = 0x02,
1896 .u = {
1897 .bulk = {
1898 .buffersize = 8192,
1905 .power_ctrl = cxusb_d680_dmb_power_ctrl,
1907 .i2c_algo = &cxusb_i2c_algo,
1909 .generic_bulk_ctrl_endpoint = 0x01,
1911 .rc.legacy = {
1912 .rc_interval = 100,
1913 .rc_key_map = ir_codes_d680_dmb_table,
1914 .rc_key_map_size = ARRAY_SIZE(ir_codes_d680_dmb_table),
1915 .rc_query = cxusb_d680_dmb_rc_query,
1918 .num_device_descs = 1,
1919 .devices = {
1921 "Conexant DMB-TH Stick",
1922 { NULL },
1923 { &cxusb_table[18], NULL },
1928 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
1929 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1931 .usb_ctrl = CYPRESS_FX2,
1933 .size_of_priv = sizeof(struct cxusb_state),
1935 .num_adapters = 1,
1936 .adapter = {
1938 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
1939 .frontend_attach = cxusb_mygica_d689_frontend_attach,
1940 .tuner_attach = cxusb_mygica_d689_tuner_attach,
1942 /* parameter for the MPEG2-data transfer */
1943 .stream = {
1944 .type = USB_BULK,
1945 .count = 5,
1946 .endpoint = 0x02,
1947 .u = {
1948 .bulk = {
1949 .buffersize = 8192,
1956 .power_ctrl = cxusb_d680_dmb_power_ctrl,
1958 .i2c_algo = &cxusb_i2c_algo,
1960 .generic_bulk_ctrl_endpoint = 0x01,
1962 .rc.legacy = {
1963 .rc_interval = 100,
1964 .rc_key_map = ir_codes_d680_dmb_table,
1965 .rc_key_map_size = ARRAY_SIZE(ir_codes_d680_dmb_table),
1966 .rc_query = cxusb_d680_dmb_rc_query,
1969 .num_device_descs = 1,
1970 .devices = {
1972 "Mygica D689 DMB-TH",
1973 { NULL },
1974 { &cxusb_table[19], NULL },
1979 static struct usb_driver cxusb_driver = {
1980 .name = "dvb_usb_cxusb",
1981 .probe = cxusb_probe,
1982 .disconnect = dvb_usb_device_exit,
1983 .id_table = cxusb_table,
1986 /* module stuff */
1987 static int __init cxusb_module_init(void)
1989 int result;
1990 if ((result = usb_register(&cxusb_driver))) {
1991 err("usb_register failed. Error number %d",result);
1992 return result;
1995 return 0;
1998 static void __exit cxusb_module_exit(void)
2000 /* deregister this driver from the USB subsystem */
2001 usb_deregister(&cxusb_driver);
2004 module_init (cxusb_module_init);
2005 module_exit (cxusb_module_exit);
2007 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
2008 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2009 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2010 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2011 MODULE_VERSION("1.0-alpha");
2012 MODULE_LICENSE("GPL");