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 wo = (rbuf == NULL || rlen == 0); /* write-only */
71 mutex_lock(&st->data_mutex);
73 memcpy(&st->data[1], wbuf, wlen);
75 ret = dvb_usb_generic_write(d, st->data, 1 + wlen);
77 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen,
80 mutex_unlock(&st->data_mutex);
85 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
87 struct cxusb_state *st = d->priv;
90 if (st->gpio_write_state[GPIO_TUNER] == onoff)
95 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
98 deb_info("gpio_write failed.\n");
100 st->gpio_write_state[GPIO_TUNER] = onoff;
103 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
109 o[0] = 0xff & ~changemask; /* mask of bits to keep */
110 o[1] = newval & changemask; /* new values for bits */
112 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
113 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
114 deb_info("bluebird_gpio_write failed.\n");
116 return rc < 0 ? rc : gpio_state;
119 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
121 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
123 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
126 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
128 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
131 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
134 u8 o[2] = {addr, onoff};
138 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
145 deb_info("gpio_write failed.\n");
151 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
154 struct dvb_usb_device *d = i2c_get_adapdata(adap);
158 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
161 for (i = 0; i < num; i++) {
163 if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_MEDION)
164 switch (msg[i].addr) {
166 cxusb_gpio_tuner(d, 0);
169 cxusb_gpio_tuner(d, 1);
173 if (msg[i].flags & I2C_M_RD) {
175 u8 obuf[3], ibuf[MAX_XFER_SIZE];
177 if (1 + msg[i].len > sizeof(ibuf)) {
178 warn("i2c rd: len=%d is too big!\n",
184 obuf[1] = msg[i].len;
185 obuf[2] = msg[i].addr;
186 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
188 ibuf, 1+msg[i].len) < 0) {
189 warn("i2c read failed");
192 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
193 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
194 msg[i].addr == msg[i+1].addr) {
195 /* write to then read from same address */
196 u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE];
198 if (3 + msg[i].len > sizeof(obuf)) {
199 warn("i2c wr: len=%d is too big!\n",
204 if (1 + msg[i + 1].len > sizeof(ibuf)) {
205 warn("i2c rd: len=%d is too big!\n",
210 obuf[0] = msg[i].len;
211 obuf[1] = msg[i+1].len;
212 obuf[2] = msg[i].addr;
213 memcpy(&obuf[3], msg[i].buf, msg[i].len);
215 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
217 ibuf, 1+msg[i+1].len) < 0)
221 deb_i2c("i2c read may have failed\n");
223 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
228 u8 obuf[MAX_XFER_SIZE], ibuf;
230 if (2 + msg[i].len > sizeof(obuf)) {
231 warn("i2c wr: len=%d is too big!\n",
236 obuf[0] = msg[i].addr;
237 obuf[1] = msg[i].len;
238 memcpy(&obuf[2], msg[i].buf, msg[i].len);
240 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
241 2+msg[i].len, &ibuf,1) < 0)
244 deb_i2c("i2c write may have failed\n");
254 mutex_unlock(&d->i2c_mutex);
258 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
263 static struct i2c_algorithm cxusb_i2c_algo = {
264 .master_xfer = cxusb_i2c_xfer,
265 .functionality = cxusb_i2c_func,
268 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
272 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
274 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
277 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
281 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
282 if (d->state == DVB_USB_STATE_INIT &&
283 usb_set_interface(d->udev, 0, 0) < 0)
284 err("set interface failed");
285 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
286 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
287 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
289 /* FIXME: We don't know why, but we need to configure the
290 * lgdt3303 with the register settings below on resume */
293 0x0e, 0x2, 0x00, 0x7f,
294 0x0e, 0x2, 0x02, 0xfe,
295 0x0e, 0x2, 0x02, 0x01,
296 0x0e, 0x2, 0x00, 0x03,
297 0x0e, 0x2, 0x0d, 0x40,
298 0x0e, 0x2, 0x0e, 0x87,
299 0x0e, 0x2, 0x0f, 0x8e,
300 0x0e, 0x2, 0x10, 0x01,
301 0x0e, 0x2, 0x14, 0xd7,
302 0x0e, 0x2, 0x47, 0x88,
305 for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
306 ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
317 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
321 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
326 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
330 rc = cxusb_power_ctrl(d, onoff);
332 cxusb_nano2_led(d, 0);
337 static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
341 ret = cxusb_power_ctrl(d, onoff);
346 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
351 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
353 u8 buf[2] = { 0x03, 0x00 };
355 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
357 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
362 static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
365 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
367 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
372 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
374 int ep = d->props.generic_bulk_ctrl_endpoint;
375 const int timeout = 100;
376 const int junk_len = 32;
380 /* Discard remaining data in video pipe */
381 junk = kmalloc(junk_len, GFP_KERNEL);
385 if (usb_bulk_msg(d->udev,
386 usb_rcvbulkpipe(d->udev, ep),
387 junk, junk_len, &rd_count, timeout) < 0)
395 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
397 struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream;
398 const int timeout = 100;
399 const int junk_len = p->u.bulk.buffersize;
403 /* Discard remaining data in video pipe */
404 junk = kmalloc(junk_len, GFP_KERNEL);
408 if (usb_bulk_msg(d->udev,
409 usb_rcvbulkpipe(d->udev, p->endpoint),
410 junk, junk_len, &rd_count, timeout) < 0)
418 static int cxusb_d680_dmb_streaming_ctrl(
419 struct dvb_usb_adapter *adap, int onoff)
422 u8 buf[2] = { 0x03, 0x00 };
423 cxusb_d680_dmb_drain_video(adap->dev);
424 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
425 buf, sizeof(buf), NULL, 0);
427 int ret = cxusb_ctrl_msg(adap->dev,
428 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
433 static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
435 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
439 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
442 *state = REMOTE_NO_KEY_PRESSED;
444 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
445 if (rc5_custom(&keymap[i]) == ircode[2] &&
446 rc5_data(&keymap[i]) == ircode[3]) {
447 *event = keymap[i].keycode;
448 *state = REMOTE_KEY_PRESSED;
457 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
460 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
463 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
464 .buf = ircode, .len = 4 };
467 *state = REMOTE_NO_KEY_PRESSED;
469 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
472 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
473 if (rc5_custom(&keymap[i]) == ircode[1] &&
474 rc5_data(&keymap[i]) == ircode[2]) {
475 *event = keymap[i].keycode;
476 *state = REMOTE_KEY_PRESSED;
485 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
488 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
493 *state = REMOTE_NO_KEY_PRESSED;
495 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
498 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
499 if (rc5_custom(&keymap[i]) == ircode[0] &&
500 rc5_data(&keymap[i]) == ircode[1]) {
501 *event = keymap[i].keycode;
502 *state = REMOTE_KEY_PRESSED;
511 static struct rc_map_table rc_map_dvico_mce_table[] = {
515 { 0xfe1e, KEY_FAVORITES },
516 { 0xfe16, KEY_SETUP },
517 { 0xfe46, KEY_POWER2 },
519 { 0xfe49, KEY_BACK },
520 { 0xfe4d, KEY_MENU },
522 { 0xfe5b, KEY_LEFT },
523 { 0xfe5f, KEY_RIGHT },
524 { 0xfe53, KEY_DOWN },
526 { 0xfe59, KEY_INFO },
528 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
529 { 0xfe12, KEY_NEXTSONG }, /* Skip */
530 { 0xfe42, KEY_ENTER }, /* Windows/Start */
531 { 0xfe15, KEY_VOLUMEUP },
532 { 0xfe05, KEY_VOLUMEDOWN },
533 { 0xfe11, KEY_CHANNELUP },
534 { 0xfe09, KEY_CHANNELDOWN },
535 { 0xfe52, KEY_CAMERA },
536 { 0xfe5a, KEY_TUNER }, /* Live */
537 { 0xfe19, KEY_OPEN },
547 { 0xfe13, KEY_ANGLE }, /* Aspect */
549 { 0xfe1f, KEY_ZOOM },
550 { 0xfe43, KEY_REWIND },
551 { 0xfe47, KEY_PLAYPAUSE },
552 { 0xfe4f, KEY_FASTFORWARD },
553 { 0xfe57, KEY_MUTE },
554 { 0xfe0d, KEY_STOP },
555 { 0xfe01, KEY_RECORD },
556 { 0xfe4e, KEY_POWER },
559 static struct rc_map_table rc_map_dvico_portable_table[] = {
560 { 0xfc02, KEY_SETUP }, /* Profile */
561 { 0xfc43, KEY_POWER2 },
563 { 0xfc5a, KEY_BACK },
564 { 0xfc05, KEY_MENU },
565 { 0xfc47, KEY_INFO },
567 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
568 { 0xfc49, KEY_VOLUMEUP },
569 { 0xfc09, KEY_VOLUMEDOWN },
570 { 0xfc54, KEY_CHANNELUP },
571 { 0xfc0b, KEY_CHANNELDOWN },
572 { 0xfc16, KEY_CAMERA },
573 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
574 { 0xfc45, KEY_OPEN },
584 { 0xfc44, KEY_ANGLE }, /* Aspect */
586 { 0xfc07, KEY_ZOOM },
587 { 0xfc0a, KEY_REWIND },
588 { 0xfc08, KEY_PLAYPAUSE },
589 { 0xfc4b, KEY_FASTFORWARD },
590 { 0xfc5b, KEY_MUTE },
591 { 0xfc04, KEY_STOP },
592 { 0xfc56, KEY_RECORD },
593 { 0xfc57, KEY_POWER },
594 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
595 { 0xfc00, KEY_UNKNOWN }, /* HD */
598 static struct rc_map_table rc_map_d680_dmb_table[] = {
599 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
600 { 0x080c, KEY_ZOOM },
611 { 0x000a, KEY_MUTE },
612 { 0x0829, KEY_BACK },
613 { 0x0012, KEY_CHANNELUP },
614 { 0x0813, KEY_CHANNELDOWN },
615 { 0x002b, KEY_VOLUMEUP },
616 { 0x082c, KEY_VOLUMEDOWN },
618 { 0x0821, KEY_DOWN },
619 { 0x0011, KEY_LEFT },
620 { 0x0810, KEY_RIGHT },
622 { 0x081f, KEY_RECORD },
623 { 0x0017, KEY_PLAYPAUSE },
624 { 0x0816, KEY_PLAYPAUSE },
625 { 0x000b, KEY_STOP },
626 { 0x0827, KEY_FASTFORWARD },
627 { 0x0026, KEY_REWIND },
628 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
629 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
630 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
631 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
632 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
633 { 0x0025, KEY_POWER },
636 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
638 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
639 static u8 reset [] = { RESET, 0x80 };
640 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
641 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
642 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
643 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
645 mt352_write(fe, clock_config, sizeof(clock_config));
647 mt352_write(fe, reset, sizeof(reset));
648 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
650 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
651 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
652 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
657 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
658 { /* used in both lgz201 and th7579 */
659 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
660 static u8 reset [] = { RESET, 0x80 };
661 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
662 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
663 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
664 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
666 mt352_write(fe, clock_config, sizeof(clock_config));
668 mt352_write(fe, reset, sizeof(reset));
669 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
671 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
672 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
673 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
677 static struct cx22702_config cxusb_cx22702_config = {
678 .demod_address = 0x63,
679 .output_mode = CX22702_PARALLEL_OUTPUT,
682 static struct lgdt330x_config cxusb_lgdt3303_config = {
683 .demod_address = 0x0e,
684 .demod_chip = LGDT3303,
687 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
688 .demod_address = 0x0e,
689 .demod_chip = LGDT3303,
690 .clock_polarity_flip = 2,
693 static struct mt352_config cxusb_dee1601_config = {
694 .demod_address = 0x0f,
695 .demod_init = cxusb_dee1601_demod_init,
698 static struct zl10353_config cxusb_zl10353_dee1601_config = {
699 .demod_address = 0x0f,
703 static struct mt352_config cxusb_mt352_config = {
704 /* used in both lgz201 and th7579 */
705 .demod_address = 0x0f,
706 .demod_init = cxusb_mt352_demod_init,
709 static struct zl10353_config cxusb_zl10353_xc3028_config = {
710 .demod_address = 0x0f,
716 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
717 .demod_address = 0x0f,
721 .disable_i2c_gate_ctrl = 1,
724 static struct mt352_config cxusb_mt352_xc3028_config = {
725 .demod_address = 0x0f,
728 .demod_init = cxusb_mt352_demod_init,
731 /* FIXME: needs tweaking */
732 static struct mxl5005s_config aver_a868r_tuner = {
734 .if_freq = 6000000UL,
735 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
736 .agc_mode = MXL_SINGLE_AGC,
737 .tracking_filter = MXL_TF_C,
738 .rssi_enable = MXL_RSSI_ENABLE,
739 .cap_select = MXL_CAP_SEL_ENABLE,
740 .div_out = MXL_DIV_OUT_4,
741 .clock_out = MXL_CLOCK_OUT_DISABLE,
742 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
743 .top = MXL5005S_TOP_25P2,
744 .mod_mode = MXL_DIGITAL_MODE,
745 .if_mode = MXL_ZERO_IF,
746 .AgcMasterByte = 0x00,
749 /* FIXME: needs tweaking */
750 static struct mxl5005s_config d680_dmb_tuner = {
752 .if_freq = 36125000UL,
753 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
754 .agc_mode = MXL_SINGLE_AGC,
755 .tracking_filter = MXL_TF_C,
756 .rssi_enable = MXL_RSSI_ENABLE,
757 .cap_select = MXL_CAP_SEL_ENABLE,
758 .div_out = MXL_DIV_OUT_4,
759 .clock_out = MXL_CLOCK_OUT_DISABLE,
760 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
761 .top = MXL5005S_TOP_25P2,
762 .mod_mode = MXL_DIGITAL_MODE,
763 .if_mode = MXL_ZERO_IF,
764 .AgcMasterByte = 0x00,
767 static struct max2165_config mygica_d689_max2165_cfg = {
772 /* Callbacks for DVB USB */
773 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
775 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
776 &adap->dev->i2c_adap, 0x61,
777 TUNER_PHILIPS_FMD1216ME_MK3);
781 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
783 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61,
784 NULL, DVB_PLL_THOMSON_DTT7579);
788 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
790 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201);
794 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
796 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
797 NULL, DVB_PLL_THOMSON_DTT7579);
801 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
803 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
804 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
808 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
809 int command, int arg)
811 struct dvb_usb_adapter *adap = ptr;
812 struct dvb_usb_device *d = adap->dev;
815 case XC2028_TUNER_RESET:
816 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
817 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
819 case XC2028_RESET_CLK:
820 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
823 deb_info("%s: unknown command %d, arg %d\n", __func__,
831 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
833 struct dvb_frontend *fe;
834 struct xc2028_config cfg = {
835 .i2c_adap = &adap->dev->i2c_adap,
838 static struct xc2028_ctrl ctl = {
839 .fname = XC2028_DEFAULT_FIRMWARE,
841 .demod = XC3028_FE_ZARLINK456,
844 /* FIXME: generalize & move to common area */
845 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback;
847 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg);
848 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
851 fe->ops.tuner_ops.set_config(fe, &ctl);
856 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
858 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
859 &adap->dev->i2c_adap, &aver_a868r_tuner);
863 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
865 struct dvb_frontend *fe;
866 fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
867 &adap->dev->i2c_adap, &d680_dmb_tuner);
868 return (fe == NULL) ? -EIO : 0;
871 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
873 struct dvb_frontend *fe;
874 fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe,
875 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
876 return (fe == NULL) ? -EIO : 0;
879 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
882 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
883 err("set interface failed");
885 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
887 adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
888 &adap->dev->i2c_adap);
889 if ((adap->fe_adap[0].fe) != NULL)
895 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
897 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
898 err("set interface failed");
900 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
902 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
903 &cxusb_lgdt3303_config,
904 &adap->dev->i2c_adap);
905 if ((adap->fe_adap[0].fe) != NULL)
911 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
913 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
914 &adap->dev->i2c_adap);
915 if (adap->fe_adap[0].fe != NULL)
921 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
923 /* used in both lgz201 and th7579 */
924 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
925 err("set interface failed");
927 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
929 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
930 &adap->dev->i2c_adap);
931 if ((adap->fe_adap[0].fe) != NULL)
937 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
939 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
940 err("set interface failed");
942 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
944 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
945 &adap->dev->i2c_adap);
946 if ((adap->fe_adap[0].fe) != NULL)
949 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
950 &cxusb_zl10353_dee1601_config,
951 &adap->dev->i2c_adap);
952 if ((adap->fe_adap[0].fe) != NULL)
958 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
962 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
963 .buf = ircode, .len = 4 };
965 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
966 err("set interface failed");
968 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
970 /* reset the tuner and demodulator */
971 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
972 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
973 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
975 adap->fe_adap[0].fe =
976 dvb_attach(zl10353_attach,
977 &cxusb_zl10353_xc3028_config_no_i2c_gate,
978 &adap->dev->i2c_adap);
979 if ((adap->fe_adap[0].fe) == NULL)
982 /* try to determine if there is no IR decoder on the I2C bus */
983 for (i = 0; adap->dev->props.rc.legacy.rc_map_table != NULL && i < 5; i++) {
985 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
987 if (ircode[0] == 0 && ircode[1] == 0)
989 if (ircode[2] + ircode[3] != 0xff) {
991 adap->dev->props.rc.legacy.rc_map_table = NULL;
992 info("No IR receiver detected on this device.");
1000 static struct dibx000_agc_config dib7070_agc_config = {
1001 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1004 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1005 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1006 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1008 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1009 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1011 .time_stabiliz = 10,
1035 .perform_agc_softsplit = 0,
1038 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1048 .IO_CLK_en_core = 1,
1051 /* refsel, sel, freq_15k */
1052 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1053 .ifreq = (0 << 25) | 0,
1055 .xtal_hz = 12000000,
1058 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
1059 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
1060 .output_mpeg2_in_188_bytes = 1,
1062 .agc_config_count = 1,
1063 .agc = &dib7070_agc_config,
1064 .bw = &dib7070_bw_config_12_mhz,
1065 .tuner_is_baseband = 1,
1071 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1073 .hostbus_diversity = 1,
1076 struct dib0700_adapter_state {
1077 int (*set_param_save)(struct dvb_frontend *);
1078 struct dib7000p_ops dib7000p_ops;
1081 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
1083 struct dib0700_adapter_state *state = adap->priv;
1085 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1086 err("set interface failed");
1088 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1090 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1092 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
1095 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1096 &cxusb_dualdig4_rev2_config) < 0) {
1097 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1101 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
1102 &cxusb_dualdig4_rev2_config);
1103 if (adap->fe_adap[0].fe == NULL)
1109 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
1111 struct dvb_usb_adapter *adap = fe->dvb->priv;
1112 struct dib0700_adapter_state *state = adap->priv;
1114 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
1117 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1122 static struct dib0070_config dib7070p_dib0070_config = {
1123 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1124 .reset = dib7070_tuner_reset,
1125 .sleep = dib7070_tuner_sleep,
1129 static int dib7070_set_param_override(struct dvb_frontend *fe)
1131 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1132 struct dvb_usb_adapter *adap = fe->dvb->priv;
1133 struct dib0700_adapter_state *state = adap->priv;
1136 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
1138 case BAND_VHF: offset = 950; break;
1140 case BAND_UHF: offset = 550; break;
1143 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1145 return state->set_param_save(fe);
1148 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1150 struct dib0700_adapter_state *st = adap->priv;
1151 struct i2c_adapter *tun_i2c;
1154 * No need to call dvb7000p_attach here, as it was called
1155 * already, as frontend_attach method is called first, and
1156 * tuner_attach is only called on sucess.
1158 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
1159 DIBX000_I2C_INTERFACE_TUNER, 1);
1161 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1162 &dib7070p_dib0070_config) == NULL)
1165 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1166 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1170 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1172 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1173 err("set interface failed");
1175 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1177 /* reset the tuner and demodulator */
1178 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1179 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1180 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1182 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
1183 &cxusb_zl10353_xc3028_config,
1184 &adap->dev->i2c_adap);
1185 if ((adap->fe_adap[0].fe) != NULL)
1188 adap->fe_adap[0].fe = dvb_attach(mt352_attach,
1189 &cxusb_mt352_xc3028_config,
1190 &adap->dev->i2c_adap);
1191 if ((adap->fe_adap[0].fe) != NULL)
1197 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1198 .prod = LGS8GXX_PROD_LGS8GL5,
1199 .demod_address = 0x19,
1203 .if_clk_freq = 30400, /* 30.4 MHz */
1204 .if_freq = 5725, /* 5.725 MHz */
1211 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1213 struct dvb_usb_device *d = adap->dev;
1216 /* Select required USB configuration */
1217 if (usb_set_interface(d->udev, 0, 0) < 0)
1218 err("set interface failed");
1220 /* Unblock all USB pipes */
1221 usb_clear_halt(d->udev,
1222 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1223 usb_clear_halt(d->udev,
1224 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1225 usb_clear_halt(d->udev,
1226 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1228 /* Drain USB pipes to avoid hang after reboot */
1229 for (n = 0; n < 5; n++) {
1230 cxusb_d680_dmb_drain_message(d);
1231 cxusb_d680_dmb_drain_video(d);
1235 /* Reset the tuner */
1236 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1237 err("clear tuner gpio failed");
1241 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1242 err("set tuner gpio failed");
1247 /* Attach frontend */
1248 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1249 if (adap->fe_adap[0].fe == NULL)
1255 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1256 .prod = ATBM8830_PROD_8830,
1257 .demod_address = 0x40,
1259 .ts_sampling_edge = 1,
1261 .osc_clk_freq = 30400, /* in kHz */
1262 .if_freq = 0, /* zero IF */
1269 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1271 struct dvb_usb_device *d = adap->dev;
1273 /* Select required USB configuration */
1274 if (usb_set_interface(d->udev, 0, 0) < 0)
1275 err("set interface failed");
1277 /* Unblock all USB pipes */
1278 usb_clear_halt(d->udev,
1279 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1280 usb_clear_halt(d->udev,
1281 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1282 usb_clear_halt(d->udev,
1283 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1286 /* Reset the tuner */
1287 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1288 err("clear tuner gpio failed");
1292 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1293 err("set tuner gpio failed");
1298 /* Attach frontend */
1299 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1301 if (adap->fe_adap[0].fe == NULL)
1307 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
1309 struct dvb_usb_device *d = adap->dev;
1310 struct cxusb_state *st = d->priv;
1311 struct i2c_adapter *adapter;
1312 struct i2c_client *client_demod;
1313 struct i2c_client *client_tuner;
1314 struct i2c_board_info info;
1315 struct si2168_config si2168_config;
1316 struct si2157_config si2157_config;
1318 /* Select required USB configuration */
1319 if (usb_set_interface(d->udev, 0, 0) < 0)
1320 err("set interface failed");
1322 /* Unblock all USB pipes */
1323 usb_clear_halt(d->udev,
1324 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1325 usb_clear_halt(d->udev,
1326 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1327 usb_clear_halt(d->udev,
1328 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1330 /* attach frontend */
1331 si2168_config.i2c_adapter = &adapter;
1332 si2168_config.fe = &adap->fe_adap[0].fe;
1333 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1334 si2168_config.ts_clock_inv = 1;
1335 memset(&info, 0, sizeof(struct i2c_board_info));
1336 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1338 info.platform_data = &si2168_config;
1339 request_module(info.type);
1340 client_demod = i2c_new_device(&d->i2c_adap, &info);
1341 if (client_demod == NULL || client_demod->dev.driver == NULL)
1344 if (!try_module_get(client_demod->dev.driver->owner)) {
1345 i2c_unregister_device(client_demod);
1349 st->i2c_client_demod = client_demod;
1352 memset(&si2157_config, 0, sizeof(si2157_config));
1353 si2157_config.fe = adap->fe_adap[0].fe;
1354 si2157_config.if_port = 1;
1355 memset(&info, 0, sizeof(struct i2c_board_info));
1356 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1358 info.platform_data = &si2157_config;
1359 request_module(info.type);
1360 client_tuner = i2c_new_device(adapter, &info);
1361 if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1362 module_put(client_demod->dev.driver->owner);
1363 i2c_unregister_device(client_demod);
1366 if (!try_module_get(client_tuner->dev.driver->owner)) {
1367 i2c_unregister_device(client_tuner);
1368 module_put(client_demod->dev.driver->owner);
1369 i2c_unregister_device(client_demod);
1373 st->i2c_client_tuner = client_tuner;
1379 * DViCO has shipped two devices with the same USB ID, but only one of them
1380 * needs a firmware download. Check the device class details to see if they
1381 * have non-default values to decide whether the device is actually cold or
1382 * not, and forget a match if it turns out we selected the wrong device.
1384 static int bluebird_fx2_identify_state(struct usb_device *udev,
1385 struct dvb_usb_device_properties *props,
1386 struct dvb_usb_device_description **desc,
1389 int wascold = *cold;
1391 *cold = udev->descriptor.bDeviceClass == 0xff &&
1392 udev->descriptor.bDeviceSubClass == 0xff &&
1393 udev->descriptor.bDeviceProtocol == 0xff;
1395 if (*cold && !wascold)
1402 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1403 * firmware file before download.
1406 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
1407 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1408 const struct firmware *fw)
1412 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1413 int idoff = dvico_firmware_id_offsets[pos];
1415 if (fw->size < idoff + 4)
1418 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1419 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1420 struct firmware new_fw;
1421 u8 *new_fw_data = vmalloc(fw->size);
1427 memcpy(new_fw_data, fw->data, fw->size);
1428 new_fw.size = fw->size;
1429 new_fw.data = new_fw_data;
1431 new_fw_data[idoff + 2] =
1432 le16_to_cpu(udev->descriptor.idProduct) + 1;
1433 new_fw_data[idoff + 3] =
1434 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1436 ret = usb_cypress_load_firmware(udev, &new_fw,
1446 /* DVB USB Driver stuff */
1447 static struct dvb_usb_device_properties cxusb_medion_properties;
1448 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1449 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1450 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1451 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1452 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1453 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1454 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1455 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1456 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1457 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1458 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1459 static struct dvb_usb_device_properties cxusb_mygica_t230_properties;
1461 static int cxusb_probe(struct usb_interface *intf,
1462 const struct usb_device_id *id)
1464 struct dvb_usb_device *d;
1465 struct cxusb_state *st;
1467 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1468 THIS_MODULE, &d, adapter_nr) ||
1469 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1470 THIS_MODULE, &d, adapter_nr) ||
1471 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1472 THIS_MODULE, &d, adapter_nr) ||
1473 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1474 THIS_MODULE, &d, adapter_nr) ||
1475 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1476 THIS_MODULE, &d, adapter_nr) ||
1477 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1478 THIS_MODULE, &d, adapter_nr) ||
1479 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1480 THIS_MODULE, &d, adapter_nr) ||
1481 0 == dvb_usb_device_init(intf,
1482 &cxusb_bluebird_nano2_needsfirmware_properties,
1483 THIS_MODULE, &d, adapter_nr) ||
1484 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1485 THIS_MODULE, &d, adapter_nr) ||
1486 0 == dvb_usb_device_init(intf,
1487 &cxusb_bluebird_dualdig4_rev2_properties,
1488 THIS_MODULE, &d, adapter_nr) ||
1489 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1490 THIS_MODULE, &d, adapter_nr) ||
1491 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1492 THIS_MODULE, &d, adapter_nr) ||
1493 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties,
1494 THIS_MODULE, &d, adapter_nr) ||
1497 mutex_init(&st->data_mutex);
1505 static void cxusb_disconnect(struct usb_interface *intf)
1507 struct dvb_usb_device *d = usb_get_intfdata(intf);
1508 struct cxusb_state *st = d->priv;
1509 struct i2c_client *client;
1511 /* remove I2C client for tuner */
1512 client = st->i2c_client_tuner;
1514 module_put(client->dev.driver->owner);
1515 i2c_unregister_device(client);
1518 /* remove I2C client for demodulator */
1519 client = st->i2c_client_demod;
1521 module_put(client->dev.driver->owner);
1522 i2c_unregister_device(client);
1525 dvb_usb_device_exit(intf);
1528 enum cxusb_table_index {
1530 DVICO_BLUEBIRD_LG064F_COLD,
1531 DVICO_BLUEBIRD_LG064F_WARM,
1532 DVICO_BLUEBIRD_DUAL_1_COLD,
1533 DVICO_BLUEBIRD_DUAL_1_WARM,
1534 DVICO_BLUEBIRD_LGZ201_COLD,
1535 DVICO_BLUEBIRD_LGZ201_WARM,
1536 DVICO_BLUEBIRD_TH7579_COLD,
1537 DVICO_BLUEBIRD_TH7579_WARM,
1538 DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
1539 DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
1540 DVICO_BLUEBIRD_DUAL_2_COLD,
1541 DVICO_BLUEBIRD_DUAL_2_WARM,
1542 DVICO_BLUEBIRD_DUAL_4,
1543 DVICO_BLUEBIRD_DVB_T_NANO_2,
1544 DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
1545 AVERMEDIA_VOLAR_A868R,
1546 DVICO_BLUEBIRD_DUAL_4_REV_2,
1550 NR__cxusb_table_index
1553 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
1554 [MEDION_MD95700] = {
1555 USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700)
1557 [DVICO_BLUEBIRD_LG064F_COLD] = {
1558 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD)
1560 [DVICO_BLUEBIRD_LG064F_WARM] = {
1561 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM)
1563 [DVICO_BLUEBIRD_DUAL_1_COLD] = {
1564 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD)
1566 [DVICO_BLUEBIRD_DUAL_1_WARM] = {
1567 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM)
1569 [DVICO_BLUEBIRD_LGZ201_COLD] = {
1570 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD)
1572 [DVICO_BLUEBIRD_LGZ201_WARM] = {
1573 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM)
1575 [DVICO_BLUEBIRD_TH7579_COLD] = {
1576 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD)
1578 [DVICO_BLUEBIRD_TH7579_WARM] = {
1579 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM)
1581 [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = {
1582 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD)
1584 [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = {
1585 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM)
1587 [DVICO_BLUEBIRD_DUAL_2_COLD] = {
1588 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD)
1590 [DVICO_BLUEBIRD_DUAL_2_WARM] = {
1591 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM)
1593 [DVICO_BLUEBIRD_DUAL_4] = {
1594 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4)
1596 [DVICO_BLUEBIRD_DVB_T_NANO_2] = {
1597 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2)
1599 [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {
1600 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM)
1602 [AVERMEDIA_VOLAR_A868R] = {
1603 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R)
1605 [DVICO_BLUEBIRD_DUAL_4_REV_2] = {
1606 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2)
1608 [CONEXANT_D680_DMB] = {
1609 USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB)
1612 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689)
1615 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230)
1617 {} /* Terminating entry */
1619 MODULE_DEVICE_TABLE (usb, cxusb_table);
1621 static struct dvb_usb_device_properties cxusb_medion_properties = {
1622 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1624 .usb_ctrl = CYPRESS_FX2,
1626 .size_of_priv = sizeof(struct cxusb_state),
1633 .streaming_ctrl = cxusb_streaming_ctrl,
1634 .frontend_attach = cxusb_cx22702_frontend_attach,
1635 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1636 /* parameter for the MPEG2-data transfer */
1650 .power_ctrl = cxusb_power_ctrl,
1652 .i2c_algo = &cxusb_i2c_algo,
1654 .generic_bulk_ctrl_endpoint = 0x01,
1656 .num_device_descs = 1,
1658 { "Medion MD95700 (MDUSBTV-HYBRID)",
1660 { &cxusb_table[MEDION_MD95700], NULL },
1665 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1666 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1668 .usb_ctrl = DEVICE_SPECIFIC,
1669 .firmware = "dvb-usb-bluebird-01.fw",
1670 .download_firmware = bluebird_patch_dvico_firmware_download,
1671 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1672 use usb alt setting 7 for EP2 transfer (atsc) */
1674 .size_of_priv = sizeof(struct cxusb_state),
1681 .streaming_ctrl = cxusb_streaming_ctrl,
1682 .frontend_attach = cxusb_lgdt3303_frontend_attach,
1683 .tuner_attach = cxusb_lgh064f_tuner_attach,
1685 /* parameter for the MPEG2-data transfer */
1700 .power_ctrl = cxusb_bluebird_power_ctrl,
1702 .i2c_algo = &cxusb_i2c_algo,
1706 .rc_map_table = rc_map_dvico_portable_table,
1707 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1708 .rc_query = cxusb_rc_query,
1711 .generic_bulk_ctrl_endpoint = 0x01,
1713 .num_device_descs = 1,
1715 { "DViCO FusionHDTV5 USB Gold",
1716 { &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL },
1717 { &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL },
1722 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1723 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1725 .usb_ctrl = DEVICE_SPECIFIC,
1726 .firmware = "dvb-usb-bluebird-01.fw",
1727 .download_firmware = bluebird_patch_dvico_firmware_download,
1728 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1729 use usb alt setting 7 for EP2 transfer (atsc) */
1731 .size_of_priv = sizeof(struct cxusb_state),
1738 .streaming_ctrl = cxusb_streaming_ctrl,
1739 .frontend_attach = cxusb_dee1601_frontend_attach,
1740 .tuner_attach = cxusb_dee1601_tuner_attach,
1741 /* parameter for the MPEG2-data transfer */
1756 .power_ctrl = cxusb_bluebird_power_ctrl,
1758 .i2c_algo = &cxusb_i2c_algo,
1762 .rc_map_table = rc_map_dvico_mce_table,
1763 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
1764 .rc_query = cxusb_rc_query,
1767 .generic_bulk_ctrl_endpoint = 0x01,
1769 .num_device_descs = 3,
1771 { "DViCO FusionHDTV DVB-T Dual USB",
1772 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL },
1773 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL },
1775 { "DigitalNow DVB-T Dual USB",
1776 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD], NULL },
1777 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL },
1779 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1780 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL },
1781 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL },
1786 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1787 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1789 .usb_ctrl = DEVICE_SPECIFIC,
1790 .firmware = "dvb-usb-bluebird-01.fw",
1791 .download_firmware = bluebird_patch_dvico_firmware_download,
1792 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1793 use usb alt setting 7 for EP2 transfer (atsc) */
1795 .size_of_priv = sizeof(struct cxusb_state),
1802 .streaming_ctrl = cxusb_streaming_ctrl,
1803 .frontend_attach = cxusb_mt352_frontend_attach,
1804 .tuner_attach = cxusb_lgz201_tuner_attach,
1806 /* parameter for the MPEG2-data transfer */
1820 .power_ctrl = cxusb_bluebird_power_ctrl,
1822 .i2c_algo = &cxusb_i2c_algo,
1826 .rc_map_table = rc_map_dvico_portable_table,
1827 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1828 .rc_query = cxusb_rc_query,
1831 .generic_bulk_ctrl_endpoint = 0x01,
1832 .num_device_descs = 1,
1834 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1835 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL },
1836 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL },
1841 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1842 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1844 .usb_ctrl = DEVICE_SPECIFIC,
1845 .firmware = "dvb-usb-bluebird-01.fw",
1846 .download_firmware = bluebird_patch_dvico_firmware_download,
1847 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1848 use usb alt setting 7 for EP2 transfer (atsc) */
1850 .size_of_priv = sizeof(struct cxusb_state),
1857 .streaming_ctrl = cxusb_streaming_ctrl,
1858 .frontend_attach = cxusb_mt352_frontend_attach,
1859 .tuner_attach = cxusb_dtt7579_tuner_attach,
1861 /* parameter for the MPEG2-data transfer */
1875 .power_ctrl = cxusb_bluebird_power_ctrl,
1877 .i2c_algo = &cxusb_i2c_algo,
1881 .rc_map_table = rc_map_dvico_portable_table,
1882 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1883 .rc_query = cxusb_rc_query,
1886 .generic_bulk_ctrl_endpoint = 0x01,
1888 .num_device_descs = 1,
1890 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1891 { &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL },
1892 { &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL },
1897 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1898 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1900 .usb_ctrl = CYPRESS_FX2,
1902 .size_of_priv = sizeof(struct cxusb_state),
1909 .streaming_ctrl = cxusb_streaming_ctrl,
1910 .frontend_attach = cxusb_dualdig4_frontend_attach,
1911 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1912 /* parameter for the MPEG2-data transfer */
1927 .power_ctrl = cxusb_power_ctrl,
1929 .i2c_algo = &cxusb_i2c_algo,
1931 .generic_bulk_ctrl_endpoint = 0x01,
1935 .rc_map_table = rc_map_dvico_mce_table,
1936 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
1937 .rc_query = cxusb_bluebird2_rc_query,
1940 .num_device_descs = 1,
1942 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1944 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL },
1949 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1950 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1952 .usb_ctrl = CYPRESS_FX2,
1953 .identify_state = bluebird_fx2_identify_state,
1955 .size_of_priv = sizeof(struct cxusb_state),
1962 .streaming_ctrl = cxusb_streaming_ctrl,
1963 .frontend_attach = cxusb_nano2_frontend_attach,
1964 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1965 /* parameter for the MPEG2-data transfer */
1980 .power_ctrl = cxusb_nano2_power_ctrl,
1982 .i2c_algo = &cxusb_i2c_algo,
1984 .generic_bulk_ctrl_endpoint = 0x01,
1988 .rc_map_table = rc_map_dvico_portable_table,
1989 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
1990 .rc_query = cxusb_bluebird2_rc_query,
1993 .num_device_descs = 1,
1995 { "DViCO FusionHDTV DVB-T NANO2",
1997 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
2002 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
2003 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2005 .usb_ctrl = DEVICE_SPECIFIC,
2006 .firmware = "dvb-usb-bluebird-02.fw",
2007 .download_firmware = bluebird_patch_dvico_firmware_download,
2008 .identify_state = bluebird_fx2_identify_state,
2010 .size_of_priv = sizeof(struct cxusb_state),
2017 .streaming_ctrl = cxusb_streaming_ctrl,
2018 .frontend_attach = cxusb_nano2_frontend_attach,
2019 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
2020 /* parameter for the MPEG2-data transfer */
2035 .power_ctrl = cxusb_nano2_power_ctrl,
2037 .i2c_algo = &cxusb_i2c_algo,
2039 .generic_bulk_ctrl_endpoint = 0x01,
2043 .rc_map_table = rc_map_dvico_portable_table,
2044 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table),
2045 .rc_query = cxusb_rc_query,
2048 .num_device_descs = 1,
2050 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
2051 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
2052 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL },
2057 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
2058 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2060 .usb_ctrl = CYPRESS_FX2,
2062 .size_of_priv = sizeof(struct cxusb_state),
2069 .streaming_ctrl = cxusb_aver_streaming_ctrl,
2070 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
2071 .tuner_attach = cxusb_mxl5003s_tuner_attach,
2072 /* parameter for the MPEG2-data transfer */
2086 .power_ctrl = cxusb_aver_power_ctrl,
2088 .i2c_algo = &cxusb_i2c_algo,
2090 .generic_bulk_ctrl_endpoint = 0x01,
2092 .num_device_descs = 1,
2094 { "AVerMedia AVerTVHD Volar (A868R)",
2096 { &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL },
2102 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2103 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2105 .usb_ctrl = CYPRESS_FX2,
2107 .size_of_priv = sizeof(struct cxusb_state),
2112 .size_of_priv = sizeof(struct dib0700_adapter_state),
2115 .streaming_ctrl = cxusb_streaming_ctrl,
2116 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
2117 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
2118 /* parameter for the MPEG2-data transfer */
2133 .power_ctrl = cxusb_bluebird_power_ctrl,
2135 .i2c_algo = &cxusb_i2c_algo,
2137 .generic_bulk_ctrl_endpoint = 0x01,
2141 .rc_map_table = rc_map_dvico_mce_table,
2142 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table),
2143 .rc_query = cxusb_rc_query,
2146 .num_device_descs = 1,
2148 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
2150 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL },
2155 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2156 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2158 .usb_ctrl = CYPRESS_FX2,
2160 .size_of_priv = sizeof(struct cxusb_state),
2167 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2168 .frontend_attach = cxusb_d680_dmb_frontend_attach,
2169 .tuner_attach = cxusb_d680_dmb_tuner_attach,
2171 /* parameter for the MPEG2-data transfer */
2186 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2188 .i2c_algo = &cxusb_i2c_algo,
2190 .generic_bulk_ctrl_endpoint = 0x01,
2194 .rc_map_table = rc_map_d680_dmb_table,
2195 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2196 .rc_query = cxusb_d680_dmb_rc_query,
2199 .num_device_descs = 1,
2202 "Conexant DMB-TH Stick",
2204 { &cxusb_table[CONEXANT_D680_DMB], NULL },
2209 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2210 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2212 .usb_ctrl = CYPRESS_FX2,
2214 .size_of_priv = sizeof(struct cxusb_state),
2221 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2222 .frontend_attach = cxusb_mygica_d689_frontend_attach,
2223 .tuner_attach = cxusb_mygica_d689_tuner_attach,
2225 /* parameter for the MPEG2-data transfer */
2240 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2242 .i2c_algo = &cxusb_i2c_algo,
2244 .generic_bulk_ctrl_endpoint = 0x01,
2248 .rc_map_table = rc_map_d680_dmb_table,
2249 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2250 .rc_query = cxusb_d680_dmb_rc_query,
2253 .num_device_descs = 1,
2256 "Mygica D689 DMB-TH",
2258 { &cxusb_table[MYGICA_D689], NULL },
2263 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2264 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2266 .usb_ctrl = CYPRESS_FX2,
2268 .size_of_priv = sizeof(struct cxusb_state),
2275 .streaming_ctrl = cxusb_streaming_ctrl,
2276 .frontend_attach = cxusb_mygica_t230_frontend_attach,
2278 /* parameter for the MPEG2-data transfer */
2293 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2295 .i2c_algo = &cxusb_i2c_algo,
2297 .generic_bulk_ctrl_endpoint = 0x01,
2301 .rc_map_table = rc_map_d680_dmb_table,
2302 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table),
2303 .rc_query = cxusb_d680_dmb_rc_query,
2306 .num_device_descs = 1,
2309 "Mygica T230 DVB-T/T2/C",
2311 { &cxusb_table[MYGICA_T230], NULL },
2316 static struct usb_driver cxusb_driver = {
2317 .name = "dvb_usb_cxusb",
2318 .probe = cxusb_probe,
2319 .disconnect = cxusb_disconnect,
2320 .id_table = cxusb_table,
2323 module_usb_driver(cxusb_driver);
2325 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2326 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2327 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2328 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2329 MODULE_VERSION("1.0-alpha");
2330 MODULE_LICENSE("GPL");