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@posteo.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"
49 static int dvb_usb_cxusb_debug;
50 module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
51 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
53 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
55 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
56 #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
58 static int cxusb_ctrl_msg(struct dvb_usb_device *d,
59 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
61 struct cxusb_state *st = d->priv;
64 if (1 + wlen > MAX_XFER_SIZE) {
65 warn("i2c wr: len=%d is too big!\n", wlen);
69 if (rlen > MAX_XFER_SIZE) {
70 warn("i2c rd: len=%d is too big!\n", rlen);
74 mutex_lock(&d->data_mutex);
76 memcpy(&st->data[1], wbuf, wlen);
77 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, st->data, rlen, 0);
78 if (!ret && rbuf && rlen)
79 memcpy(rbuf, st->data, rlen);
81 mutex_unlock(&d->data_mutex);
86 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
88 struct cxusb_state *st = d->priv;
91 if (st->gpio_write_state[GPIO_TUNER] == onoff)
96 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
99 deb_info("gpio_write failed.\n");
101 st->gpio_write_state[GPIO_TUNER] = onoff;
104 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
110 o[0] = 0xff & ~changemask; /* mask of bits to keep */
111 o[1] = newval & changemask; /* new values for bits */
113 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
114 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
115 deb_info("bluebird_gpio_write failed.\n");
117 return rc < 0 ? rc : gpio_state;
120 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
122 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
124 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
127 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
129 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
132 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
135 u8 o[2] = {addr, onoff};
139 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
146 deb_info("gpio_write failed.\n");
152 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
155 struct dvb_usb_device *d = i2c_get_adapdata(adap);
159 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
162 for (i = 0; i < num; i++) {
164 if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_MEDION)
165 switch (msg[i].addr) {
167 cxusb_gpio_tuner(d, 0);
170 cxusb_gpio_tuner(d, 1);
174 if (msg[i].flags & I2C_M_RD) {
176 u8 obuf[3], ibuf[MAX_XFER_SIZE];
178 if (1 + msg[i].len > sizeof(ibuf)) {
179 warn("i2c rd: len=%d is too big!\n",
185 obuf[1] = msg[i].len;
186 obuf[2] = msg[i].addr;
187 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
189 ibuf, 1+msg[i].len) < 0) {
190 warn("i2c read failed");
193 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
194 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
195 msg[i].addr == msg[i+1].addr) {
196 /* write to then read from same address */
197 u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE];
199 if (3 + msg[i].len > sizeof(obuf)) {
200 warn("i2c wr: len=%d is too big!\n",
205 if (1 + msg[i + 1].len > sizeof(ibuf)) {
206 warn("i2c rd: len=%d is too big!\n",
211 obuf[0] = msg[i].len;
212 obuf[1] = msg[i+1].len;
213 obuf[2] = msg[i].addr;
214 memcpy(&obuf[3], msg[i].buf, msg[i].len);
216 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
218 ibuf, 1+msg[i+1].len) < 0)
222 deb_i2c("i2c read may have failed\n");
224 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
229 u8 obuf[MAX_XFER_SIZE], ibuf;
231 if (2 + msg[i].len > sizeof(obuf)) {
232 warn("i2c wr: len=%d is too big!\n",
237 obuf[0] = msg[i].addr;
238 obuf[1] = msg[i].len;
239 memcpy(&obuf[2], msg[i].buf, msg[i].len);
241 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
242 2+msg[i].len, &ibuf,1) < 0)
245 deb_i2c("i2c write may have failed\n");
255 mutex_unlock(&d->i2c_mutex);
259 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
264 static struct i2c_algorithm cxusb_i2c_algo = {
265 .master_xfer = cxusb_i2c_xfer,
266 .functionality = cxusb_i2c_func,
269 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
273 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
275 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
278 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
282 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
283 if (d->state == DVB_USB_STATE_INIT &&
284 usb_set_interface(d->udev, 0, 0) < 0)
285 err("set interface failed");
286 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
287 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
288 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
290 /* FIXME: We don't know why, but we need to configure the
291 * lgdt3303 with the register settings below on resume */
294 0x0e, 0x2, 0x00, 0x7f,
295 0x0e, 0x2, 0x02, 0xfe,
296 0x0e, 0x2, 0x02, 0x01,
297 0x0e, 0x2, 0x00, 0x03,
298 0x0e, 0x2, 0x0d, 0x40,
299 0x0e, 0x2, 0x0e, 0x87,
300 0x0e, 0x2, 0x0f, 0x8e,
301 0x0e, 0x2, 0x10, 0x01,
302 0x0e, 0x2, 0x14, 0xd7,
303 0x0e, 0x2, 0x47, 0x88,
306 for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
307 ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
318 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
322 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
327 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
331 rc = cxusb_power_ctrl(d, onoff);
333 cxusb_nano2_led(d, 0);
338 static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
342 ret = cxusb_power_ctrl(d, onoff);
347 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
352 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
354 u8 buf[2] = { 0x03, 0x00 };
356 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
358 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
363 static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
366 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
368 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
373 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
375 int ep = d->props.generic_bulk_ctrl_endpoint;
376 const int timeout = 100;
377 const int junk_len = 32;
381 /* Discard remaining data in video pipe */
382 junk = kmalloc(junk_len, GFP_KERNEL);
386 if (usb_bulk_msg(d->udev,
387 usb_rcvbulkpipe(d->udev, ep),
388 junk, junk_len, &rd_count, timeout) < 0)
396 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
398 struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream;
399 const int timeout = 100;
400 const int junk_len = p->u.bulk.buffersize;
404 /* Discard remaining data in video pipe */
405 junk = kmalloc(junk_len, GFP_KERNEL);
409 if (usb_bulk_msg(d->udev,
410 usb_rcvbulkpipe(d->udev, p->endpoint),
411 junk, junk_len, &rd_count, timeout) < 0)
419 static int cxusb_d680_dmb_streaming_ctrl(
420 struct dvb_usb_adapter *adap, int onoff)
423 u8 buf[2] = { 0x03, 0x00 };
424 cxusb_d680_dmb_drain_video(adap->dev);
425 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
426 buf, sizeof(buf), NULL, 0);
428 int ret = cxusb_ctrl_msg(adap->dev,
429 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
434 static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
436 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
440 if (cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4) < 0)
444 *state = REMOTE_NO_KEY_PRESSED;
446 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
447 if (rc5_custom(&keymap[i]) == ircode[2] &&
448 rc5_data(&keymap[i]) == ircode[3]) {
449 *event = keymap[i].keycode;
450 *state = REMOTE_KEY_PRESSED;
459 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
462 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
465 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
466 .buf = ircode, .len = 4 };
469 *state = REMOTE_NO_KEY_PRESSED;
471 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
474 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
475 if (rc5_custom(&keymap[i]) == ircode[1] &&
476 rc5_data(&keymap[i]) == ircode[2]) {
477 *event = keymap[i].keycode;
478 *state = REMOTE_KEY_PRESSED;
487 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
490 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
495 *state = REMOTE_NO_KEY_PRESSED;
497 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
500 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
501 if (rc5_custom(&keymap[i]) == ircode[0] &&
502 rc5_data(&keymap[i]) == ircode[1]) {
503 *event = keymap[i].keycode;
504 *state = REMOTE_KEY_PRESSED;
513 static struct rc_map_table rc_map_dvico_mce_table[] = {
517 { 0xfe1e, KEY_FAVORITES },
518 { 0xfe16, KEY_SETUP },
519 { 0xfe46, KEY_POWER2 },
521 { 0xfe49, KEY_BACK },
522 { 0xfe4d, KEY_MENU },
524 { 0xfe5b, KEY_LEFT },
525 { 0xfe5f, KEY_RIGHT },
526 { 0xfe53, KEY_DOWN },
528 { 0xfe59, KEY_INFO },
530 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
531 { 0xfe12, KEY_NEXTSONG }, /* Skip */
532 { 0xfe42, KEY_ENTER }, /* Windows/Start */
533 { 0xfe15, KEY_VOLUMEUP },
534 { 0xfe05, KEY_VOLUMEDOWN },
535 { 0xfe11, KEY_CHANNELUP },
536 { 0xfe09, KEY_CHANNELDOWN },
537 { 0xfe52, KEY_CAMERA },
538 { 0xfe5a, KEY_TUNER }, /* Live */
539 { 0xfe19, KEY_OPEN },
549 { 0xfe13, KEY_ANGLE }, /* Aspect */
551 { 0xfe1f, KEY_ZOOM },
552 { 0xfe43, KEY_REWIND },
553 { 0xfe47, KEY_PLAYPAUSE },
554 { 0xfe4f, KEY_FASTFORWARD },
555 { 0xfe57, KEY_MUTE },
556 { 0xfe0d, KEY_STOP },
557 { 0xfe01, KEY_RECORD },
558 { 0xfe4e, KEY_POWER },
561 static struct rc_map_table rc_map_dvico_portable_table[] = {
562 { 0xfc02, KEY_SETUP }, /* Profile */
563 { 0xfc43, KEY_POWER2 },
565 { 0xfc5a, KEY_BACK },
566 { 0xfc05, KEY_MENU },
567 { 0xfc47, KEY_INFO },
569 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
570 { 0xfc49, KEY_VOLUMEUP },
571 { 0xfc09, KEY_VOLUMEDOWN },
572 { 0xfc54, KEY_CHANNELUP },
573 { 0xfc0b, KEY_CHANNELDOWN },
574 { 0xfc16, KEY_CAMERA },
575 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
576 { 0xfc45, KEY_OPEN },
586 { 0xfc44, KEY_ANGLE }, /* Aspect */
588 { 0xfc07, KEY_ZOOM },
589 { 0xfc0a, KEY_REWIND },
590 { 0xfc08, KEY_PLAYPAUSE },
591 { 0xfc4b, KEY_FASTFORWARD },
592 { 0xfc5b, KEY_MUTE },
593 { 0xfc04, KEY_STOP },
594 { 0xfc56, KEY_RECORD },
595 { 0xfc57, KEY_POWER },
596 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
597 { 0xfc00, KEY_UNKNOWN }, /* HD */
600 static struct rc_map_table rc_map_d680_dmb_table[] = {
601 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
602 { 0x080c, KEY_ZOOM },
613 { 0x000a, KEY_MUTE },
614 { 0x0829, KEY_BACK },
615 { 0x0012, KEY_CHANNELUP },
616 { 0x0813, KEY_CHANNELDOWN },
617 { 0x002b, KEY_VOLUMEUP },
618 { 0x082c, KEY_VOLUMEDOWN },
620 { 0x0821, KEY_DOWN },
621 { 0x0011, KEY_LEFT },
622 { 0x0810, KEY_RIGHT },
624 { 0x081f, KEY_RECORD },
625 { 0x0017, KEY_PLAYPAUSE },
626 { 0x0816, KEY_PLAYPAUSE },
627 { 0x000b, KEY_STOP },
628 { 0x0827, KEY_FASTFORWARD },
629 { 0x0026, KEY_REWIND },
630 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
631 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
632 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
633 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
634 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
635 { 0x0025, KEY_POWER },
638 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
640 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
641 static u8 reset [] = { RESET, 0x80 };
642 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
643 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
644 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
645 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
647 mt352_write(fe, clock_config, sizeof(clock_config));
649 mt352_write(fe, reset, sizeof(reset));
650 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
652 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
653 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
654 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
659 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
660 { /* used in both lgz201 and th7579 */
661 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
662 static u8 reset [] = { RESET, 0x80 };
663 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
664 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
665 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
666 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
668 mt352_write(fe, clock_config, sizeof(clock_config));
670 mt352_write(fe, reset, sizeof(reset));
671 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
673 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
674 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
675 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
679 static struct cx22702_config cxusb_cx22702_config = {
680 .demod_address = 0x63,
681 .output_mode = CX22702_PARALLEL_OUTPUT,
684 static struct lgdt330x_config cxusb_lgdt3303_config = {
685 .demod_address = 0x0e,
686 .demod_chip = LGDT3303,
689 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
690 .demod_address = 0x0e,
691 .demod_chip = LGDT3303,
692 .clock_polarity_flip = 2,
695 static struct mt352_config cxusb_dee1601_config = {
696 .demod_address = 0x0f,
697 .demod_init = cxusb_dee1601_demod_init,
700 static struct zl10353_config cxusb_zl10353_dee1601_config = {
701 .demod_address = 0x0f,
705 static struct mt352_config cxusb_mt352_config = {
706 /* used in both lgz201 and th7579 */
707 .demod_address = 0x0f,
708 .demod_init = cxusb_mt352_demod_init,
711 static struct zl10353_config cxusb_zl10353_xc3028_config = {
712 .demod_address = 0x0f,
718 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
719 .demod_address = 0x0f,
723 .disable_i2c_gate_ctrl = 1,
726 static struct mt352_config cxusb_mt352_xc3028_config = {
727 .demod_address = 0x0f,
730 .demod_init = cxusb_mt352_demod_init,
733 /* FIXME: needs tweaking */
734 static struct mxl5005s_config aver_a868r_tuner = {
736 .if_freq = 6000000UL,
737 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
738 .agc_mode = MXL_SINGLE_AGC,
739 .tracking_filter = MXL_TF_C,
740 .rssi_enable = MXL_RSSI_ENABLE,
741 .cap_select = MXL_CAP_SEL_ENABLE,
742 .div_out = MXL_DIV_OUT_4,
743 .clock_out = MXL_CLOCK_OUT_DISABLE,
744 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
745 .top = MXL5005S_TOP_25P2,
746 .mod_mode = MXL_DIGITAL_MODE,
747 .if_mode = MXL_ZERO_IF,
748 .AgcMasterByte = 0x00,
751 /* FIXME: needs tweaking */
752 static struct mxl5005s_config d680_dmb_tuner = {
754 .if_freq = 36125000UL,
755 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
756 .agc_mode = MXL_SINGLE_AGC,
757 .tracking_filter = MXL_TF_C,
758 .rssi_enable = MXL_RSSI_ENABLE,
759 .cap_select = MXL_CAP_SEL_ENABLE,
760 .div_out = MXL_DIV_OUT_4,
761 .clock_out = MXL_CLOCK_OUT_DISABLE,
762 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
763 .top = MXL5005S_TOP_25P2,
764 .mod_mode = MXL_DIGITAL_MODE,
765 .if_mode = MXL_ZERO_IF,
766 .AgcMasterByte = 0x00,
769 static struct max2165_config mygica_d689_max2165_cfg = {
774 /* Callbacks for DVB USB */
775 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
777 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
778 &adap->dev->i2c_adap, 0x61,
779 TUNER_PHILIPS_FMD1216ME_MK3);
783 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
785 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61,
786 NULL, DVB_PLL_THOMSON_DTT7579);
790 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
792 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201);
796 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
798 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
799 NULL, DVB_PLL_THOMSON_DTT7579);
803 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
805 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
806 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
810 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
811 int command, int arg)
813 struct dvb_usb_adapter *adap = ptr;
814 struct dvb_usb_device *d = adap->dev;
817 case XC2028_TUNER_RESET:
818 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
819 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
821 case XC2028_RESET_CLK:
822 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
824 case XC2028_I2C_FLUSH:
827 deb_info("%s: unknown command %d, arg %d\n", __func__,
835 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
837 struct dvb_frontend *fe;
838 struct xc2028_config cfg = {
839 .i2c_adap = &adap->dev->i2c_adap,
842 static struct xc2028_ctrl ctl = {
843 .fname = "/*(DEBLOBBED)*/",
845 .demod = XC3028_FE_ZARLINK456,
848 /* FIXME: generalize & move to common area */
849 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback;
851 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg);
852 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
855 fe->ops.tuner_ops.set_config(fe, &ctl);
860 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
862 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
863 &adap->dev->i2c_adap, &aver_a868r_tuner);
867 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
869 struct dvb_frontend *fe;
870 fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
871 &adap->dev->i2c_adap, &d680_dmb_tuner);
872 return (fe == NULL) ? -EIO : 0;
875 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
877 struct dvb_frontend *fe;
878 fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe,
879 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
880 return (fe == NULL) ? -EIO : 0;
883 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
886 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
887 err("set interface failed");
889 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
891 adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
892 &adap->dev->i2c_adap);
893 if ((adap->fe_adap[0].fe) != NULL)
899 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
901 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
902 err("set interface failed");
904 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
906 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
907 &cxusb_lgdt3303_config,
908 &adap->dev->i2c_adap);
909 if ((adap->fe_adap[0].fe) != NULL)
915 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
917 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
918 &adap->dev->i2c_adap);
919 if (adap->fe_adap[0].fe != NULL)
925 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
927 /* used in both lgz201 and th7579 */
928 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
929 err("set interface failed");
931 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
933 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
934 &adap->dev->i2c_adap);
935 if ((adap->fe_adap[0].fe) != NULL)
941 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
943 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
944 err("set interface failed");
946 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
948 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
949 &adap->dev->i2c_adap);
950 if ((adap->fe_adap[0].fe) != NULL)
953 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
954 &cxusb_zl10353_dee1601_config,
955 &adap->dev->i2c_adap);
956 if ((adap->fe_adap[0].fe) != NULL)
962 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
966 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
967 .buf = ircode, .len = 4 };
969 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
970 err("set interface failed");
972 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
974 /* reset the tuner and demodulator */
975 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
976 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
977 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
979 adap->fe_adap[0].fe =
980 dvb_attach(zl10353_attach,
981 &cxusb_zl10353_xc3028_config_no_i2c_gate,
982 &adap->dev->i2c_adap);
983 if ((adap->fe_adap[0].fe) == NULL)
986 /* try to determine if there is no IR decoder on the I2C bus */
987 for (i = 0; adap->dev->props.rc.legacy.rc_map_table != NULL && i < 5; i++) {
989 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
991 if (ircode[0] == 0 && ircode[1] == 0)
993 if (ircode[2] + ircode[3] != 0xff) {
995 adap->dev->props.rc.legacy.rc_map_table = NULL;
996 info("No IR receiver detected on this device.");
1004 static struct dibx000_agc_config dib7070_agc_config = {
1005 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1008 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1009 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1010 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1012 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1013 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1015 .time_stabiliz = 10,
1039 .perform_agc_softsplit = 0,
1042 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1052 .IO_CLK_en_core = 1,
1055 /* refsel, sel, freq_15k */
1056 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1057 .ifreq = (0 << 25) | 0,
1059 .xtal_hz = 12000000,
1062 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
1063 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
1064 .output_mpeg2_in_188_bytes = 1,
1066 .agc_config_count = 1,
1067 .agc = &dib7070_agc_config,
1068 .bw = &dib7070_bw_config_12_mhz,
1069 .tuner_is_baseband = 1,
1075 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1077 .hostbus_diversity = 1,
1080 struct dib0700_adapter_state {
1081 int (*set_param_save)(struct dvb_frontend *);
1082 struct dib7000p_ops dib7000p_ops;
1085 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
1087 struct dib0700_adapter_state *state = adap->priv;
1089 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1090 err("set interface failed");
1092 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1094 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1096 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1099 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1100 &cxusb_dualdig4_rev2_config) < 0) {
1101 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1105 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
1106 &cxusb_dualdig4_rev2_config);
1107 if (adap->fe_adap[0].fe == NULL)
1113 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
1115 struct dvb_usb_adapter *adap = fe->dvb->priv;
1116 struct dib0700_adapter_state *state = adap->priv;
1118 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
1121 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1126 static struct dib0070_config dib7070p_dib0070_config = {
1127 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1128 .reset = dib7070_tuner_reset,
1129 .sleep = dib7070_tuner_sleep,
1133 static int dib7070_set_param_override(struct dvb_frontend *fe)
1135 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1136 struct dvb_usb_adapter *adap = fe->dvb->priv;
1137 struct dib0700_adapter_state *state = adap->priv;
1140 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
1142 case BAND_VHF: offset = 950; break;
1144 case BAND_UHF: offset = 550; break;
1147 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1149 return state->set_param_save(fe);
1152 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1154 struct dib0700_adapter_state *st = adap->priv;
1155 struct i2c_adapter *tun_i2c;
1158 * No need to call dvb7000p_attach here, as it was called
1159 * already, as frontend_attach method is called first, and
1160 * tuner_attach is only called on sucess.
1162 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
1163 DIBX000_I2C_INTERFACE_TUNER, 1);
1165 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1166 &dib7070p_dib0070_config) == NULL)
1169 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1170 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1174 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1176 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1177 err("set interface failed");
1179 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1181 /* reset the tuner and demodulator */
1182 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1183 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1184 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1186 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
1187 &cxusb_zl10353_xc3028_config,
1188 &adap->dev->i2c_adap);
1189 if ((adap->fe_adap[0].fe) != NULL)
1192 adap->fe_adap[0].fe = dvb_attach(mt352_attach,
1193 &cxusb_mt352_xc3028_config,
1194 &adap->dev->i2c_adap);
1195 if ((adap->fe_adap[0].fe) != NULL)
1201 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1202 .prod = LGS8GXX_PROD_LGS8GL5,
1203 .demod_address = 0x19,
1207 .if_clk_freq = 30400, /* 30.4 MHz */
1208 .if_freq = 5725, /* 5.725 MHz */
1215 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1217 struct dvb_usb_device *d = adap->dev;
1220 /* Select required USB configuration */
1221 if (usb_set_interface(d->udev, 0, 0) < 0)
1222 err("set interface failed");
1224 /* Unblock all USB pipes */
1225 usb_clear_halt(d->udev,
1226 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1227 usb_clear_halt(d->udev,
1228 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1229 usb_clear_halt(d->udev,
1230 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1232 /* Drain USB pipes to avoid hang after reboot */
1233 for (n = 0; n < 5; n++) {
1234 cxusb_d680_dmb_drain_message(d);
1235 cxusb_d680_dmb_drain_video(d);
1239 /* Reset the tuner */
1240 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1241 err("clear tuner gpio failed");
1245 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1246 err("set tuner gpio failed");
1251 /* Attach frontend */
1252 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1253 if (adap->fe_adap[0].fe == NULL)
1259 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1260 .prod = ATBM8830_PROD_8830,
1261 .demod_address = 0x40,
1263 .ts_sampling_edge = 1,
1265 .osc_clk_freq = 30400, /* in kHz */
1266 .if_freq = 0, /* zero IF */
1273 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1275 struct dvb_usb_device *d = adap->dev;
1277 /* Select required USB configuration */
1278 if (usb_set_interface(d->udev, 0, 0) < 0)
1279 err("set interface failed");
1281 /* Unblock all USB pipes */
1282 usb_clear_halt(d->udev,
1283 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1284 usb_clear_halt(d->udev,
1285 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1286 usb_clear_halt(d->udev,
1287 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1290 /* Reset the tuner */
1291 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1292 err("clear tuner gpio failed");
1296 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1297 err("set tuner gpio failed");
1302 /* Attach frontend */
1303 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1305 if (adap->fe_adap[0].fe == NULL)
1311 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
1313 struct dvb_usb_device *d = adap->dev;
1314 struct cxusb_state *st = d->priv;
1315 struct i2c_adapter *adapter;
1316 struct i2c_client *client_demod;
1317 struct i2c_client *client_tuner;
1318 struct i2c_board_info info;
1319 struct si2168_config si2168_config;
1320 struct si2157_config si2157_config;
1322 /* Select required USB configuration */
1323 if (usb_set_interface(d->udev, 0, 0) < 0)
1324 err("set interface failed");
1326 /* Unblock all USB pipes */
1327 usb_clear_halt(d->udev,
1328 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1329 usb_clear_halt(d->udev,
1330 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1331 usb_clear_halt(d->udev,
1332 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1334 /* attach frontend */
1335 si2168_config.i2c_adapter = &adapter;
1336 si2168_config.fe = &adap->fe_adap[0].fe;
1337 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1338 si2168_config.ts_clock_inv = 1;
1339 memset(&info, 0, sizeof(struct i2c_board_info));
1340 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1342 info.platform_data = &si2168_config;
1343 request_module(info.type);
1344 client_demod = i2c_new_device(&d->i2c_adap, &info);
1345 if (client_demod == NULL || client_demod->dev.driver == NULL)
1348 if (!try_module_get(client_demod->dev.driver->owner)) {
1349 i2c_unregister_device(client_demod);
1353 st->i2c_client_demod = client_demod;
1356 memset(&si2157_config, 0, sizeof(si2157_config));
1357 si2157_config.fe = adap->fe_adap[0].fe;
1358 si2157_config.if_port = 1;
1359 memset(&info, 0, sizeof(struct i2c_board_info));
1360 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1362 info.platform_data = &si2157_config;
1363 request_module(info.type);
1364 client_tuner = i2c_new_device(adapter, &info);
1365 if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1366 module_put(client_demod->dev.driver->owner);
1367 i2c_unregister_device(client_demod);
1370 if (!try_module_get(client_tuner->dev.driver->owner)) {
1371 i2c_unregister_device(client_tuner);
1372 module_put(client_demod->dev.driver->owner);
1373 i2c_unregister_device(client_demod);
1377 st->i2c_client_tuner = client_tuner;
1383 * DViCO has shipped two devices with the same USB ID, but only one of them
1384 * needs a firmware download. Check the device class details to see if they
1385 * have non-default values to decide whether the device is actually cold or
1386 * not, and forget a match if it turns out we selected the wrong device.
1388 static int bluebird_fx2_identify_state(struct usb_device *udev,
1389 struct dvb_usb_device_properties *props,
1390 struct dvb_usb_device_description **desc,
1393 int wascold = *cold;
1395 *cold = udev->descriptor.bDeviceClass == 0xff &&
1396 udev->descriptor.bDeviceSubClass == 0xff &&
1397 udev->descriptor.bDeviceProtocol == 0xff;
1399 if (*cold && !wascold)
1406 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1407 * firmware file before download.
1410 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
1411 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1412 const struct firmware *fw)
1416 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1417 int idoff = dvico_firmware_id_offsets[pos];
1419 if (fw->size < idoff + 4)
1422 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1423 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1424 struct firmware new_fw;
1425 u8 *new_fw_data = vmalloc(fw->size);
1431 memcpy(new_fw_data, fw->data, fw->size);
1432 new_fw.size = fw->size;
1433 new_fw.data = new_fw_data;
1435 new_fw_data[idoff + 2] =
1436 le16_to_cpu(udev->descriptor.idProduct) + 1;
1437 new_fw_data[idoff + 3] =
1438 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1440 ret = usb_cypress_load_firmware(udev, &new_fw,
1450 /* DVB USB Driver stuff */
1451 static struct dvb_usb_device_properties cxusb_medion_properties;
1452 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1453 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1454 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1455 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1456 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1457 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1458 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1459 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1460 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1461 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1462 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1463 static struct dvb_usb_device_properties cxusb_mygica_t230_properties;
1465 static int cxusb_probe(struct usb_interface *intf,
1466 const struct usb_device_id *id)
1468 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1469 THIS_MODULE, NULL, adapter_nr) ||
1470 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1471 THIS_MODULE, NULL, adapter_nr) ||
1472 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1473 THIS_MODULE, NULL, adapter_nr) ||
1474 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1475 THIS_MODULE, NULL, adapter_nr) ||
1476 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1477 THIS_MODULE, NULL, adapter_nr) ||
1478 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1479 THIS_MODULE, NULL, adapter_nr) ||
1480 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1481 THIS_MODULE, NULL, adapter_nr) ||
1482 0 == dvb_usb_device_init(intf,
1483 &cxusb_bluebird_nano2_needsfirmware_properties,
1484 THIS_MODULE, NULL, adapter_nr) ||
1485 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1486 THIS_MODULE, NULL, adapter_nr) ||
1487 0 == dvb_usb_device_init(intf,
1488 &cxusb_bluebird_dualdig4_rev2_properties,
1489 THIS_MODULE, NULL, adapter_nr) ||
1490 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1491 THIS_MODULE, NULL, adapter_nr) ||
1492 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1493 THIS_MODULE, NULL, adapter_nr) ||
1494 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties,
1495 THIS_MODULE, NULL, adapter_nr) ||
1502 static void cxusb_disconnect(struct usb_interface *intf)
1504 struct dvb_usb_device *d = usb_get_intfdata(intf);
1505 struct cxusb_state *st = d->priv;
1506 struct i2c_client *client;
1508 /* remove I2C client for tuner */
1509 client = st->i2c_client_tuner;
1511 module_put(client->dev.driver->owner);
1512 i2c_unregister_device(client);
1515 /* remove I2C client for demodulator */
1516 client = st->i2c_client_demod;
1518 module_put(client->dev.driver->owner);
1519 i2c_unregister_device(client);
1522 dvb_usb_device_exit(intf);
1525 enum cxusb_table_index {
1527 DVICO_BLUEBIRD_LG064F_COLD,
1528 DVICO_BLUEBIRD_LG064F_WARM,
1529 DVICO_BLUEBIRD_DUAL_1_COLD,
1530 DVICO_BLUEBIRD_DUAL_1_WARM,
1531 DVICO_BLUEBIRD_LGZ201_COLD,
1532 DVICO_BLUEBIRD_LGZ201_WARM,
1533 DVICO_BLUEBIRD_TH7579_COLD,
1534 DVICO_BLUEBIRD_TH7579_WARM,
1535 DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
1536 DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
1537 DVICO_BLUEBIRD_DUAL_2_COLD,
1538 DVICO_BLUEBIRD_DUAL_2_WARM,
1539 DVICO_BLUEBIRD_DUAL_4,
1540 DVICO_BLUEBIRD_DVB_T_NANO_2,
1541 DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
1542 AVERMEDIA_VOLAR_A868R,
1543 DVICO_BLUEBIRD_DUAL_4_REV_2,
1547 NR__cxusb_table_index
1550 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
1551 [MEDION_MD95700] = {
1552 USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700)
1554 [DVICO_BLUEBIRD_LG064F_COLD] = {
1555 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD)
1557 [DVICO_BLUEBIRD_LG064F_WARM] = {
1558 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM)
1560 [DVICO_BLUEBIRD_DUAL_1_COLD] = {
1561 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD)
1563 [DVICO_BLUEBIRD_DUAL_1_WARM] = {
1564 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM)
1566 [DVICO_BLUEBIRD_LGZ201_COLD] = {
1567 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD)
1569 [DVICO_BLUEBIRD_LGZ201_WARM] = {
1570 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM)
1572 [DVICO_BLUEBIRD_TH7579_COLD] = {
1573 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD)
1575 [DVICO_BLUEBIRD_TH7579_WARM] = {
1576 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM)
1578 [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = {
1579 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD)
1581 [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = {
1582 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM)
1584 [DVICO_BLUEBIRD_DUAL_2_COLD] = {
1585 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD)
1587 [DVICO_BLUEBIRD_DUAL_2_WARM] = {
1588 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM)
1590 [DVICO_BLUEBIRD_DUAL_4] = {
1591 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4)
1593 [DVICO_BLUEBIRD_DVB_T_NANO_2] = {
1594 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2)
1596 [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {
1597 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM)
1599 [AVERMEDIA_VOLAR_A868R] = {
1600 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R)
1602 [DVICO_BLUEBIRD_DUAL_4_REV_2] = {
1603 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2)
1605 [CONEXANT_D680_DMB] = {
1606 USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB)
1609 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689)
1612 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230)
1614 {} /* Terminating entry */
1616 MODULE_DEVICE_TABLE (usb, cxusb_table);
1618 static struct dvb_usb_device_properties cxusb_medion_properties = {
1619 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1621 .usb_ctrl = CYPRESS_FX2,
1623 .size_of_priv = sizeof(struct cxusb_state),
1630 .streaming_ctrl = cxusb_streaming_ctrl,
1631 .frontend_attach = cxusb_cx22702_frontend_attach,
1632 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1633 /* parameter for the MPEG2-data transfer */
1647 .power_ctrl = cxusb_power_ctrl,
1649 .i2c_algo = &cxusb_i2c_algo,
1651 .generic_bulk_ctrl_endpoint = 0x01,
1653 .num_device_descs = 1,
1655 { "Medion MD95700 (MDUSBTV-HYBRID)",
1657 { &cxusb_table[MEDION_MD95700], NULL },
1662 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1663 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1665 .usb_ctrl = DEVICE_SPECIFIC,
1666 .firmware = "/*(DEBLOBBED)*/",
1667 .download_firmware = bluebird_patch_dvico_firmware_download,
1668 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1669 use usb alt setting 7 for EP2 transfer (atsc) */
1671 .size_of_priv = sizeof(struct cxusb_state),
1678 .streaming_ctrl = cxusb_streaming_ctrl,
1679 .frontend_attach = cxusb_lgdt3303_frontend_attach,
1680 .tuner_attach = cxusb_lgh064f_tuner_attach,
1682 /* parameter for the MPEG2-data transfer */
1697 .power_ctrl = cxusb_bluebird_power_ctrl,
1699 .i2c_algo = &cxusb_i2c_algo,
1703 .rc_map_table = rc_map_dvico_portable_table,
1704 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1705 .rc_query = cxusb_rc_query,
1708 .generic_bulk_ctrl_endpoint = 0x01,
1710 .num_device_descs = 1,
1712 { "DViCO FusionHDTV5 USB Gold",
1713 { &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL },
1714 { &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL },
1719 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1720 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1722 .usb_ctrl = DEVICE_SPECIFIC,
1723 .firmware = "/*(DEBLOBBED)*/",
1724 .download_firmware = bluebird_patch_dvico_firmware_download,
1725 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1726 use usb alt setting 7 for EP2 transfer (atsc) */
1728 .size_of_priv = sizeof(struct cxusb_state),
1735 .streaming_ctrl = cxusb_streaming_ctrl,
1736 .frontend_attach = cxusb_dee1601_frontend_attach,
1737 .tuner_attach = cxusb_dee1601_tuner_attach,
1738 /* parameter for the MPEG2-data transfer */
1753 .power_ctrl = cxusb_bluebird_power_ctrl,
1755 .i2c_algo = &cxusb_i2c_algo,
1759 .rc_map_table = rc_map_dvico_mce_table,
1760 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
1761 .rc_query = cxusb_rc_query,
1764 .generic_bulk_ctrl_endpoint = 0x01,
1766 .num_device_descs = 3,
1768 { "DViCO FusionHDTV DVB-T Dual USB",
1769 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL },
1770 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL },
1772 { "DigitalNow DVB-T Dual USB",
1773 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD], NULL },
1774 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL },
1776 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1777 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL },
1778 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL },
1783 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1784 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1786 .usb_ctrl = DEVICE_SPECIFIC,
1787 .firmware = "/*(DEBLOBBED)*/",
1788 .download_firmware = bluebird_patch_dvico_firmware_download,
1789 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1790 use usb alt setting 7 for EP2 transfer (atsc) */
1792 .size_of_priv = sizeof(struct cxusb_state),
1799 .streaming_ctrl = cxusb_streaming_ctrl,
1800 .frontend_attach = cxusb_mt352_frontend_attach,
1801 .tuner_attach = cxusb_lgz201_tuner_attach,
1803 /* parameter for the MPEG2-data transfer */
1817 .power_ctrl = cxusb_bluebird_power_ctrl,
1819 .i2c_algo = &cxusb_i2c_algo,
1823 .rc_map_table = rc_map_dvico_portable_table,
1824 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1825 .rc_query = cxusb_rc_query,
1828 .generic_bulk_ctrl_endpoint = 0x01,
1829 .num_device_descs = 1,
1831 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1832 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL },
1833 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL },
1838 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1839 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1841 .usb_ctrl = DEVICE_SPECIFIC,
1842 .firmware = "/*(DEBLOBBED)*/",
1843 .download_firmware = bluebird_patch_dvico_firmware_download,
1844 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1845 use usb alt setting 7 for EP2 transfer (atsc) */
1847 .size_of_priv = sizeof(struct cxusb_state),
1854 .streaming_ctrl = cxusb_streaming_ctrl,
1855 .frontend_attach = cxusb_mt352_frontend_attach,
1856 .tuner_attach = cxusb_dtt7579_tuner_attach,
1858 /* parameter for the MPEG2-data transfer */
1872 .power_ctrl = cxusb_bluebird_power_ctrl,
1874 .i2c_algo = &cxusb_i2c_algo,
1878 .rc_map_table = rc_map_dvico_portable_table,
1879 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1880 .rc_query = cxusb_rc_query,
1883 .generic_bulk_ctrl_endpoint = 0x01,
1885 .num_device_descs = 1,
1887 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1888 { &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL },
1889 { &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL },
1894 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1895 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1897 .usb_ctrl = CYPRESS_FX2,
1899 .size_of_priv = sizeof(struct cxusb_state),
1906 .streaming_ctrl = cxusb_streaming_ctrl,
1907 .frontend_attach = cxusb_dualdig4_frontend_attach,
1908 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1909 /* parameter for the MPEG2-data transfer */
1924 .power_ctrl = cxusb_power_ctrl,
1926 .i2c_algo = &cxusb_i2c_algo,
1928 .generic_bulk_ctrl_endpoint = 0x01,
1932 .rc_map_table = rc_map_dvico_mce_table,
1933 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
1934 .rc_query = cxusb_bluebird2_rc_query,
1937 .num_device_descs = 1,
1939 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1941 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL },
1946 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1947 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1949 .usb_ctrl = CYPRESS_FX2,
1950 .identify_state = bluebird_fx2_identify_state,
1952 .size_of_priv = sizeof(struct cxusb_state),
1959 .streaming_ctrl = cxusb_streaming_ctrl,
1960 .frontend_attach = cxusb_nano2_frontend_attach,
1961 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1962 /* parameter for the MPEG2-data transfer */
1977 .power_ctrl = cxusb_nano2_power_ctrl,
1979 .i2c_algo = &cxusb_i2c_algo,
1981 .generic_bulk_ctrl_endpoint = 0x01,
1985 .rc_map_table = rc_map_dvico_portable_table,
1986 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1987 .rc_query = cxusb_bluebird2_rc_query,
1990 .num_device_descs = 1,
1992 { "DViCO FusionHDTV DVB-T NANO2",
1994 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
1999 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
2000 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2002 .usb_ctrl = DEVICE_SPECIFIC,
2003 .firmware = "/*(DEBLOBBED)*/",
2004 .download_firmware = bluebird_patch_dvico_firmware_download,
2005 .identify_state = bluebird_fx2_identify_state,
2007 .size_of_priv = sizeof(struct cxusb_state),
2014 .streaming_ctrl = cxusb_streaming_ctrl,
2015 .frontend_attach = cxusb_nano2_frontend_attach,
2016 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
2017 /* parameter for the MPEG2-data transfer */
2032 .power_ctrl = cxusb_nano2_power_ctrl,
2034 .i2c_algo = &cxusb_i2c_algo,
2036 .generic_bulk_ctrl_endpoint = 0x01,
2040 .rc_map_table = rc_map_dvico_portable_table,
2041 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
2042 .rc_query = cxusb_rc_query,
2045 .num_device_descs = 1,
2047 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
2048 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
2049 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL },
2054 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
2055 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2057 .usb_ctrl = CYPRESS_FX2,
2059 .size_of_priv = sizeof(struct cxusb_state),
2066 .streaming_ctrl = cxusb_aver_streaming_ctrl,
2067 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
2068 .tuner_attach = cxusb_mxl5003s_tuner_attach,
2069 /* parameter for the MPEG2-data transfer */
2083 .power_ctrl = cxusb_aver_power_ctrl,
2085 .i2c_algo = &cxusb_i2c_algo,
2087 .generic_bulk_ctrl_endpoint = 0x01,
2089 .num_device_descs = 1,
2091 { "AVerMedia AVerTVHD Volar (A868R)",
2093 { &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL },
2099 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2100 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2102 .usb_ctrl = CYPRESS_FX2,
2104 .size_of_priv = sizeof(struct cxusb_state),
2109 .size_of_priv = sizeof(struct dib0700_adapter_state),
2112 .streaming_ctrl = cxusb_streaming_ctrl,
2113 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
2114 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
2115 /* parameter for the MPEG2-data transfer */
2130 .power_ctrl = cxusb_bluebird_power_ctrl,
2132 .i2c_algo = &cxusb_i2c_algo,
2134 .generic_bulk_ctrl_endpoint = 0x01,
2138 .rc_map_table = rc_map_dvico_mce_table,
2139 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
2140 .rc_query = cxusb_rc_query,
2143 .num_device_descs = 1,
2145 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
2147 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL },
2152 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2153 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2155 .usb_ctrl = CYPRESS_FX2,
2157 .size_of_priv = sizeof(struct cxusb_state),
2164 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2165 .frontend_attach = cxusb_d680_dmb_frontend_attach,
2166 .tuner_attach = cxusb_d680_dmb_tuner_attach,
2168 /* parameter for the MPEG2-data transfer */
2183 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2185 .i2c_algo = &cxusb_i2c_algo,
2187 .generic_bulk_ctrl_endpoint = 0x01,
2191 .rc_map_table = rc_map_d680_dmb_table,
2192 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2193 .rc_query = cxusb_d680_dmb_rc_query,
2196 .num_device_descs = 1,
2199 "Conexant DMB-TH Stick",
2201 { &cxusb_table[CONEXANT_D680_DMB], NULL },
2206 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2207 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2209 .usb_ctrl = CYPRESS_FX2,
2211 .size_of_priv = sizeof(struct cxusb_state),
2218 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2219 .frontend_attach = cxusb_mygica_d689_frontend_attach,
2220 .tuner_attach = cxusb_mygica_d689_tuner_attach,
2222 /* parameter for the MPEG2-data transfer */
2237 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2239 .i2c_algo = &cxusb_i2c_algo,
2241 .generic_bulk_ctrl_endpoint = 0x01,
2245 .rc_map_table = rc_map_d680_dmb_table,
2246 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2247 .rc_query = cxusb_d680_dmb_rc_query,
2250 .num_device_descs = 1,
2253 "Mygica D689 DMB-TH",
2255 { &cxusb_table[MYGICA_D689], NULL },
2260 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2261 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2263 .usb_ctrl = CYPRESS_FX2,
2265 .size_of_priv = sizeof(struct cxusb_state),
2272 .streaming_ctrl = cxusb_streaming_ctrl,
2273 .frontend_attach = cxusb_mygica_t230_frontend_attach,
2275 /* parameter for the MPEG2-data transfer */
2290 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2292 .i2c_algo = &cxusb_i2c_algo,
2294 .generic_bulk_ctrl_endpoint = 0x01,
2298 .rc_map_table = rc_map_d680_dmb_table,
2299 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2300 .rc_query = cxusb_d680_dmb_rc_query,
2303 .num_device_descs = 1,
2306 "Mygica T230 DVB-T/T2/C",
2308 { &cxusb_table[MYGICA_T230], NULL },
2313 static struct usb_driver cxusb_driver = {
2314 .name = "dvb_usb_cxusb",
2315 .probe = cxusb_probe,
2316 .disconnect = cxusb_disconnect,
2317 .id_table = cxusb_table,
2320 module_usb_driver(cxusb_driver);
2322 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2323 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2324 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2325 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2326 MODULE_VERSION("1.0-alpha");
2327 MODULE_LICENSE("GPL");