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
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>
35 #include "mt352_priv.h"
37 #include "tuner-xc2028.h"
38 #include "tuner-simple.h"
48 /* Max transfer size done by I2C transfer functions */
49 #define MAX_XFER_SIZE 80
52 static int dvb_usb_cxusb_debug;
53 module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
54 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
56 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
58 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
59 #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
61 static int cxusb_ctrl_msg(struct dvb_usb_device *d,
62 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
64 int wo = (rbuf == NULL || rlen == 0); /* write-only */
65 u8 sndbuf[MAX_XFER_SIZE];
67 if (1 + wlen > sizeof(sndbuf)) {
68 warn("i2c wr: len=%d is too big!\n",
73 memset(sndbuf, 0, 1+wlen);
76 memcpy(&sndbuf[1], wbuf, wlen);
78 return dvb_usb_generic_write(d, sndbuf, 1+wlen);
80 return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
84 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
86 struct cxusb_state *st = d->priv;
89 if (st->gpio_write_state[GPIO_TUNER] == onoff)
94 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
97 deb_info("gpio_write failed.\n");
99 st->gpio_write_state[GPIO_TUNER] = onoff;
102 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
108 o[0] = 0xff & ~changemask; /* mask of bits to keep */
109 o[1] = newval & changemask; /* new values for bits */
111 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
112 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
113 deb_info("bluebird_gpio_write failed.\n");
115 return rc < 0 ? rc : gpio_state;
118 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
120 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
122 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
125 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
127 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
130 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
133 u8 o[2] = {addr, onoff};
137 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
144 deb_info("gpio_write failed.\n");
149 static int cxusb_tt_ct2_4400_gpio_tuner(struct dvb_usb_device *d, int onoff)
156 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
159 deb_info("gpio_write failed.\n");
166 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
169 struct dvb_usb_device *d = i2c_get_adapdata(adap);
173 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
176 for (i = 0; i < num; i++) {
178 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
179 switch (msg[i].addr) {
181 cxusb_gpio_tuner(d, 0);
184 cxusb_gpio_tuner(d, 1);
188 if (msg[i].flags & I2C_M_RD) {
190 u8 obuf[3], ibuf[MAX_XFER_SIZE];
192 if (1 + msg[i].len > sizeof(ibuf)) {
193 warn("i2c rd: len=%d is too big!\n",
199 obuf[1] = msg[i].len;
200 obuf[2] = msg[i].addr;
201 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
203 ibuf, 1+msg[i].len) < 0) {
204 warn("i2c read failed");
207 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
208 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
209 msg[i].addr == msg[i+1].addr) {
210 /* write to then read from same address */
211 u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE];
213 if (3 + msg[i].len > sizeof(obuf)) {
214 warn("i2c wr: len=%d is too big!\n",
219 if (1 + msg[i + 1].len > sizeof(ibuf)) {
220 warn("i2c rd: len=%d is too big!\n",
225 obuf[0] = msg[i].len;
226 obuf[1] = msg[i+1].len;
227 obuf[2] = msg[i].addr;
228 memcpy(&obuf[3], msg[i].buf, msg[i].len);
230 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
232 ibuf, 1+msg[i+1].len) < 0)
236 deb_i2c("i2c read may have failed\n");
238 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
243 u8 obuf[MAX_XFER_SIZE], ibuf;
245 if (2 + msg[i].len > sizeof(obuf)) {
246 warn("i2c wr: len=%d is too big!\n",
251 obuf[0] = msg[i].addr;
252 obuf[1] = msg[i].len;
253 memcpy(&obuf[2], msg[i].buf, msg[i].len);
255 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
256 2+msg[i].len, &ibuf,1) < 0)
259 deb_i2c("i2c write may have failed\n");
269 mutex_unlock(&d->i2c_mutex);
273 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
278 static struct i2c_algorithm cxusb_i2c_algo = {
279 .master_xfer = cxusb_i2c_xfer,
280 .functionality = cxusb_i2c_func,
283 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
287 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
289 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
292 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
296 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
297 if (d->state == DVB_USB_STATE_INIT &&
298 usb_set_interface(d->udev, 0, 0) < 0)
299 err("set interface failed");
300 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
301 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
302 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
304 /* FIXME: We don't know why, but we need to configure the
305 * lgdt3303 with the register settings below on resume */
308 0x0e, 0x2, 0x00, 0x7f,
309 0x0e, 0x2, 0x02, 0xfe,
310 0x0e, 0x2, 0x02, 0x01,
311 0x0e, 0x2, 0x00, 0x03,
312 0x0e, 0x2, 0x0d, 0x40,
313 0x0e, 0x2, 0x0e, 0x87,
314 0x0e, 0x2, 0x0f, 0x8e,
315 0x0e, 0x2, 0x10, 0x01,
316 0x0e, 0x2, 0x14, 0xd7,
317 0x0e, 0x2, 0x47, 0x88,
320 for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
321 ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
332 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
336 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
341 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
345 rc = cxusb_power_ctrl(d, onoff);
347 cxusb_nano2_led(d, 0);
352 static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
356 ret = cxusb_power_ctrl(d, onoff);
361 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
366 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
368 u8 buf[2] = { 0x03, 0x00 };
370 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
372 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
377 static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
380 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
382 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
387 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
389 int ep = d->props.generic_bulk_ctrl_endpoint;
390 const int timeout = 100;
391 const int junk_len = 32;
395 /* Discard remaining data in video pipe */
396 junk = kmalloc(junk_len, GFP_KERNEL);
400 if (usb_bulk_msg(d->udev,
401 usb_rcvbulkpipe(d->udev, ep),
402 junk, junk_len, &rd_count, timeout) < 0)
410 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
412 struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream;
413 const int timeout = 100;
414 const int junk_len = p->u.bulk.buffersize;
418 /* Discard remaining data in video pipe */
419 junk = kmalloc(junk_len, GFP_KERNEL);
423 if (usb_bulk_msg(d->udev,
424 usb_rcvbulkpipe(d->udev, p->endpoint),
425 junk, junk_len, &rd_count, timeout) < 0)
433 static int cxusb_d680_dmb_streaming_ctrl(
434 struct dvb_usb_adapter *adap, int onoff)
437 u8 buf[2] = { 0x03, 0x00 };
438 cxusb_d680_dmb_drain_video(adap->dev);
439 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
440 buf, sizeof(buf), NULL, 0);
442 int ret = cxusb_ctrl_msg(adap->dev,
443 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
448 static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
450 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
454 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
457 *state = REMOTE_NO_KEY_PRESSED;
459 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
460 if (rc5_custom(&keymap[i]) == ircode[2] &&
461 rc5_data(&keymap[i]) == ircode[3]) {
462 *event = keymap[i].keycode;
463 *state = REMOTE_KEY_PRESSED;
472 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
475 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
478 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
479 .buf = ircode, .len = 4 };
482 *state = REMOTE_NO_KEY_PRESSED;
484 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
487 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
488 if (rc5_custom(&keymap[i]) == ircode[1] &&
489 rc5_data(&keymap[i]) == ircode[2]) {
490 *event = keymap[i].keycode;
491 *state = REMOTE_KEY_PRESSED;
500 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
503 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
508 *state = REMOTE_NO_KEY_PRESSED;
510 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
513 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
514 if (rc5_custom(&keymap[i]) == ircode[0] &&
515 rc5_data(&keymap[i]) == ircode[1]) {
516 *event = keymap[i].keycode;
517 *state = REMOTE_KEY_PRESSED;
526 static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d)
531 u8 rc5_cmd, rc5_addr, rc5_toggle;
533 ret = cxusb_ctrl_msg(d, 0x10, NULL, 0, i, 2);
537 cmd = (i[0] << 8) | i[1];
540 rc5_cmd = cmd & 0x3F; /* bits 1-6 for command */
541 rc5_addr = (cmd & 0x07C0) >> 6; /* bits 7-11 for address */
542 rc5_toggle = (cmd & 0x0800) >> 11; /* bit 12 for toggle */
543 keycode = (rc5_addr << 8) | rc5_cmd;
544 rc_keydown(d->rc_dev, RC_BIT_RC5, keycode, rc5_toggle);
550 static struct rc_map_table rc_map_dvico_mce_table[] = {
554 { 0xfe1e, KEY_FAVORITES },
555 { 0xfe16, KEY_SETUP },
556 { 0xfe46, KEY_POWER2 },
558 { 0xfe49, KEY_BACK },
559 { 0xfe4d, KEY_MENU },
561 { 0xfe5b, KEY_LEFT },
562 { 0xfe5f, KEY_RIGHT },
563 { 0xfe53, KEY_DOWN },
565 { 0xfe59, KEY_INFO },
567 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
568 { 0xfe12, KEY_NEXTSONG }, /* Skip */
569 { 0xfe42, KEY_ENTER }, /* Windows/Start */
570 { 0xfe15, KEY_VOLUMEUP },
571 { 0xfe05, KEY_VOLUMEDOWN },
572 { 0xfe11, KEY_CHANNELUP },
573 { 0xfe09, KEY_CHANNELDOWN },
574 { 0xfe52, KEY_CAMERA },
575 { 0xfe5a, KEY_TUNER }, /* Live */
576 { 0xfe19, KEY_OPEN },
586 { 0xfe13, KEY_ANGLE }, /* Aspect */
588 { 0xfe1f, KEY_ZOOM },
589 { 0xfe43, KEY_REWIND },
590 { 0xfe47, KEY_PLAYPAUSE },
591 { 0xfe4f, KEY_FASTFORWARD },
592 { 0xfe57, KEY_MUTE },
593 { 0xfe0d, KEY_STOP },
594 { 0xfe01, KEY_RECORD },
595 { 0xfe4e, KEY_POWER },
598 static struct rc_map_table rc_map_dvico_portable_table[] = {
599 { 0xfc02, KEY_SETUP }, /* Profile */
600 { 0xfc43, KEY_POWER2 },
602 { 0xfc5a, KEY_BACK },
603 { 0xfc05, KEY_MENU },
604 { 0xfc47, KEY_INFO },
606 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
607 { 0xfc49, KEY_VOLUMEUP },
608 { 0xfc09, KEY_VOLUMEDOWN },
609 { 0xfc54, KEY_CHANNELUP },
610 { 0xfc0b, KEY_CHANNELDOWN },
611 { 0xfc16, KEY_CAMERA },
612 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
613 { 0xfc45, KEY_OPEN },
623 { 0xfc44, KEY_ANGLE }, /* Aspect */
625 { 0xfc07, KEY_ZOOM },
626 { 0xfc0a, KEY_REWIND },
627 { 0xfc08, KEY_PLAYPAUSE },
628 { 0xfc4b, KEY_FASTFORWARD },
629 { 0xfc5b, KEY_MUTE },
630 { 0xfc04, KEY_STOP },
631 { 0xfc56, KEY_RECORD },
632 { 0xfc57, KEY_POWER },
633 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
634 { 0xfc00, KEY_UNKNOWN }, /* HD */
637 static struct rc_map_table rc_map_d680_dmb_table[] = {
638 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
639 { 0x080c, KEY_ZOOM },
650 { 0x000a, KEY_MUTE },
651 { 0x0829, KEY_BACK },
652 { 0x0012, KEY_CHANNELUP },
653 { 0x0813, KEY_CHANNELDOWN },
654 { 0x002b, KEY_VOLUMEUP },
655 { 0x082c, KEY_VOLUMEDOWN },
657 { 0x0821, KEY_DOWN },
658 { 0x0011, KEY_LEFT },
659 { 0x0810, KEY_RIGHT },
661 { 0x081f, KEY_RECORD },
662 { 0x0017, KEY_PLAYPAUSE },
663 { 0x0816, KEY_PLAYPAUSE },
664 { 0x000b, KEY_STOP },
665 { 0x0827, KEY_FASTFORWARD },
666 { 0x0026, KEY_REWIND },
667 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
668 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
669 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
670 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
671 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
672 { 0x0025, KEY_POWER },
675 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
677 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
678 static u8 reset [] = { RESET, 0x80 };
679 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
680 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
681 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
682 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
684 mt352_write(fe, clock_config, sizeof(clock_config));
686 mt352_write(fe, reset, sizeof(reset));
687 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
689 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
690 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
691 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
696 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
697 { /* used in both lgz201 and th7579 */
698 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
699 static u8 reset [] = { RESET, 0x80 };
700 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
701 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
702 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
703 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
705 mt352_write(fe, clock_config, sizeof(clock_config));
707 mt352_write(fe, reset, sizeof(reset));
708 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
710 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
711 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
712 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
716 static struct cx22702_config cxusb_cx22702_config = {
717 .demod_address = 0x63,
718 .output_mode = CX22702_PARALLEL_OUTPUT,
721 static struct lgdt330x_config cxusb_lgdt3303_config = {
722 .demod_address = 0x0e,
723 .demod_chip = LGDT3303,
726 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
727 .demod_address = 0x0e,
728 .demod_chip = LGDT3303,
729 .clock_polarity_flip = 2,
732 static struct mt352_config cxusb_dee1601_config = {
733 .demod_address = 0x0f,
734 .demod_init = cxusb_dee1601_demod_init,
737 static struct zl10353_config cxusb_zl10353_dee1601_config = {
738 .demod_address = 0x0f,
742 static struct mt352_config cxusb_mt352_config = {
743 /* used in both lgz201 and th7579 */
744 .demod_address = 0x0f,
745 .demod_init = cxusb_mt352_demod_init,
748 static struct zl10353_config cxusb_zl10353_xc3028_config = {
749 .demod_address = 0x0f,
755 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
756 .demod_address = 0x0f,
760 .disable_i2c_gate_ctrl = 1,
763 static struct mt352_config cxusb_mt352_xc3028_config = {
764 .demod_address = 0x0f,
767 .demod_init = cxusb_mt352_demod_init,
770 /* FIXME: needs tweaking */
771 static struct mxl5005s_config aver_a868r_tuner = {
773 .if_freq = 6000000UL,
774 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
775 .agc_mode = MXL_SINGLE_AGC,
776 .tracking_filter = MXL_TF_C,
777 .rssi_enable = MXL_RSSI_ENABLE,
778 .cap_select = MXL_CAP_SEL_ENABLE,
779 .div_out = MXL_DIV_OUT_4,
780 .clock_out = MXL_CLOCK_OUT_DISABLE,
781 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
782 .top = MXL5005S_TOP_25P2,
783 .mod_mode = MXL_DIGITAL_MODE,
784 .if_mode = MXL_ZERO_IF,
785 .AgcMasterByte = 0x00,
788 /* FIXME: needs tweaking */
789 static struct mxl5005s_config d680_dmb_tuner = {
791 .if_freq = 36125000UL,
792 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
793 .agc_mode = MXL_SINGLE_AGC,
794 .tracking_filter = MXL_TF_C,
795 .rssi_enable = MXL_RSSI_ENABLE,
796 .cap_select = MXL_CAP_SEL_ENABLE,
797 .div_out = MXL_DIV_OUT_4,
798 .clock_out = MXL_CLOCK_OUT_DISABLE,
799 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
800 .top = MXL5005S_TOP_25P2,
801 .mod_mode = MXL_DIGITAL_MODE,
802 .if_mode = MXL_ZERO_IF,
803 .AgcMasterByte = 0x00,
806 static struct max2165_config mygica_d689_max2165_cfg = {
811 /* Callbacks for DVB USB */
812 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
814 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
815 &adap->dev->i2c_adap, 0x61,
816 TUNER_PHILIPS_FMD1216ME_MK3);
820 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
822 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61,
823 NULL, DVB_PLL_THOMSON_DTT7579);
827 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
829 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201);
833 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
835 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
836 NULL, DVB_PLL_THOMSON_DTT7579);
840 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
842 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
843 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
847 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
848 int command, int arg)
850 struct dvb_usb_adapter *adap = ptr;
851 struct dvb_usb_device *d = adap->dev;
854 case XC2028_TUNER_RESET:
855 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
856 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
858 case XC2028_RESET_CLK:
859 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
862 deb_info("%s: unknown command %d, arg %d\n", __func__,
870 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
872 struct dvb_frontend *fe;
873 struct xc2028_config cfg = {
874 .i2c_adap = &adap->dev->i2c_adap,
877 static struct xc2028_ctrl ctl = {
878 .fname = XC2028_DEFAULT_FIRMWARE,
880 .demod = XC3028_FE_ZARLINK456,
883 /* FIXME: generalize & move to common area */
884 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback;
886 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg);
887 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
890 fe->ops.tuner_ops.set_config(fe, &ctl);
895 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
897 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
898 &adap->dev->i2c_adap, &aver_a868r_tuner);
902 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
904 struct dvb_frontend *fe;
905 fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
906 &adap->dev->i2c_adap, &d680_dmb_tuner);
907 return (fe == NULL) ? -EIO : 0;
910 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
912 struct dvb_frontend *fe;
913 fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe,
914 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
915 return (fe == NULL) ? -EIO : 0;
918 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
921 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
922 err("set interface failed");
924 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
926 adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
927 &adap->dev->i2c_adap);
928 if ((adap->fe_adap[0].fe) != NULL)
934 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
936 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
937 err("set interface failed");
939 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
941 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
942 &cxusb_lgdt3303_config,
943 &adap->dev->i2c_adap);
944 if ((adap->fe_adap[0].fe) != NULL)
950 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
952 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
953 &adap->dev->i2c_adap);
954 if (adap->fe_adap[0].fe != NULL)
960 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
962 /* used in both lgz201 and th7579 */
963 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
964 err("set interface failed");
966 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
968 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
969 &adap->dev->i2c_adap);
970 if ((adap->fe_adap[0].fe) != NULL)
976 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
978 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
979 err("set interface failed");
981 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
983 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
984 &adap->dev->i2c_adap);
985 if ((adap->fe_adap[0].fe) != NULL)
988 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
989 &cxusb_zl10353_dee1601_config,
990 &adap->dev->i2c_adap);
991 if ((adap->fe_adap[0].fe) != NULL)
997 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
1001 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
1002 .buf = ircode, .len = 4 };
1004 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1005 err("set interface failed");
1007 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1009 /* reset the tuner and demodulator */
1010 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1011 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1012 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1014 adap->fe_adap[0].fe =
1015 dvb_attach(zl10353_attach,
1016 &cxusb_zl10353_xc3028_config_no_i2c_gate,
1017 &adap->dev->i2c_adap);
1018 if ((adap->fe_adap[0].fe) == NULL)
1021 /* try to determine if there is no IR decoder on the I2C bus */
1022 for (i = 0; adap->dev->props.rc.legacy.rc_map_table != NULL && i < 5; i++) {
1024 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
1026 if (ircode[0] == 0 && ircode[1] == 0)
1028 if (ircode[2] + ircode[3] != 0xff) {
1030 adap->dev->props.rc.legacy.rc_map_table = NULL;
1031 info("No IR receiver detected on this device.");
1039 static struct dibx000_agc_config dib7070_agc_config = {
1040 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1043 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1044 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1045 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1047 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1048 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1050 .time_stabiliz = 10,
1074 .perform_agc_softsplit = 0,
1077 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1087 .IO_CLK_en_core = 1,
1090 /* refsel, sel, freq_15k */
1091 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1092 .ifreq = (0 << 25) | 0,
1094 .xtal_hz = 12000000,
1097 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
1098 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
1099 .output_mpeg2_in_188_bytes = 1,
1101 .agc_config_count = 1,
1102 .agc = &dib7070_agc_config,
1103 .bw = &dib7070_bw_config_12_mhz,
1104 .tuner_is_baseband = 1,
1110 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1112 .hostbus_diversity = 1,
1115 struct dib0700_adapter_state {
1116 int (*set_param_save)(struct dvb_frontend *);
1117 struct dib7000p_ops dib7000p_ops;
1120 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
1122 struct dib0700_adapter_state *state = adap->priv;
1124 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1125 err("set interface failed");
1127 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1129 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1131 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1134 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1135 &cxusb_dualdig4_rev2_config) < 0) {
1136 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1140 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
1141 &cxusb_dualdig4_rev2_config);
1142 if (adap->fe_adap[0].fe == NULL)
1148 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
1150 struct dvb_usb_adapter *adap = fe->dvb->priv;
1151 struct dib0700_adapter_state *state = adap->priv;
1153 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
1156 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1161 static struct dib0070_config dib7070p_dib0070_config = {
1162 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1163 .reset = dib7070_tuner_reset,
1164 .sleep = dib7070_tuner_sleep,
1168 static int dib7070_set_param_override(struct dvb_frontend *fe)
1170 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1171 struct dvb_usb_adapter *adap = fe->dvb->priv;
1172 struct dib0700_adapter_state *state = adap->priv;
1175 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
1177 case BAND_VHF: offset = 950; break;
1179 case BAND_UHF: offset = 550; break;
1182 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1184 return state->set_param_save(fe);
1187 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1189 struct dib0700_adapter_state *st = adap->priv;
1190 struct i2c_adapter *tun_i2c;
1193 * No need to call dvb7000p_attach here, as it was called
1194 * already, as frontend_attach method is called first, and
1195 * tuner_attach is only called on sucess.
1197 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
1198 DIBX000_I2C_INTERFACE_TUNER, 1);
1200 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1201 &dib7070p_dib0070_config) == NULL)
1204 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1205 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1209 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1211 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1212 err("set interface failed");
1214 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1216 /* reset the tuner and demodulator */
1217 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1218 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1219 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1221 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
1222 &cxusb_zl10353_xc3028_config,
1223 &adap->dev->i2c_adap);
1224 if ((adap->fe_adap[0].fe) != NULL)
1227 adap->fe_adap[0].fe = dvb_attach(mt352_attach,
1228 &cxusb_mt352_xc3028_config,
1229 &adap->dev->i2c_adap);
1230 if ((adap->fe_adap[0].fe) != NULL)
1236 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1237 .prod = LGS8GXX_PROD_LGS8GL5,
1238 .demod_address = 0x19,
1242 .if_clk_freq = 30400, /* 30.4 MHz */
1243 .if_freq = 5725, /* 5.725 MHz */
1250 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1252 struct dvb_usb_device *d = adap->dev;
1255 /* Select required USB configuration */
1256 if (usb_set_interface(d->udev, 0, 0) < 0)
1257 err("set interface failed");
1259 /* Unblock all USB pipes */
1260 usb_clear_halt(d->udev,
1261 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1262 usb_clear_halt(d->udev,
1263 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1264 usb_clear_halt(d->udev,
1265 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1267 /* Drain USB pipes to avoid hang after reboot */
1268 for (n = 0; n < 5; n++) {
1269 cxusb_d680_dmb_drain_message(d);
1270 cxusb_d680_dmb_drain_video(d);
1274 /* Reset the tuner */
1275 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1276 err("clear tuner gpio failed");
1280 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1281 err("set tuner gpio failed");
1286 /* Attach frontend */
1287 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1288 if (adap->fe_adap[0].fe == NULL)
1294 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1295 .prod = ATBM8830_PROD_8830,
1296 .demod_address = 0x40,
1298 .ts_sampling_edge = 1,
1300 .osc_clk_freq = 30400, /* in kHz */
1301 .if_freq = 0, /* zero IF */
1308 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1310 struct dvb_usb_device *d = adap->dev;
1312 /* Select required USB configuration */
1313 if (usb_set_interface(d->udev, 0, 0) < 0)
1314 err("set interface failed");
1316 /* Unblock all USB pipes */
1317 usb_clear_halt(d->udev,
1318 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1319 usb_clear_halt(d->udev,
1320 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1321 usb_clear_halt(d->udev,
1322 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1325 /* Reset the tuner */
1326 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1327 err("clear tuner gpio failed");
1331 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1332 err("set tuner gpio failed");
1337 /* Attach frontend */
1338 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1340 if (adap->fe_adap[0].fe == NULL)
1346 static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
1348 struct dvb_usb_device *d = adap->dev;
1349 struct cxusb_state *st = d->priv;
1350 struct i2c_adapter *adapter;
1351 struct i2c_client *client_demod;
1352 struct i2c_client *client_tuner;
1353 struct i2c_board_info info;
1354 struct si2168_config si2168_config;
1355 struct si2157_config si2157_config;
1357 /* reset the tuner */
1358 if (cxusb_tt_ct2_4400_gpio_tuner(d, 0) < 0) {
1359 err("clear tuner gpio failed");
1363 if (cxusb_tt_ct2_4400_gpio_tuner(d, 1) < 0) {
1364 err("set tuner gpio failed");
1369 /* attach frontend */
1370 si2168_config.i2c_adapter = &adapter;
1371 si2168_config.fe = &adap->fe_adap[0].fe;
1372 memset(&info, 0, sizeof(struct i2c_board_info));
1373 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1375 info.platform_data = &si2168_config;
1376 request_module(info.type);
1377 client_demod = i2c_new_device(&d->i2c_adap, &info);
1378 if (client_demod == NULL || client_demod->dev.driver == NULL)
1381 if (!try_module_get(client_demod->dev.driver->owner)) {
1382 i2c_unregister_device(client_demod);
1386 st->i2c_client_demod = client_demod;
1389 memset(&si2157_config, 0, sizeof(si2157_config));
1390 si2157_config.fe = adap->fe_adap[0].fe;
1391 memset(&info, 0, sizeof(struct i2c_board_info));
1392 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1394 info.platform_data = &si2157_config;
1395 request_module(info.type);
1396 client_tuner = i2c_new_device(adapter, &info);
1397 if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1398 module_put(client_demod->dev.driver->owner);
1399 i2c_unregister_device(client_demod);
1402 if (!try_module_get(client_tuner->dev.driver->owner)) {
1403 i2c_unregister_device(client_tuner);
1404 module_put(client_demod->dev.driver->owner);
1405 i2c_unregister_device(client_demod);
1409 st->i2c_client_tuner = client_tuner;
1415 * DViCO has shipped two devices with the same USB ID, but only one of them
1416 * needs a firmware download. Check the device class details to see if they
1417 * have non-default values to decide whether the device is actually cold or
1418 * not, and forget a match if it turns out we selected the wrong device.
1420 static int bluebird_fx2_identify_state(struct usb_device *udev,
1421 struct dvb_usb_device_properties *props,
1422 struct dvb_usb_device_description **desc,
1425 int wascold = *cold;
1427 *cold = udev->descriptor.bDeviceClass == 0xff &&
1428 udev->descriptor.bDeviceSubClass == 0xff &&
1429 udev->descriptor.bDeviceProtocol == 0xff;
1431 if (*cold && !wascold)
1438 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1439 * firmware file before download.
1442 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
1443 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1444 const struct firmware *fw)
1448 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1449 int idoff = dvico_firmware_id_offsets[pos];
1451 if (fw->size < idoff + 4)
1454 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1455 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1456 struct firmware new_fw;
1457 u8 *new_fw_data = vmalloc(fw->size);
1463 memcpy(new_fw_data, fw->data, fw->size);
1464 new_fw.size = fw->size;
1465 new_fw.data = new_fw_data;
1467 new_fw_data[idoff + 2] =
1468 le16_to_cpu(udev->descriptor.idProduct) + 1;
1469 new_fw_data[idoff + 3] =
1470 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1472 ret = usb_cypress_load_firmware(udev, &new_fw,
1482 /* DVB USB Driver stuff */
1483 static struct dvb_usb_device_properties cxusb_medion_properties;
1484 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1485 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1486 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1487 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1488 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1489 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1490 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1491 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1492 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1493 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1494 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1495 static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties;
1497 static int cxusb_probe(struct usb_interface *intf,
1498 const struct usb_device_id *id)
1500 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1501 THIS_MODULE, NULL, adapter_nr) ||
1502 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1503 THIS_MODULE, NULL, adapter_nr) ||
1504 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1505 THIS_MODULE, NULL, adapter_nr) ||
1506 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1507 THIS_MODULE, NULL, adapter_nr) ||
1508 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1509 THIS_MODULE, NULL, adapter_nr) ||
1510 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1511 THIS_MODULE, NULL, adapter_nr) ||
1512 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1513 THIS_MODULE, NULL, adapter_nr) ||
1514 0 == dvb_usb_device_init(intf,
1515 &cxusb_bluebird_nano2_needsfirmware_properties,
1516 THIS_MODULE, NULL, adapter_nr) ||
1517 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1518 THIS_MODULE, NULL, adapter_nr) ||
1519 0 == dvb_usb_device_init(intf,
1520 &cxusb_bluebird_dualdig4_rev2_properties,
1521 THIS_MODULE, NULL, adapter_nr) ||
1522 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1523 THIS_MODULE, NULL, adapter_nr) ||
1524 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1525 THIS_MODULE, NULL, adapter_nr) ||
1526 0 == dvb_usb_device_init(intf, &cxusb_tt_ct2_4400_properties,
1527 THIS_MODULE, NULL, adapter_nr) ||
1534 static void cxusb_disconnect(struct usb_interface *intf)
1536 struct dvb_usb_device *d = usb_get_intfdata(intf);
1537 struct cxusb_state *st = d->priv;
1538 struct i2c_client *client;
1540 /* remove I2C client for tuner */
1541 client = st->i2c_client_tuner;
1543 module_put(client->dev.driver->owner);
1544 i2c_unregister_device(client);
1547 /* remove I2C client for demodulator */
1548 client = st->i2c_client_demod;
1550 module_put(client->dev.driver->owner);
1551 i2c_unregister_device(client);
1554 dvb_usb_device_exit(intf);
1557 static struct usb_device_id cxusb_table [] = {
1558 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
1559 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
1560 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
1561 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
1562 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
1563 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
1564 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
1565 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
1566 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
1567 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
1568 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
1569 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
1570 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
1571 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
1572 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
1573 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
1574 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
1575 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
1576 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
1577 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
1578 { USB_DEVICE(USB_VID_TECHNOTREND, USB_PID_TECHNOTREND_TVSTICK_CT2_4400) },
1579 {} /* Terminating entry */
1581 MODULE_DEVICE_TABLE (usb, cxusb_table);
1583 static struct dvb_usb_device_properties cxusb_medion_properties = {
1584 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1586 .usb_ctrl = CYPRESS_FX2,
1588 .size_of_priv = sizeof(struct cxusb_state),
1595 .streaming_ctrl = cxusb_streaming_ctrl,
1596 .frontend_attach = cxusb_cx22702_frontend_attach,
1597 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1598 /* parameter for the MPEG2-data transfer */
1612 .power_ctrl = cxusb_power_ctrl,
1614 .i2c_algo = &cxusb_i2c_algo,
1616 .generic_bulk_ctrl_endpoint = 0x01,
1618 .num_device_descs = 1,
1620 { "Medion MD95700 (MDUSBTV-HYBRID)",
1622 { &cxusb_table[0], NULL },
1627 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1628 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1630 .usb_ctrl = DEVICE_SPECIFIC,
1631 .firmware = "dvb-usb-bluebird-01.fw",
1632 .download_firmware = bluebird_patch_dvico_firmware_download,
1633 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1634 use usb alt setting 7 for EP2 transfer (atsc) */
1636 .size_of_priv = sizeof(struct cxusb_state),
1643 .streaming_ctrl = cxusb_streaming_ctrl,
1644 .frontend_attach = cxusb_lgdt3303_frontend_attach,
1645 .tuner_attach = cxusb_lgh064f_tuner_attach,
1647 /* parameter for the MPEG2-data transfer */
1662 .power_ctrl = cxusb_bluebird_power_ctrl,
1664 .i2c_algo = &cxusb_i2c_algo,
1668 .rc_map_table = rc_map_dvico_portable_table,
1669 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1670 .rc_query = cxusb_rc_query,
1673 .generic_bulk_ctrl_endpoint = 0x01,
1675 .num_device_descs = 1,
1677 { "DViCO FusionHDTV5 USB Gold",
1678 { &cxusb_table[1], NULL },
1679 { &cxusb_table[2], NULL },
1684 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1685 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1687 .usb_ctrl = DEVICE_SPECIFIC,
1688 .firmware = "dvb-usb-bluebird-01.fw",
1689 .download_firmware = bluebird_patch_dvico_firmware_download,
1690 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1691 use usb alt setting 7 for EP2 transfer (atsc) */
1693 .size_of_priv = sizeof(struct cxusb_state),
1700 .streaming_ctrl = cxusb_streaming_ctrl,
1701 .frontend_attach = cxusb_dee1601_frontend_attach,
1702 .tuner_attach = cxusb_dee1601_tuner_attach,
1703 /* parameter for the MPEG2-data transfer */
1718 .power_ctrl = cxusb_bluebird_power_ctrl,
1720 .i2c_algo = &cxusb_i2c_algo,
1724 .rc_map_table = rc_map_dvico_mce_table,
1725 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
1726 .rc_query = cxusb_rc_query,
1729 .generic_bulk_ctrl_endpoint = 0x01,
1731 .num_device_descs = 3,
1733 { "DViCO FusionHDTV DVB-T Dual USB",
1734 { &cxusb_table[3], NULL },
1735 { &cxusb_table[4], NULL },
1737 { "DigitalNow DVB-T Dual USB",
1738 { &cxusb_table[9], NULL },
1739 { &cxusb_table[10], NULL },
1741 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1742 { &cxusb_table[11], NULL },
1743 { &cxusb_table[12], NULL },
1748 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1749 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1751 .usb_ctrl = DEVICE_SPECIFIC,
1752 .firmware = "dvb-usb-bluebird-01.fw",
1753 .download_firmware = bluebird_patch_dvico_firmware_download,
1754 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1755 use usb alt setting 7 for EP2 transfer (atsc) */
1757 .size_of_priv = sizeof(struct cxusb_state),
1764 .streaming_ctrl = cxusb_streaming_ctrl,
1765 .frontend_attach = cxusb_mt352_frontend_attach,
1766 .tuner_attach = cxusb_lgz201_tuner_attach,
1768 /* parameter for the MPEG2-data transfer */
1782 .power_ctrl = cxusb_bluebird_power_ctrl,
1784 .i2c_algo = &cxusb_i2c_algo,
1788 .rc_map_table = rc_map_dvico_portable_table,
1789 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1790 .rc_query = cxusb_rc_query,
1793 .generic_bulk_ctrl_endpoint = 0x01,
1794 .num_device_descs = 1,
1796 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1797 { &cxusb_table[5], NULL },
1798 { &cxusb_table[6], NULL },
1803 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1804 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1806 .usb_ctrl = DEVICE_SPECIFIC,
1807 .firmware = "dvb-usb-bluebird-01.fw",
1808 .download_firmware = bluebird_patch_dvico_firmware_download,
1809 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1810 use usb alt setting 7 for EP2 transfer (atsc) */
1812 .size_of_priv = sizeof(struct cxusb_state),
1819 .streaming_ctrl = cxusb_streaming_ctrl,
1820 .frontend_attach = cxusb_mt352_frontend_attach,
1821 .tuner_attach = cxusb_dtt7579_tuner_attach,
1823 /* parameter for the MPEG2-data transfer */
1837 .power_ctrl = cxusb_bluebird_power_ctrl,
1839 .i2c_algo = &cxusb_i2c_algo,
1843 .rc_map_table = rc_map_dvico_portable_table,
1844 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1845 .rc_query = cxusb_rc_query,
1848 .generic_bulk_ctrl_endpoint = 0x01,
1850 .num_device_descs = 1,
1852 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1853 { &cxusb_table[7], NULL },
1854 { &cxusb_table[8], NULL },
1859 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1860 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1862 .usb_ctrl = CYPRESS_FX2,
1864 .size_of_priv = sizeof(struct cxusb_state),
1871 .streaming_ctrl = cxusb_streaming_ctrl,
1872 .frontend_attach = cxusb_dualdig4_frontend_attach,
1873 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1874 /* parameter for the MPEG2-data transfer */
1889 .power_ctrl = cxusb_power_ctrl,
1891 .i2c_algo = &cxusb_i2c_algo,
1893 .generic_bulk_ctrl_endpoint = 0x01,
1897 .rc_map_table = rc_map_dvico_mce_table,
1898 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
1899 .rc_query = cxusb_bluebird2_rc_query,
1902 .num_device_descs = 1,
1904 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1906 { &cxusb_table[13], NULL },
1911 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1912 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1914 .usb_ctrl = CYPRESS_FX2,
1915 .identify_state = bluebird_fx2_identify_state,
1917 .size_of_priv = sizeof(struct cxusb_state),
1924 .streaming_ctrl = cxusb_streaming_ctrl,
1925 .frontend_attach = cxusb_nano2_frontend_attach,
1926 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1927 /* parameter for the MPEG2-data transfer */
1942 .power_ctrl = cxusb_nano2_power_ctrl,
1944 .i2c_algo = &cxusb_i2c_algo,
1946 .generic_bulk_ctrl_endpoint = 0x01,
1950 .rc_map_table = rc_map_dvico_portable_table,
1951 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1952 .rc_query = cxusb_bluebird2_rc_query,
1955 .num_device_descs = 1,
1957 { "DViCO FusionHDTV DVB-T NANO2",
1959 { &cxusb_table[14], NULL },
1964 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1965 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1967 .usb_ctrl = DEVICE_SPECIFIC,
1968 .firmware = "dvb-usb-bluebird-02.fw",
1969 .download_firmware = bluebird_patch_dvico_firmware_download,
1970 .identify_state = bluebird_fx2_identify_state,
1972 .size_of_priv = sizeof(struct cxusb_state),
1979 .streaming_ctrl = cxusb_streaming_ctrl,
1980 .frontend_attach = cxusb_nano2_frontend_attach,
1981 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1982 /* parameter for the MPEG2-data transfer */
1997 .power_ctrl = cxusb_nano2_power_ctrl,
1999 .i2c_algo = &cxusb_i2c_algo,
2001 .generic_bulk_ctrl_endpoint = 0x01,
2005 .rc_map_table = rc_map_dvico_portable_table,
2006 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
2007 .rc_query = cxusb_rc_query,
2010 .num_device_descs = 1,
2012 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
2013 { &cxusb_table[14], NULL },
2014 { &cxusb_table[15], NULL },
2019 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
2020 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2022 .usb_ctrl = CYPRESS_FX2,
2024 .size_of_priv = sizeof(struct cxusb_state),
2031 .streaming_ctrl = cxusb_aver_streaming_ctrl,
2032 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
2033 .tuner_attach = cxusb_mxl5003s_tuner_attach,
2034 /* parameter for the MPEG2-data transfer */
2048 .power_ctrl = cxusb_aver_power_ctrl,
2050 .i2c_algo = &cxusb_i2c_algo,
2052 .generic_bulk_ctrl_endpoint = 0x01,
2054 .num_device_descs = 1,
2056 { "AVerMedia AVerTVHD Volar (A868R)",
2058 { &cxusb_table[16], NULL },
2064 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2065 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2067 .usb_ctrl = CYPRESS_FX2,
2069 .size_of_priv = sizeof(struct cxusb_state),
2074 .size_of_priv = sizeof(struct dib0700_adapter_state),
2077 .streaming_ctrl = cxusb_streaming_ctrl,
2078 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
2079 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
2080 /* parameter for the MPEG2-data transfer */
2095 .power_ctrl = cxusb_bluebird_power_ctrl,
2097 .i2c_algo = &cxusb_i2c_algo,
2099 .generic_bulk_ctrl_endpoint = 0x01,
2103 .rc_map_table = rc_map_dvico_mce_table,
2104 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
2105 .rc_query = cxusb_rc_query,
2108 .num_device_descs = 1,
2110 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
2112 { &cxusb_table[17], NULL },
2117 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2118 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2120 .usb_ctrl = CYPRESS_FX2,
2122 .size_of_priv = sizeof(struct cxusb_state),
2129 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2130 .frontend_attach = cxusb_d680_dmb_frontend_attach,
2131 .tuner_attach = cxusb_d680_dmb_tuner_attach,
2133 /* parameter for the MPEG2-data transfer */
2148 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2150 .i2c_algo = &cxusb_i2c_algo,
2152 .generic_bulk_ctrl_endpoint = 0x01,
2156 .rc_map_table = rc_map_d680_dmb_table,
2157 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2158 .rc_query = cxusb_d680_dmb_rc_query,
2161 .num_device_descs = 1,
2164 "Conexant DMB-TH Stick",
2166 { &cxusb_table[18], NULL },
2171 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2172 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2174 .usb_ctrl = CYPRESS_FX2,
2176 .size_of_priv = sizeof(struct cxusb_state),
2183 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2184 .frontend_attach = cxusb_mygica_d689_frontend_attach,
2185 .tuner_attach = cxusb_mygica_d689_tuner_attach,
2187 /* parameter for the MPEG2-data transfer */
2202 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2204 .i2c_algo = &cxusb_i2c_algo,
2206 .generic_bulk_ctrl_endpoint = 0x01,
2210 .rc_map_table = rc_map_d680_dmb_table,
2211 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2212 .rc_query = cxusb_d680_dmb_rc_query,
2215 .num_device_descs = 1,
2218 "Mygica D689 DMB-TH",
2220 { &cxusb_table[19], NULL },
2225 static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties = {
2226 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2228 .usb_ctrl = CYPRESS_FX2,
2230 .size_of_priv = sizeof(struct cxusb_state),
2237 .streaming_ctrl = cxusb_streaming_ctrl,
2238 /* both frontend and tuner attached in the
2240 .frontend_attach = cxusb_tt_ct2_4400_attach,
2242 /* parameter for the MPEG2-data transfer */
2257 .i2c_algo = &cxusb_i2c_algo,
2258 .generic_bulk_ctrl_endpoint = 0x01,
2259 .generic_bulk_ctrl_endpoint_response = 0x81,
2262 .rc_codes = RC_MAP_TT_1500,
2263 .allowed_protos = RC_BIT_RC5,
2264 .rc_query = cxusb_tt_ct2_4400_rc_query,
2268 .num_device_descs = 1,
2271 "TechnoTrend TVStick CT2-4400",
2273 { &cxusb_table[20], NULL },
2278 static struct usb_driver cxusb_driver = {
2279 .name = "dvb_usb_cxusb",
2280 .probe = cxusb_probe,
2281 .disconnect = cxusb_disconnect,
2282 .id_table = cxusb_table,
2285 module_usb_driver(cxusb_driver);
2287 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
2288 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2289 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2290 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2291 MODULE_VERSION("1.0-alpha");
2292 MODULE_LICENSE("GPL");