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 int cxusb_read_status(struct dvb_frontend *fe,
374 enum fe_status *status)
376 struct dvb_usb_adapter *adap = (struct dvb_usb_adapter *)fe->dvb->priv;
377 struct cxusb_state *state = (struct cxusb_state *)adap->dev->priv;
380 ret = state->fe_read_status(fe, status);
382 /* it need resync slave fifo when signal change from unlock to lock.*/
383 if ((*status & FE_HAS_LOCK) && (!state->last_lock)) {
384 mutex_lock(&state->stream_mutex);
385 cxusb_streaming_ctrl(adap, 1);
386 mutex_unlock(&state->stream_mutex);
389 state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
393 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
395 int ep = d->props.generic_bulk_ctrl_endpoint;
396 const int timeout = 100;
397 const int junk_len = 32;
401 /* Discard remaining data in video pipe */
402 junk = kmalloc(junk_len, GFP_KERNEL);
406 if (usb_bulk_msg(d->udev,
407 usb_rcvbulkpipe(d->udev, ep),
408 junk, junk_len, &rd_count, timeout) < 0)
416 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
418 struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream;
419 const int timeout = 100;
420 const int junk_len = p->u.bulk.buffersize;
424 /* Discard remaining data in video pipe */
425 junk = kmalloc(junk_len, GFP_KERNEL);
429 if (usb_bulk_msg(d->udev,
430 usb_rcvbulkpipe(d->udev, p->endpoint),
431 junk, junk_len, &rd_count, timeout) < 0)
439 static int cxusb_d680_dmb_streaming_ctrl(
440 struct dvb_usb_adapter *adap, int onoff)
443 u8 buf[2] = { 0x03, 0x00 };
444 cxusb_d680_dmb_drain_video(adap->dev);
445 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
446 buf, sizeof(buf), NULL, 0);
448 int ret = cxusb_ctrl_msg(adap->dev,
449 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
454 static int cxusb_rc_query(struct dvb_usb_device *d)
458 if (cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4) < 0)
461 if (ircode[2] || ircode[3])
462 rc_keydown(d->rc_dev, RC_PROTO_NEC,
463 RC_SCANCODE_NEC(~ircode[2] & 0xff, ircode[3]), 0);
467 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d)
470 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
471 .buf = ircode, .len = 4 };
473 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
476 if (ircode[1] || ircode[2])
477 rc_keydown(d->rc_dev, RC_PROTO_NEC,
478 RC_SCANCODE_NEC(~ircode[1] & 0xff, ircode[2]), 0);
482 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d)
486 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
489 if (ircode[0] || ircode[1])
490 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN,
491 RC_SCANCODE_RC5(ircode[0], ircode[1]), 0);
495 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
497 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
498 static u8 reset [] = { RESET, 0x80 };
499 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
500 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
501 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
502 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
504 mt352_write(fe, clock_config, sizeof(clock_config));
506 mt352_write(fe, reset, sizeof(reset));
507 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
509 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
510 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
511 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
516 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
517 { /* used in both lgz201 and th7579 */
518 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
519 static u8 reset [] = { RESET, 0x80 };
520 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
521 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
522 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
523 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
525 mt352_write(fe, clock_config, sizeof(clock_config));
527 mt352_write(fe, reset, sizeof(reset));
528 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
530 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
531 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
532 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
536 static struct cx22702_config cxusb_cx22702_config = {
537 .demod_address = 0x63,
538 .output_mode = CX22702_PARALLEL_OUTPUT,
541 static struct lgdt330x_config cxusb_lgdt3303_config = {
542 .demod_address = 0x0e,
543 .demod_chip = LGDT3303,
546 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
547 .demod_address = 0x0e,
548 .demod_chip = LGDT3303,
549 .clock_polarity_flip = 2,
552 static struct mt352_config cxusb_dee1601_config = {
553 .demod_address = 0x0f,
554 .demod_init = cxusb_dee1601_demod_init,
557 static struct zl10353_config cxusb_zl10353_dee1601_config = {
558 .demod_address = 0x0f,
562 static struct mt352_config cxusb_mt352_config = {
563 /* used in both lgz201 and th7579 */
564 .demod_address = 0x0f,
565 .demod_init = cxusb_mt352_demod_init,
568 static struct zl10353_config cxusb_zl10353_xc3028_config = {
569 .demod_address = 0x0f,
575 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
576 .demod_address = 0x0f,
580 .disable_i2c_gate_ctrl = 1,
583 static struct mt352_config cxusb_mt352_xc3028_config = {
584 .demod_address = 0x0f,
587 .demod_init = cxusb_mt352_demod_init,
590 /* FIXME: needs tweaking */
591 static struct mxl5005s_config aver_a868r_tuner = {
593 .if_freq = 6000000UL,
594 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
595 .agc_mode = MXL_SINGLE_AGC,
596 .tracking_filter = MXL_TF_C,
597 .rssi_enable = MXL_RSSI_ENABLE,
598 .cap_select = MXL_CAP_SEL_ENABLE,
599 .div_out = MXL_DIV_OUT_4,
600 .clock_out = MXL_CLOCK_OUT_DISABLE,
601 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
602 .top = MXL5005S_TOP_25P2,
603 .mod_mode = MXL_DIGITAL_MODE,
604 .if_mode = MXL_ZERO_IF,
605 .AgcMasterByte = 0x00,
608 /* FIXME: needs tweaking */
609 static struct mxl5005s_config d680_dmb_tuner = {
611 .if_freq = 36125000UL,
612 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
613 .agc_mode = MXL_SINGLE_AGC,
614 .tracking_filter = MXL_TF_C,
615 .rssi_enable = MXL_RSSI_ENABLE,
616 .cap_select = MXL_CAP_SEL_ENABLE,
617 .div_out = MXL_DIV_OUT_4,
618 .clock_out = MXL_CLOCK_OUT_DISABLE,
619 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
620 .top = MXL5005S_TOP_25P2,
621 .mod_mode = MXL_DIGITAL_MODE,
622 .if_mode = MXL_ZERO_IF,
623 .AgcMasterByte = 0x00,
626 static struct max2165_config mygica_d689_max2165_cfg = {
631 /* Callbacks for DVB USB */
632 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
634 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
635 &adap->dev->i2c_adap, 0x61,
636 TUNER_PHILIPS_FMD1216ME_MK3);
640 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
642 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61,
643 NULL, DVB_PLL_THOMSON_DTT7579);
647 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
649 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201);
653 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
655 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
656 NULL, DVB_PLL_THOMSON_DTT7579);
660 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
662 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
663 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
667 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
668 int command, int arg)
670 struct dvb_usb_adapter *adap = ptr;
671 struct dvb_usb_device *d = adap->dev;
674 case XC2028_TUNER_RESET:
675 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
676 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
678 case XC2028_RESET_CLK:
679 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
681 case XC2028_I2C_FLUSH:
684 deb_info("%s: unknown command %d, arg %d\n", __func__,
692 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
694 struct dvb_frontend *fe;
695 struct xc2028_config cfg = {
696 .i2c_adap = &adap->dev->i2c_adap,
699 static struct xc2028_ctrl ctl = {
700 .fname = "/*(DEBLOBBED)*/",
702 .demod = XC3028_FE_ZARLINK456,
705 /* FIXME: generalize & move to common area */
706 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback;
708 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg);
709 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
712 fe->ops.tuner_ops.set_config(fe, &ctl);
717 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
719 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
720 &adap->dev->i2c_adap, &aver_a868r_tuner);
724 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
726 struct dvb_frontend *fe;
727 fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
728 &adap->dev->i2c_adap, &d680_dmb_tuner);
729 return (fe == NULL) ? -EIO : 0;
732 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
734 struct dvb_frontend *fe;
735 fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe,
736 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
737 return (fe == NULL) ? -EIO : 0;
740 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
743 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
744 err("set interface failed");
746 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
748 adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
749 &adap->dev->i2c_adap);
750 if ((adap->fe_adap[0].fe) != NULL)
756 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
758 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
759 err("set interface failed");
761 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
763 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
764 &cxusb_lgdt3303_config,
765 &adap->dev->i2c_adap);
766 if ((adap->fe_adap[0].fe) != NULL)
772 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
774 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
775 &adap->dev->i2c_adap);
776 if (adap->fe_adap[0].fe != NULL)
782 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
784 /* used in both lgz201 and th7579 */
785 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
786 err("set interface failed");
788 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
790 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
791 &adap->dev->i2c_adap);
792 if ((adap->fe_adap[0].fe) != NULL)
798 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
800 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
801 err("set interface failed");
803 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
805 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
806 &adap->dev->i2c_adap);
807 if ((adap->fe_adap[0].fe) != NULL)
810 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
811 &cxusb_zl10353_dee1601_config,
812 &adap->dev->i2c_adap);
813 if ((adap->fe_adap[0].fe) != NULL)
819 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
823 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
824 .buf = ircode, .len = 4 };
826 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
827 err("set interface failed");
829 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
831 /* reset the tuner and demodulator */
832 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
833 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
834 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
836 adap->fe_adap[0].fe =
837 dvb_attach(zl10353_attach,
838 &cxusb_zl10353_xc3028_config_no_i2c_gate,
839 &adap->dev->i2c_adap);
840 if ((adap->fe_adap[0].fe) == NULL)
843 /* try to determine if there is no IR decoder on the I2C bus */
844 for (i = 0; adap->dev->props.rc.core.rc_codes && i < 5; i++) {
846 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
848 if (ircode[0] == 0 && ircode[1] == 0)
850 if (ircode[2] + ircode[3] != 0xff) {
852 adap->dev->props.rc.core.rc_codes = NULL;
853 info("No IR receiver detected on this device.");
861 static struct dibx000_agc_config dib7070_agc_config = {
862 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
865 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
866 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
867 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
869 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
870 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
896 .perform_agc_softsplit = 0,
899 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
912 /* refsel, sel, freq_15k */
913 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
914 .ifreq = (0 << 25) | 0,
919 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
920 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
921 .output_mpeg2_in_188_bytes = 1,
923 .agc_config_count = 1,
924 .agc = &dib7070_agc_config,
925 .bw = &dib7070_bw_config_12_mhz,
926 .tuner_is_baseband = 1,
932 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
934 .hostbus_diversity = 1,
937 struct dib0700_adapter_state {
938 int (*set_param_save)(struct dvb_frontend *);
939 struct dib7000p_ops dib7000p_ops;
942 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
944 struct dib0700_adapter_state *state = adap->priv;
946 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
947 err("set interface failed");
949 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
951 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
953 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
956 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
957 &cxusb_dualdig4_rev2_config) < 0) {
958 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
962 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
963 &cxusb_dualdig4_rev2_config);
964 if (adap->fe_adap[0].fe == NULL)
970 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
972 struct dvb_usb_adapter *adap = fe->dvb->priv;
973 struct dib0700_adapter_state *state = adap->priv;
975 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
978 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
983 static struct dib0070_config dib7070p_dib0070_config = {
984 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
985 .reset = dib7070_tuner_reset,
986 .sleep = dib7070_tuner_sleep,
990 static int dib7070_set_param_override(struct dvb_frontend *fe)
992 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
993 struct dvb_usb_adapter *adap = fe->dvb->priv;
994 struct dib0700_adapter_state *state = adap->priv;
997 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
999 case BAND_VHF: offset = 950; break;
1001 case BAND_UHF: offset = 550; break;
1004 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1006 return state->set_param_save(fe);
1009 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1011 struct dib0700_adapter_state *st = adap->priv;
1012 struct i2c_adapter *tun_i2c;
1015 * No need to call dvb7000p_attach here, as it was called
1016 * already, as frontend_attach method is called first, and
1017 * tuner_attach is only called on sucess.
1019 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
1020 DIBX000_I2C_INTERFACE_TUNER, 1);
1022 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1023 &dib7070p_dib0070_config) == NULL)
1026 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1027 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1031 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1033 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1034 err("set interface failed");
1036 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1038 /* reset the tuner and demodulator */
1039 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1040 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1041 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1043 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
1044 &cxusb_zl10353_xc3028_config,
1045 &adap->dev->i2c_adap);
1046 if ((adap->fe_adap[0].fe) != NULL)
1049 adap->fe_adap[0].fe = dvb_attach(mt352_attach,
1050 &cxusb_mt352_xc3028_config,
1051 &adap->dev->i2c_adap);
1052 if ((adap->fe_adap[0].fe) != NULL)
1058 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1059 .prod = LGS8GXX_PROD_LGS8GL5,
1060 .demod_address = 0x19,
1064 .if_clk_freq = 30400, /* 30.4 MHz */
1065 .if_freq = 5725, /* 5.725 MHz */
1072 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1074 struct dvb_usb_device *d = adap->dev;
1077 /* Select required USB configuration */
1078 if (usb_set_interface(d->udev, 0, 0) < 0)
1079 err("set interface failed");
1081 /* Unblock all USB pipes */
1082 usb_clear_halt(d->udev,
1083 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1084 usb_clear_halt(d->udev,
1085 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1086 usb_clear_halt(d->udev,
1087 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1089 /* Drain USB pipes to avoid hang after reboot */
1090 for (n = 0; n < 5; n++) {
1091 cxusb_d680_dmb_drain_message(d);
1092 cxusb_d680_dmb_drain_video(d);
1096 /* Reset the tuner */
1097 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1098 err("clear tuner gpio failed");
1102 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1103 err("set tuner gpio failed");
1108 /* Attach frontend */
1109 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1110 if (adap->fe_adap[0].fe == NULL)
1116 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1117 .prod = ATBM8830_PROD_8830,
1118 .demod_address = 0x40,
1120 .ts_sampling_edge = 1,
1122 .osc_clk_freq = 30400, /* in kHz */
1123 .if_freq = 0, /* zero IF */
1130 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1132 struct dvb_usb_device *d = adap->dev;
1134 /* Select required USB configuration */
1135 if (usb_set_interface(d->udev, 0, 0) < 0)
1136 err("set interface failed");
1138 /* Unblock all USB pipes */
1139 usb_clear_halt(d->udev,
1140 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1141 usb_clear_halt(d->udev,
1142 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1143 usb_clear_halt(d->udev,
1144 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1147 /* Reset the tuner */
1148 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1149 err("clear tuner gpio failed");
1153 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1154 err("set tuner gpio failed");
1159 /* Attach frontend */
1160 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1162 if (adap->fe_adap[0].fe == NULL)
1168 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
1170 struct dvb_usb_device *d = adap->dev;
1171 struct cxusb_state *st = d->priv;
1172 struct i2c_adapter *adapter;
1173 struct i2c_client *client_demod;
1174 struct i2c_client *client_tuner;
1175 struct i2c_board_info info;
1176 struct si2168_config si2168_config;
1177 struct si2157_config si2157_config;
1179 /* Select required USB configuration */
1180 if (usb_set_interface(d->udev, 0, 0) < 0)
1181 err("set interface failed");
1183 /* Unblock all USB pipes */
1184 usb_clear_halt(d->udev,
1185 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1186 usb_clear_halt(d->udev,
1187 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1188 usb_clear_halt(d->udev,
1189 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1191 /* attach frontend */
1192 si2168_config.i2c_adapter = &adapter;
1193 si2168_config.fe = &adap->fe_adap[0].fe;
1194 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1195 si2168_config.ts_clock_inv = 1;
1196 memset(&info, 0, sizeof(struct i2c_board_info));
1197 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1199 info.platform_data = &si2168_config;
1200 request_module(info.type);
1201 client_demod = i2c_new_device(&d->i2c_adap, &info);
1202 if (client_demod == NULL || client_demod->dev.driver == NULL)
1205 if (!try_module_get(client_demod->dev.driver->owner)) {
1206 i2c_unregister_device(client_demod);
1210 st->i2c_client_demod = client_demod;
1213 memset(&si2157_config, 0, sizeof(si2157_config));
1214 si2157_config.fe = adap->fe_adap[0].fe;
1215 si2157_config.if_port = 1;
1216 memset(&info, 0, sizeof(struct i2c_board_info));
1217 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1219 info.platform_data = &si2157_config;
1220 request_module(info.type);
1221 client_tuner = i2c_new_device(adapter, &info);
1222 if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1223 module_put(client_demod->dev.driver->owner);
1224 i2c_unregister_device(client_demod);
1227 if (!try_module_get(client_tuner->dev.driver->owner)) {
1228 i2c_unregister_device(client_tuner);
1229 module_put(client_demod->dev.driver->owner);
1230 i2c_unregister_device(client_demod);
1234 st->i2c_client_tuner = client_tuner;
1236 /* hook fe: need to resync the slave fifo when signal locks. */
1237 mutex_init(&st->stream_mutex);
1239 st->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
1240 adap->fe_adap[0].fe->ops.read_status = cxusb_read_status;
1245 static int cxusb_mygica_t230c_frontend_attach(struct dvb_usb_adapter *adap)
1247 struct dvb_usb_device *d = adap->dev;
1248 struct cxusb_state *st = d->priv;
1249 struct i2c_adapter *adapter;
1250 struct i2c_client *client_demod;
1251 struct i2c_client *client_tuner;
1252 struct i2c_board_info info;
1253 struct si2168_config si2168_config;
1254 struct si2157_config si2157_config;
1256 /* Select required USB configuration */
1257 if (usb_set_interface(d->udev, 0, 0) < 0)
1258 err("set interface failed");
1260 /* Unblock all USB pipes */
1261 usb_clear_halt(d->udev,
1262 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1263 usb_clear_halt(d->udev,
1264 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1265 usb_clear_halt(d->udev,
1266 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1268 /* attach frontend */
1269 memset(&si2168_config, 0, sizeof(si2168_config));
1270 si2168_config.i2c_adapter = &adapter;
1271 si2168_config.fe = &adap->fe_adap[0].fe;
1272 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1273 si2168_config.ts_clock_inv = 1;
1274 memset(&info, 0, sizeof(struct i2c_board_info));
1275 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1277 info.platform_data = &si2168_config;
1278 request_module(info.type);
1279 client_demod = i2c_new_device(&d->i2c_adap, &info);
1280 if (client_demod == NULL || client_demod->dev.driver == NULL)
1283 if (!try_module_get(client_demod->dev.driver->owner)) {
1284 i2c_unregister_device(client_demod);
1289 memset(&si2157_config, 0, sizeof(si2157_config));
1290 si2157_config.fe = adap->fe_adap[0].fe;
1291 memset(&info, 0, sizeof(struct i2c_board_info));
1292 strlcpy(info.type, "si2141", I2C_NAME_SIZE);
1294 info.platform_data = &si2157_config;
1295 request_module("si2157");
1296 client_tuner = i2c_new_device(adapter, &info);
1297 if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1298 module_put(client_demod->dev.driver->owner);
1299 i2c_unregister_device(client_demod);
1302 if (!try_module_get(client_tuner->dev.driver->owner)) {
1303 i2c_unregister_device(client_tuner);
1304 module_put(client_demod->dev.driver->owner);
1305 i2c_unregister_device(client_demod);
1309 st->i2c_client_demod = client_demod;
1310 st->i2c_client_tuner = client_tuner;
1312 /* hook fe: need to resync the slave fifo when signal locks. */
1313 mutex_init(&st->stream_mutex);
1315 st->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
1316 adap->fe_adap[0].fe->ops.read_status = cxusb_read_status;
1322 * DViCO has shipped two devices with the same USB ID, but only one of them
1323 * needs a firmware download. Check the device class details to see if they
1324 * have non-default values to decide whether the device is actually cold or
1325 * not, and forget a match if it turns out we selected the wrong device.
1327 static int bluebird_fx2_identify_state(struct usb_device *udev,
1328 struct dvb_usb_device_properties *props,
1329 struct dvb_usb_device_description **desc,
1332 int wascold = *cold;
1334 *cold = udev->descriptor.bDeviceClass == 0xff &&
1335 udev->descriptor.bDeviceSubClass == 0xff &&
1336 udev->descriptor.bDeviceProtocol == 0xff;
1338 if (*cold && !wascold)
1345 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1346 * firmware file before download.
1349 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
1350 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1351 const struct firmware *fw)
1355 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1356 int idoff = dvico_firmware_id_offsets[pos];
1358 if (fw->size < idoff + 4)
1361 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1362 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1363 struct firmware new_fw;
1364 u8 *new_fw_data = vmalloc(fw->size);
1370 memcpy(new_fw_data, fw->data, fw->size);
1371 new_fw.size = fw->size;
1372 new_fw.data = new_fw_data;
1374 new_fw_data[idoff + 2] =
1375 le16_to_cpu(udev->descriptor.idProduct) + 1;
1376 new_fw_data[idoff + 3] =
1377 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1379 ret = usb_cypress_load_firmware(udev, &new_fw,
1389 /* DVB USB Driver stuff */
1390 static struct dvb_usb_device_properties cxusb_medion_properties;
1391 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1392 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1393 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1394 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1395 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1396 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1397 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1398 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1399 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1400 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1401 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1402 static struct dvb_usb_device_properties cxusb_mygica_t230_properties;
1403 static struct dvb_usb_device_properties cxusb_mygica_t230c_properties;
1405 static int cxusb_probe(struct usb_interface *intf,
1406 const struct usb_device_id *id)
1408 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1409 THIS_MODULE, NULL, adapter_nr) ||
1410 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1411 THIS_MODULE, NULL, adapter_nr) ||
1412 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1413 THIS_MODULE, NULL, adapter_nr) ||
1414 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1415 THIS_MODULE, NULL, adapter_nr) ||
1416 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1417 THIS_MODULE, NULL, adapter_nr) ||
1418 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1419 THIS_MODULE, NULL, adapter_nr) ||
1420 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1421 THIS_MODULE, NULL, adapter_nr) ||
1422 0 == dvb_usb_device_init(intf,
1423 &cxusb_bluebird_nano2_needsfirmware_properties,
1424 THIS_MODULE, NULL, adapter_nr) ||
1425 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1426 THIS_MODULE, NULL, adapter_nr) ||
1427 0 == dvb_usb_device_init(intf,
1428 &cxusb_bluebird_dualdig4_rev2_properties,
1429 THIS_MODULE, NULL, adapter_nr) ||
1430 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1431 THIS_MODULE, NULL, adapter_nr) ||
1432 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1433 THIS_MODULE, NULL, adapter_nr) ||
1434 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties,
1435 THIS_MODULE, NULL, adapter_nr) ||
1436 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230c_properties,
1437 THIS_MODULE, NULL, adapter_nr) ||
1444 static void cxusb_disconnect(struct usb_interface *intf)
1446 struct dvb_usb_device *d = usb_get_intfdata(intf);
1447 struct cxusb_state *st = d->priv;
1448 struct i2c_client *client;
1450 /* remove I2C client for tuner */
1451 client = st->i2c_client_tuner;
1453 module_put(client->dev.driver->owner);
1454 i2c_unregister_device(client);
1457 /* remove I2C client for demodulator */
1458 client = st->i2c_client_demod;
1460 module_put(client->dev.driver->owner);
1461 i2c_unregister_device(client);
1464 dvb_usb_device_exit(intf);
1467 enum cxusb_table_index {
1469 DVICO_BLUEBIRD_LG064F_COLD,
1470 DVICO_BLUEBIRD_LG064F_WARM,
1471 DVICO_BLUEBIRD_DUAL_1_COLD,
1472 DVICO_BLUEBIRD_DUAL_1_WARM,
1473 DVICO_BLUEBIRD_LGZ201_COLD,
1474 DVICO_BLUEBIRD_LGZ201_WARM,
1475 DVICO_BLUEBIRD_TH7579_COLD,
1476 DVICO_BLUEBIRD_TH7579_WARM,
1477 DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
1478 DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
1479 DVICO_BLUEBIRD_DUAL_2_COLD,
1480 DVICO_BLUEBIRD_DUAL_2_WARM,
1481 DVICO_BLUEBIRD_DUAL_4,
1482 DVICO_BLUEBIRD_DVB_T_NANO_2,
1483 DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
1484 AVERMEDIA_VOLAR_A868R,
1485 DVICO_BLUEBIRD_DUAL_4_REV_2,
1490 NR__cxusb_table_index
1493 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
1494 [MEDION_MD95700] = {
1495 USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700)
1497 [DVICO_BLUEBIRD_LG064F_COLD] = {
1498 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD)
1500 [DVICO_BLUEBIRD_LG064F_WARM] = {
1501 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM)
1503 [DVICO_BLUEBIRD_DUAL_1_COLD] = {
1504 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD)
1506 [DVICO_BLUEBIRD_DUAL_1_WARM] = {
1507 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM)
1509 [DVICO_BLUEBIRD_LGZ201_COLD] = {
1510 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD)
1512 [DVICO_BLUEBIRD_LGZ201_WARM] = {
1513 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM)
1515 [DVICO_BLUEBIRD_TH7579_COLD] = {
1516 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD)
1518 [DVICO_BLUEBIRD_TH7579_WARM] = {
1519 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM)
1521 [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = {
1522 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD)
1524 [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = {
1525 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM)
1527 [DVICO_BLUEBIRD_DUAL_2_COLD] = {
1528 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD)
1530 [DVICO_BLUEBIRD_DUAL_2_WARM] = {
1531 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM)
1533 [DVICO_BLUEBIRD_DUAL_4] = {
1534 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4)
1536 [DVICO_BLUEBIRD_DVB_T_NANO_2] = {
1537 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2)
1539 [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {
1540 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM)
1542 [AVERMEDIA_VOLAR_A868R] = {
1543 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R)
1545 [DVICO_BLUEBIRD_DUAL_4_REV_2] = {
1546 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2)
1548 [CONEXANT_D680_DMB] = {
1549 USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB)
1552 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689)
1555 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230)
1558 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230+1)
1560 {} /* Terminating entry */
1562 MODULE_DEVICE_TABLE (usb, cxusb_table);
1564 static struct dvb_usb_device_properties cxusb_medion_properties = {
1565 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1567 .usb_ctrl = CYPRESS_FX2,
1569 .size_of_priv = sizeof(struct cxusb_state),
1576 .streaming_ctrl = cxusb_streaming_ctrl,
1577 .frontend_attach = cxusb_cx22702_frontend_attach,
1578 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1579 /* parameter for the MPEG2-data transfer */
1593 .power_ctrl = cxusb_power_ctrl,
1595 .i2c_algo = &cxusb_i2c_algo,
1597 .generic_bulk_ctrl_endpoint = 0x01,
1599 .num_device_descs = 1,
1601 { "Medion MD95700 (MDUSBTV-HYBRID)",
1603 { &cxusb_table[MEDION_MD95700], NULL },
1608 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1609 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1611 .usb_ctrl = DEVICE_SPECIFIC,
1612 .firmware = "/*(DEBLOBBED)*/",
1613 .download_firmware = bluebird_patch_dvico_firmware_download,
1614 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1615 use usb alt setting 7 for EP2 transfer (atsc) */
1617 .size_of_priv = sizeof(struct cxusb_state),
1624 .streaming_ctrl = cxusb_streaming_ctrl,
1625 .frontend_attach = cxusb_lgdt3303_frontend_attach,
1626 .tuner_attach = cxusb_lgh064f_tuner_attach,
1628 /* parameter for the MPEG2-data transfer */
1643 .power_ctrl = cxusb_bluebird_power_ctrl,
1645 .i2c_algo = &cxusb_i2c_algo,
1649 .rc_codes = RC_MAP_DVICO_PORTABLE,
1650 .module_name = KBUILD_MODNAME,
1651 .rc_query = cxusb_rc_query,
1652 .allowed_protos = RC_PROTO_BIT_NEC,
1655 .generic_bulk_ctrl_endpoint = 0x01,
1657 .num_device_descs = 1,
1659 { "DViCO FusionHDTV5 USB Gold",
1660 { &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL },
1661 { &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL },
1666 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1667 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1669 .usb_ctrl = DEVICE_SPECIFIC,
1670 .firmware = "/*(DEBLOBBED)*/",
1671 .download_firmware = bluebird_patch_dvico_firmware_download,
1672 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1673 use usb alt setting 7 for EP2 transfer (atsc) */
1675 .size_of_priv = sizeof(struct cxusb_state),
1682 .streaming_ctrl = cxusb_streaming_ctrl,
1683 .frontend_attach = cxusb_dee1601_frontend_attach,
1684 .tuner_attach = cxusb_dee1601_tuner_attach,
1685 /* parameter for the MPEG2-data transfer */
1700 .power_ctrl = cxusb_bluebird_power_ctrl,
1702 .i2c_algo = &cxusb_i2c_algo,
1706 .rc_codes = RC_MAP_DVICO_MCE,
1707 .module_name = KBUILD_MODNAME,
1708 .rc_query = cxusb_rc_query,
1709 .allowed_protos = RC_PROTO_BIT_NEC,
1712 .generic_bulk_ctrl_endpoint = 0x01,
1714 .num_device_descs = 3,
1716 { "DViCO FusionHDTV DVB-T Dual USB",
1717 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL },
1718 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL },
1720 { "DigitalNow DVB-T Dual USB",
1721 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD], NULL },
1722 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL },
1724 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1725 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL },
1726 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL },
1731 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1732 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1734 .usb_ctrl = DEVICE_SPECIFIC,
1735 .firmware = "/*(DEBLOBBED)*/",
1736 .download_firmware = bluebird_patch_dvico_firmware_download,
1737 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1738 use usb alt setting 7 for EP2 transfer (atsc) */
1740 .size_of_priv = sizeof(struct cxusb_state),
1747 .streaming_ctrl = cxusb_streaming_ctrl,
1748 .frontend_attach = cxusb_mt352_frontend_attach,
1749 .tuner_attach = cxusb_lgz201_tuner_attach,
1751 /* parameter for the MPEG2-data transfer */
1765 .power_ctrl = cxusb_bluebird_power_ctrl,
1767 .i2c_algo = &cxusb_i2c_algo,
1771 .rc_codes = RC_MAP_DVICO_PORTABLE,
1772 .module_name = KBUILD_MODNAME,
1773 .rc_query = cxusb_rc_query,
1774 .allowed_protos = RC_PROTO_BIT_NEC,
1777 .generic_bulk_ctrl_endpoint = 0x01,
1778 .num_device_descs = 1,
1780 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1781 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL },
1782 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL },
1787 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1788 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1790 .usb_ctrl = DEVICE_SPECIFIC,
1791 .firmware = "/*(DEBLOBBED)*/",
1792 .download_firmware = bluebird_patch_dvico_firmware_download,
1793 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1794 use usb alt setting 7 for EP2 transfer (atsc) */
1796 .size_of_priv = sizeof(struct cxusb_state),
1803 .streaming_ctrl = cxusb_streaming_ctrl,
1804 .frontend_attach = cxusb_mt352_frontend_attach,
1805 .tuner_attach = cxusb_dtt7579_tuner_attach,
1807 /* parameter for the MPEG2-data transfer */
1821 .power_ctrl = cxusb_bluebird_power_ctrl,
1823 .i2c_algo = &cxusb_i2c_algo,
1827 .rc_codes = RC_MAP_DVICO_PORTABLE,
1828 .module_name = KBUILD_MODNAME,
1829 .rc_query = cxusb_rc_query,
1830 .allowed_protos = RC_PROTO_BIT_NEC,
1833 .generic_bulk_ctrl_endpoint = 0x01,
1835 .num_device_descs = 1,
1837 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1838 { &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL },
1839 { &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL },
1844 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1845 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1847 .usb_ctrl = CYPRESS_FX2,
1849 .size_of_priv = sizeof(struct cxusb_state),
1856 .streaming_ctrl = cxusb_streaming_ctrl,
1857 .frontend_attach = cxusb_dualdig4_frontend_attach,
1858 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1859 /* parameter for the MPEG2-data transfer */
1874 .power_ctrl = cxusb_power_ctrl,
1876 .i2c_algo = &cxusb_i2c_algo,
1878 .generic_bulk_ctrl_endpoint = 0x01,
1882 .rc_codes = RC_MAP_DVICO_MCE,
1883 .module_name = KBUILD_MODNAME,
1884 .rc_query = cxusb_bluebird2_rc_query,
1885 .allowed_protos = RC_PROTO_BIT_NEC,
1888 .num_device_descs = 1,
1890 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1892 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL },
1897 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1898 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1900 .usb_ctrl = CYPRESS_FX2,
1901 .identify_state = bluebird_fx2_identify_state,
1903 .size_of_priv = sizeof(struct cxusb_state),
1910 .streaming_ctrl = cxusb_streaming_ctrl,
1911 .frontend_attach = cxusb_nano2_frontend_attach,
1912 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1913 /* parameter for the MPEG2-data transfer */
1928 .power_ctrl = cxusb_nano2_power_ctrl,
1930 .i2c_algo = &cxusb_i2c_algo,
1932 .generic_bulk_ctrl_endpoint = 0x01,
1936 .rc_codes = RC_MAP_DVICO_PORTABLE,
1937 .module_name = KBUILD_MODNAME,
1938 .rc_query = cxusb_bluebird2_rc_query,
1939 .allowed_protos = RC_PROTO_BIT_NEC,
1942 .num_device_descs = 1,
1944 { "DViCO FusionHDTV DVB-T NANO2",
1946 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
1951 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1952 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1954 .usb_ctrl = DEVICE_SPECIFIC,
1955 .firmware = "/*(DEBLOBBED)*/",
1956 .download_firmware = bluebird_patch_dvico_firmware_download,
1957 .identify_state = bluebird_fx2_identify_state,
1959 .size_of_priv = sizeof(struct cxusb_state),
1966 .streaming_ctrl = cxusb_streaming_ctrl,
1967 .frontend_attach = cxusb_nano2_frontend_attach,
1968 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1969 /* parameter for the MPEG2-data transfer */
1984 .power_ctrl = cxusb_nano2_power_ctrl,
1986 .i2c_algo = &cxusb_i2c_algo,
1988 .generic_bulk_ctrl_endpoint = 0x01,
1992 .rc_codes = RC_MAP_DVICO_PORTABLE,
1993 .module_name = KBUILD_MODNAME,
1994 .rc_query = cxusb_rc_query,
1995 .allowed_protos = RC_PROTO_BIT_NEC,
1998 .num_device_descs = 1,
2000 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
2001 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
2002 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL },
2007 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
2008 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2010 .usb_ctrl = CYPRESS_FX2,
2012 .size_of_priv = sizeof(struct cxusb_state),
2019 .streaming_ctrl = cxusb_aver_streaming_ctrl,
2020 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
2021 .tuner_attach = cxusb_mxl5003s_tuner_attach,
2022 /* parameter for the MPEG2-data transfer */
2036 .power_ctrl = cxusb_aver_power_ctrl,
2038 .i2c_algo = &cxusb_i2c_algo,
2040 .generic_bulk_ctrl_endpoint = 0x01,
2042 .num_device_descs = 1,
2044 { "AVerMedia AVerTVHD Volar (A868R)",
2046 { &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL },
2052 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2053 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2055 .usb_ctrl = CYPRESS_FX2,
2057 .size_of_priv = sizeof(struct cxusb_state),
2062 .size_of_priv = sizeof(struct dib0700_adapter_state),
2065 .streaming_ctrl = cxusb_streaming_ctrl,
2066 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
2067 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
2068 /* parameter for the MPEG2-data transfer */
2083 .power_ctrl = cxusb_bluebird_power_ctrl,
2085 .i2c_algo = &cxusb_i2c_algo,
2087 .generic_bulk_ctrl_endpoint = 0x01,
2091 .rc_codes = RC_MAP_DVICO_MCE,
2092 .module_name = KBUILD_MODNAME,
2093 .rc_query = cxusb_rc_query,
2094 .allowed_protos = RC_PROTO_BIT_NEC,
2097 .num_device_descs = 1,
2099 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
2101 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL },
2106 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2107 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2109 .usb_ctrl = CYPRESS_FX2,
2111 .size_of_priv = sizeof(struct cxusb_state),
2118 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2119 .frontend_attach = cxusb_d680_dmb_frontend_attach,
2120 .tuner_attach = cxusb_d680_dmb_tuner_attach,
2122 /* parameter for the MPEG2-data transfer */
2137 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2139 .i2c_algo = &cxusb_i2c_algo,
2141 .generic_bulk_ctrl_endpoint = 0x01,
2145 .rc_codes = RC_MAP_D680_DMB,
2146 .module_name = KBUILD_MODNAME,
2147 .rc_query = cxusb_d680_dmb_rc_query,
2148 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2151 .num_device_descs = 1,
2154 "Conexant DMB-TH Stick",
2156 { &cxusb_table[CONEXANT_D680_DMB], NULL },
2161 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2162 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2164 .usb_ctrl = CYPRESS_FX2,
2166 .size_of_priv = sizeof(struct cxusb_state),
2173 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2174 .frontend_attach = cxusb_mygica_d689_frontend_attach,
2175 .tuner_attach = cxusb_mygica_d689_tuner_attach,
2177 /* parameter for the MPEG2-data transfer */
2192 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2194 .i2c_algo = &cxusb_i2c_algo,
2196 .generic_bulk_ctrl_endpoint = 0x01,
2200 .rc_codes = RC_MAP_D680_DMB,
2201 .module_name = KBUILD_MODNAME,
2202 .rc_query = cxusb_d680_dmb_rc_query,
2203 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2206 .num_device_descs = 1,
2209 "Mygica D689 DMB-TH",
2211 { &cxusb_table[MYGICA_D689], NULL },
2216 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2217 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2219 .usb_ctrl = CYPRESS_FX2,
2221 .size_of_priv = sizeof(struct cxusb_state),
2228 .streaming_ctrl = cxusb_streaming_ctrl,
2229 .frontend_attach = cxusb_mygica_t230_frontend_attach,
2231 /* parameter for the MPEG2-data transfer */
2246 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2248 .i2c_algo = &cxusb_i2c_algo,
2250 .generic_bulk_ctrl_endpoint = 0x01,
2254 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2255 .module_name = KBUILD_MODNAME,
2256 .rc_query = cxusb_d680_dmb_rc_query,
2257 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2260 .num_device_descs = 1,
2263 "Mygica T230 DVB-T/T2/C",
2265 { &cxusb_table[MYGICA_T230], NULL },
2270 static struct dvb_usb_device_properties cxusb_mygica_t230c_properties = {
2271 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2273 .usb_ctrl = CYPRESS_FX2,
2275 .size_of_priv = sizeof(struct cxusb_state),
2282 .streaming_ctrl = cxusb_streaming_ctrl,
2283 .frontend_attach = cxusb_mygica_t230c_frontend_attach,
2285 /* parameter for the MPEG2-data transfer */
2300 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2302 .i2c_algo = &cxusb_i2c_algo,
2304 .generic_bulk_ctrl_endpoint = 0x01,
2308 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2309 .module_name = KBUILD_MODNAME,
2310 .rc_query = cxusb_d680_dmb_rc_query,
2311 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2314 .num_device_descs = 1,
2317 "Mygica T230C DVB-T/T2/C",
2319 { &cxusb_table[MYGICA_T230C], NULL },
2324 static struct usb_driver cxusb_driver = {
2325 .name = "dvb_usb_cxusb",
2326 .probe = cxusb_probe,
2327 .disconnect = cxusb_disconnect,
2328 .id_table = cxusb_table,
2331 module_usb_driver(cxusb_driver);
2333 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2334 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2335 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2336 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2337 MODULE_VERSION("1.0-alpha");
2338 MODULE_LICENSE("GPL");