1 // SPDX-License-Identifier: GPL-2.0-only
2 /* DVB USB compliant linux driver for Conexant USB reference design.
4 * The Conexant reference design I saw on their website was only for analogue
5 * capturing (using the cx25842). The box I took to write this driver (reverse
6 * engineered) is the one labeled Medion MD95700. In addition to the cx25842
7 * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
8 * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
10 * Maybe it is a little bit premature to call this driver cxusb, but I assume
11 * the USB protocol is identical or at least inherited from the reference
12 * design, so it can be reused for the "analogue-only" device (if it will
15 * TODO: Use the cx25840-driver for the analogue part
17 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
18 * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
19 * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
21 * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
23 #include <media/tuner.h>
24 #include <linux/vmalloc.h>
25 #include <linux/slab.h>
26 #include <linux/kernel.h>
33 #include "mt352_priv.h"
35 #include "tuner-xc2028.h"
36 #include "tuner-simple.h"
47 static int dvb_usb_cxusb_debug;
48 module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
49 MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
51 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
53 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
54 #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
56 static int cxusb_ctrl_msg(struct dvb_usb_device *d,
57 u8 cmd, const u8 *wbuf, int wlen, u8 *rbuf, int rlen)
59 struct cxusb_state *st = d->priv;
62 if (1 + wlen > MAX_XFER_SIZE) {
63 warn("i2c wr: len=%d is too big!\n", wlen);
67 if (rlen > MAX_XFER_SIZE) {
68 warn("i2c rd: len=%d is too big!\n", rlen);
72 mutex_lock(&d->data_mutex);
74 memcpy(&st->data[1], wbuf, wlen);
75 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, st->data, rlen, 0);
76 if (!ret && rbuf && rlen)
77 memcpy(rbuf, st->data, rlen);
79 mutex_unlock(&d->data_mutex);
84 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
86 struct cxusb_state *st = d->priv;
89 if (st->gpio_write_state[GPIO_TUNER] == onoff)
94 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
97 deb_info("gpio_write failed.\n");
99 st->gpio_write_state[GPIO_TUNER] = onoff;
102 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
108 o[0] = 0xff & ~changemask; /* mask of bits to keep */
109 o[1] = newval & changemask; /* new values for bits */
111 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
112 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
113 deb_info("bluebird_gpio_write failed.\n");
115 return rc < 0 ? rc : gpio_state;
118 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
120 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
122 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
125 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
127 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
130 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
133 u8 o[2] = {addr, onoff};
137 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
144 deb_info("gpio_write failed.\n");
150 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
153 struct dvb_usb_device *d = i2c_get_adapdata(adap);
157 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
160 for (i = 0; i < num; i++) {
162 if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_MEDION)
163 switch (msg[i].addr) {
165 cxusb_gpio_tuner(d, 0);
168 cxusb_gpio_tuner(d, 1);
172 if (msg[i].flags & I2C_M_RD) {
174 u8 obuf[3], ibuf[MAX_XFER_SIZE];
176 if (1 + msg[i].len > sizeof(ibuf)) {
177 warn("i2c rd: len=%d is too big!\n",
183 obuf[1] = msg[i].len;
184 obuf[2] = msg[i].addr;
185 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
187 ibuf, 1+msg[i].len) < 0) {
188 warn("i2c read failed");
191 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
192 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
193 msg[i].addr == msg[i+1].addr) {
194 /* write to then read from same address */
195 u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE];
197 if (3 + msg[i].len > sizeof(obuf)) {
198 warn("i2c wr: len=%d is too big!\n",
203 if (1 + msg[i + 1].len > sizeof(ibuf)) {
204 warn("i2c rd: len=%d is too big!\n",
209 obuf[0] = msg[i].len;
210 obuf[1] = msg[i+1].len;
211 obuf[2] = msg[i].addr;
212 memcpy(&obuf[3], msg[i].buf, msg[i].len);
214 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
216 ibuf, 1+msg[i+1].len) < 0)
220 deb_i2c("i2c read may have failed\n");
222 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
227 u8 obuf[MAX_XFER_SIZE], ibuf;
229 if (2 + msg[i].len > sizeof(obuf)) {
230 warn("i2c wr: len=%d is too big!\n",
235 obuf[0] = msg[i].addr;
236 obuf[1] = msg[i].len;
237 memcpy(&obuf[2], msg[i].buf, msg[i].len);
239 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
240 2+msg[i].len, &ibuf,1) < 0)
243 deb_i2c("i2c write may have failed\n");
253 mutex_unlock(&d->i2c_mutex);
257 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
262 static struct i2c_algorithm cxusb_i2c_algo = {
263 .master_xfer = cxusb_i2c_xfer,
264 .functionality = cxusb_i2c_func,
267 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
271 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
273 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
276 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
280 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
281 if (d->state == DVB_USB_STATE_INIT &&
282 usb_set_interface(d->udev, 0, 0) < 0)
283 err("set interface failed");
284 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
285 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
286 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
288 /* FIXME: We don't know why, but we need to configure the
289 * lgdt3303 with the register settings below on resume */
292 static const u8 bufs[] = {
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 < ARRAY_SIZE(bufs); 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 int cxusb_read_status(struct dvb_frontend *fe,
373 enum fe_status *status)
375 struct dvb_usb_adapter *adap = (struct dvb_usb_adapter *)fe->dvb->priv;
376 struct cxusb_state *state = (struct cxusb_state *)adap->dev->priv;
379 ret = state->fe_read_status(fe, status);
381 /* it need resync slave fifo when signal change from unlock to lock.*/
382 if ((*status & FE_HAS_LOCK) && (!state->last_lock)) {
383 mutex_lock(&state->stream_mutex);
384 cxusb_streaming_ctrl(adap, 1);
385 mutex_unlock(&state->stream_mutex);
388 state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
392 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
394 int ep = d->props.generic_bulk_ctrl_endpoint;
395 const int timeout = 100;
396 const int junk_len = 32;
400 /* Discard remaining data in video pipe */
401 junk = kmalloc(junk_len, GFP_KERNEL);
405 if (usb_bulk_msg(d->udev,
406 usb_rcvbulkpipe(d->udev, ep),
407 junk, junk_len, &rd_count, timeout) < 0)
415 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
417 struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream;
418 const int timeout = 100;
419 const int junk_len = p->u.bulk.buffersize;
423 /* Discard remaining data in video pipe */
424 junk = kmalloc(junk_len, GFP_KERNEL);
428 if (usb_bulk_msg(d->udev,
429 usb_rcvbulkpipe(d->udev, p->endpoint),
430 junk, junk_len, &rd_count, timeout) < 0)
438 static int cxusb_d680_dmb_streaming_ctrl(
439 struct dvb_usb_adapter *adap, int onoff)
442 u8 buf[2] = { 0x03, 0x00 };
443 cxusb_d680_dmb_drain_video(adap->dev);
444 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
445 buf, sizeof(buf), NULL, 0);
447 int ret = cxusb_ctrl_msg(adap->dev,
448 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
453 static int cxusb_rc_query(struct dvb_usb_device *d)
457 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
459 if (ircode[2] || ircode[3])
460 rc_keydown(d->rc_dev, RC_PROTO_NEC,
461 RC_SCANCODE_NEC(~ircode[2] & 0xff, ircode[3]), 0);
465 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d)
468 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
469 .buf = ircode, .len = 4 };
471 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
474 if (ircode[1] || ircode[2])
475 rc_keydown(d->rc_dev, RC_PROTO_NEC,
476 RC_SCANCODE_NEC(~ircode[1] & 0xff, ircode[2]), 0);
480 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d)
484 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
487 if (ircode[0] || ircode[1])
488 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN,
489 RC_SCANCODE_RC5(ircode[0], ircode[1]), 0);
493 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
495 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
496 static u8 reset [] = { RESET, 0x80 };
497 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
498 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
499 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
500 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
502 mt352_write(fe, clock_config, sizeof(clock_config));
504 mt352_write(fe, reset, sizeof(reset));
505 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
507 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
508 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
509 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
514 static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
515 { /* used in both lgz201 and th7579 */
516 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
517 static u8 reset [] = { RESET, 0x80 };
518 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
519 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
520 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
521 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
523 mt352_write(fe, clock_config, sizeof(clock_config));
525 mt352_write(fe, reset, sizeof(reset));
526 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
528 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
529 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
530 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
534 static struct cx22702_config cxusb_cx22702_config = {
535 .demod_address = 0x63,
536 .output_mode = CX22702_PARALLEL_OUTPUT,
539 static struct lgdt330x_config cxusb_lgdt3303_config = {
540 .demod_chip = LGDT3303,
543 static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
544 .demod_chip = LGDT3303,
545 .clock_polarity_flip = 2,
548 static struct mt352_config cxusb_dee1601_config = {
549 .demod_address = 0x0f,
550 .demod_init = cxusb_dee1601_demod_init,
553 static struct zl10353_config cxusb_zl10353_dee1601_config = {
554 .demod_address = 0x0f,
558 static struct mt352_config cxusb_mt352_config = {
559 /* used in both lgz201 and th7579 */
560 .demod_address = 0x0f,
561 .demod_init = cxusb_mt352_demod_init,
564 static struct zl10353_config cxusb_zl10353_xc3028_config = {
565 .demod_address = 0x0f,
571 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
572 .demod_address = 0x0f,
576 .disable_i2c_gate_ctrl = 1,
579 static struct mt352_config cxusb_mt352_xc3028_config = {
580 .demod_address = 0x0f,
583 .demod_init = cxusb_mt352_demod_init,
586 /* FIXME: needs tweaking */
587 static struct mxl5005s_config aver_a868r_tuner = {
589 .if_freq = 6000000UL,
590 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
591 .agc_mode = MXL_SINGLE_AGC,
592 .tracking_filter = MXL_TF_C,
593 .rssi_enable = MXL_RSSI_ENABLE,
594 .cap_select = MXL_CAP_SEL_ENABLE,
595 .div_out = MXL_DIV_OUT_4,
596 .clock_out = MXL_CLOCK_OUT_DISABLE,
597 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
598 .top = MXL5005S_TOP_25P2,
599 .mod_mode = MXL_DIGITAL_MODE,
600 .if_mode = MXL_ZERO_IF,
601 .AgcMasterByte = 0x00,
604 /* FIXME: needs tweaking */
605 static struct mxl5005s_config d680_dmb_tuner = {
607 .if_freq = 36125000UL,
608 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
609 .agc_mode = MXL_SINGLE_AGC,
610 .tracking_filter = MXL_TF_C,
611 .rssi_enable = MXL_RSSI_ENABLE,
612 .cap_select = MXL_CAP_SEL_ENABLE,
613 .div_out = MXL_DIV_OUT_4,
614 .clock_out = MXL_CLOCK_OUT_DISABLE,
615 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
616 .top = MXL5005S_TOP_25P2,
617 .mod_mode = MXL_DIGITAL_MODE,
618 .if_mode = MXL_ZERO_IF,
619 .AgcMasterByte = 0x00,
622 static struct max2165_config mygica_d689_max2165_cfg = {
627 /* Callbacks for DVB USB */
628 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
630 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
631 &adap->dev->i2c_adap, 0x61,
632 TUNER_PHILIPS_FMD1216ME_MK3);
636 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
638 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61,
639 NULL, DVB_PLL_THOMSON_DTT7579);
643 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
645 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201);
649 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
651 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
652 NULL, DVB_PLL_THOMSON_DTT7579);
656 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
658 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe,
659 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
663 static int dvico_bluebird_xc2028_callback(void *ptr, int component,
664 int command, int arg)
666 struct dvb_usb_adapter *adap = ptr;
667 struct dvb_usb_device *d = adap->dev;
670 case XC2028_TUNER_RESET:
671 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
672 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
674 case XC2028_RESET_CLK:
675 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
677 case XC2028_I2C_FLUSH:
680 deb_info("%s: unknown command %d, arg %d\n", __func__,
688 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
690 struct dvb_frontend *fe;
691 struct xc2028_config cfg = {
692 .i2c_adap = &adap->dev->i2c_adap,
695 static struct xc2028_ctrl ctl = {
696 .fname = XC2028_DEFAULT_FIRMWARE,
698 .demod = XC3028_FE_ZARLINK456,
701 /* FIXME: generalize & move to common area */
702 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback;
704 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg);
705 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
708 fe->ops.tuner_ops.set_config(fe, &ctl);
713 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
715 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
716 &adap->dev->i2c_adap, &aver_a868r_tuner);
720 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
722 struct dvb_frontend *fe;
723 fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe,
724 &adap->dev->i2c_adap, &d680_dmb_tuner);
725 return (fe == NULL) ? -EIO : 0;
728 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
730 struct dvb_frontend *fe;
731 fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe,
732 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
733 return (fe == NULL) ? -EIO : 0;
736 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
739 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
740 err("set interface failed");
742 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
744 adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
745 &adap->dev->i2c_adap);
746 if ((adap->fe_adap[0].fe) != NULL)
752 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
754 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
755 err("set interface failed");
757 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
759 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
760 &cxusb_lgdt3303_config,
762 &adap->dev->i2c_adap);
763 if ((adap->fe_adap[0].fe) != NULL)
769 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
771 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach,
772 &cxusb_aver_lgdt3303_config,
774 &adap->dev->i2c_adap);
775 if (adap->fe_adap[0].fe != NULL)
781 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
783 /* used in both lgz201 and th7579 */
784 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
785 err("set interface failed");
787 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
789 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
790 &adap->dev->i2c_adap);
791 if ((adap->fe_adap[0].fe) != NULL)
797 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
799 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
800 err("set interface failed");
802 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
804 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
805 &adap->dev->i2c_adap);
806 if ((adap->fe_adap[0].fe) != NULL)
809 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
810 &cxusb_zl10353_dee1601_config,
811 &adap->dev->i2c_adap);
812 if ((adap->fe_adap[0].fe) != NULL)
818 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
822 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
823 .buf = ircode, .len = 4 };
825 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
826 err("set interface failed");
828 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
830 /* reset the tuner and demodulator */
831 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
832 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
833 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
835 adap->fe_adap[0].fe =
836 dvb_attach(zl10353_attach,
837 &cxusb_zl10353_xc3028_config_no_i2c_gate,
838 &adap->dev->i2c_adap);
839 if ((adap->fe_adap[0].fe) == NULL)
842 /* try to determine if there is no IR decoder on the I2C bus */
843 for (i = 0; adap->dev->props.rc.core.rc_codes && i < 5; i++) {
845 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
847 if (ircode[0] == 0 && ircode[1] == 0)
849 if (ircode[2] + ircode[3] != 0xff) {
851 adap->dev->props.rc.core.rc_codes = NULL;
852 info("No IR receiver detected on this device.");
860 static struct dibx000_agc_config dib7070_agc_config = {
861 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
864 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
865 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
866 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
868 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
869 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
895 .perform_agc_softsplit = 0,
898 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
911 /* refsel, sel, freq_15k */
912 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
913 .ifreq = (0 << 25) | 0,
918 static struct dib7000p_config cxusb_dualdig4_rev2_config = {
919 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
920 .output_mpeg2_in_188_bytes = 1,
922 .agc_config_count = 1,
923 .agc = &dib7070_agc_config,
924 .bw = &dib7070_bw_config_12_mhz,
925 .tuner_is_baseband = 1,
931 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
933 .hostbus_diversity = 1,
936 struct dib0700_adapter_state {
937 int (*set_param_save)(struct dvb_frontend *);
938 struct dib7000p_ops dib7000p_ops;
941 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
943 struct dib0700_adapter_state *state = adap->priv;
945 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
946 err("set interface failed");
948 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
950 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
952 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops))
955 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
956 &cxusb_dualdig4_rev2_config) < 0) {
957 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
961 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80,
962 &cxusb_dualdig4_rev2_config);
963 if (adap->fe_adap[0].fe == NULL)
969 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
971 struct dvb_usb_adapter *adap = fe->dvb->priv;
972 struct dib0700_adapter_state *state = adap->priv;
974 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff);
977 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
982 static struct dib0070_config dib7070p_dib0070_config = {
983 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
984 .reset = dib7070_tuner_reset,
985 .sleep = dib7070_tuner_sleep,
989 static int dib7070_set_param_override(struct dvb_frontend *fe)
991 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
992 struct dvb_usb_adapter *adap = fe->dvb->priv;
993 struct dib0700_adapter_state *state = adap->priv;
996 u8 band = BAND_OF_FREQUENCY(p->frequency/1000);
998 case BAND_VHF: offset = 950; break;
1000 case BAND_UHF: offset = 550; break;
1003 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1005 return state->set_param_save(fe);
1008 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1010 struct dib0700_adapter_state *st = adap->priv;
1011 struct i2c_adapter *tun_i2c;
1014 * No need to call dvb7000p_attach here, as it was called
1015 * already, as frontend_attach method is called first, and
1016 * tuner_attach is only called on success.
1018 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe,
1019 DIBX000_I2C_INTERFACE_TUNER, 1);
1021 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c,
1022 &dib7070p_dib0070_config) == NULL)
1025 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
1026 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1030 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1032 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1033 err("set interface failed");
1035 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1037 /* reset the tuner and demodulator */
1038 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1039 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1040 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1042 adap->fe_adap[0].fe = dvb_attach(zl10353_attach,
1043 &cxusb_zl10353_xc3028_config,
1044 &adap->dev->i2c_adap);
1045 if ((adap->fe_adap[0].fe) != NULL)
1048 adap->fe_adap[0].fe = dvb_attach(mt352_attach,
1049 &cxusb_mt352_xc3028_config,
1050 &adap->dev->i2c_adap);
1051 if ((adap->fe_adap[0].fe) != NULL)
1057 static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1058 .prod = LGS8GXX_PROD_LGS8GL5,
1059 .demod_address = 0x19,
1063 .if_clk_freq = 30400, /* 30.4 MHz */
1064 .if_freq = 5725, /* 5.725 MHz */
1071 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1073 struct dvb_usb_device *d = adap->dev;
1076 /* Select required USB configuration */
1077 if (usb_set_interface(d->udev, 0, 0) < 0)
1078 err("set interface failed");
1080 /* Unblock all USB pipes */
1081 usb_clear_halt(d->udev,
1082 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1083 usb_clear_halt(d->udev,
1084 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1085 usb_clear_halt(d->udev,
1086 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1088 /* Drain USB pipes to avoid hang after reboot */
1089 for (n = 0; n < 5; n++) {
1090 cxusb_d680_dmb_drain_message(d);
1091 cxusb_d680_dmb_drain_video(d);
1095 /* Reset the tuner */
1096 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1097 err("clear tuner gpio failed");
1101 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1102 err("set tuner gpio failed");
1107 /* Attach frontend */
1108 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1109 if (adap->fe_adap[0].fe == NULL)
1115 static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1116 .prod = ATBM8830_PROD_8830,
1117 .demod_address = 0x40,
1119 .ts_sampling_edge = 1,
1121 .osc_clk_freq = 30400, /* in kHz */
1122 .if_freq = 0, /* zero IF */
1129 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1131 struct dvb_usb_device *d = adap->dev;
1133 /* Select required USB configuration */
1134 if (usb_set_interface(d->udev, 0, 0) < 0)
1135 err("set interface failed");
1137 /* Unblock all USB pipes */
1138 usb_clear_halt(d->udev,
1139 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1140 usb_clear_halt(d->udev,
1141 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1142 usb_clear_halt(d->udev,
1143 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1146 /* Reset the tuner */
1147 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1148 err("clear tuner gpio failed");
1152 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1153 err("set tuner gpio failed");
1158 /* Attach frontend */
1159 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1161 if (adap->fe_adap[0].fe == NULL)
1167 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
1169 struct dvb_usb_device *d = adap->dev;
1170 struct cxusb_state *st = d->priv;
1171 struct i2c_adapter *adapter;
1172 struct i2c_client *client_demod;
1173 struct i2c_client *client_tuner;
1174 struct i2c_board_info info;
1175 struct si2168_config si2168_config;
1176 struct si2157_config si2157_config;
1178 /* Select required USB configuration */
1179 if (usb_set_interface(d->udev, 0, 0) < 0)
1180 err("set interface failed");
1182 /* Unblock all USB pipes */
1183 usb_clear_halt(d->udev,
1184 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1185 usb_clear_halt(d->udev,
1186 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1187 usb_clear_halt(d->udev,
1188 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint));
1190 /* attach frontend */
1191 si2168_config.i2c_adapter = &adapter;
1192 si2168_config.fe = &adap->fe_adap[0].fe;
1193 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1194 si2168_config.ts_clock_inv = 1;
1195 memset(&info, 0, sizeof(struct i2c_board_info));
1196 strscpy(info.type, "si2168", I2C_NAME_SIZE);
1198 info.platform_data = &si2168_config;
1199 request_module(info.type);
1200 client_demod = i2c_new_device(&d->i2c_adap, &info);
1201 if (client_demod == NULL || client_demod->dev.driver == NULL)
1204 if (!try_module_get(client_demod->dev.driver->owner)) {
1205 i2c_unregister_device(client_demod);
1209 st->i2c_client_demod = client_demod;
1212 memset(&si2157_config, 0, sizeof(si2157_config));
1213 si2157_config.fe = adap->fe_adap[0].fe;
1214 si2157_config.if_port = 1;
1215 memset(&info, 0, sizeof(struct i2c_board_info));
1216 strscpy(info.type, "si2157", I2C_NAME_SIZE);
1218 info.platform_data = &si2157_config;
1219 request_module(info.type);
1220 client_tuner = i2c_new_device(adapter, &info);
1221 if (client_tuner == NULL || client_tuner->dev.driver == NULL) {
1222 module_put(client_demod->dev.driver->owner);
1223 i2c_unregister_device(client_demod);
1226 if (!try_module_get(client_tuner->dev.driver->owner)) {
1227 i2c_unregister_device(client_tuner);
1228 module_put(client_demod->dev.driver->owner);
1229 i2c_unregister_device(client_demod);
1233 st->i2c_client_tuner = client_tuner;
1235 /* hook fe: need to resync the slave fifo when signal locks. */
1236 mutex_init(&st->stream_mutex);
1238 st->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
1239 adap->fe_adap[0].fe->ops.read_status = cxusb_read_status;
1245 * DViCO has shipped two devices with the same USB ID, but only one of them
1246 * needs a firmware download. Check the device class details to see if they
1247 * have non-default values to decide whether the device is actually cold or
1248 * not, and forget a match if it turns out we selected the wrong device.
1250 static int bluebird_fx2_identify_state(struct usb_device *udev,
1251 struct dvb_usb_device_properties *props,
1252 struct dvb_usb_device_description **desc,
1255 int wascold = *cold;
1257 *cold = udev->descriptor.bDeviceClass == 0xff &&
1258 udev->descriptor.bDeviceSubClass == 0xff &&
1259 udev->descriptor.bDeviceProtocol == 0xff;
1261 if (*cold && !wascold)
1268 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1269 * firmware file before download.
1272 static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
1273 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1274 const struct firmware *fw)
1278 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1279 int idoff = dvico_firmware_id_offsets[pos];
1281 if (fw->size < idoff + 4)
1284 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1285 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
1286 struct firmware new_fw;
1287 u8 *new_fw_data = vmalloc(fw->size);
1293 memcpy(new_fw_data, fw->data, fw->size);
1294 new_fw.size = fw->size;
1295 new_fw.data = new_fw_data;
1297 new_fw_data[idoff + 2] =
1298 le16_to_cpu(udev->descriptor.idProduct) + 1;
1299 new_fw_data[idoff + 3] =
1300 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1302 ret = usb_cypress_load_firmware(udev, &new_fw,
1312 /* DVB USB Driver stuff */
1313 static struct dvb_usb_device_properties cxusb_medion_properties;
1314 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1315 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1316 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1317 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
1318 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
1319 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
1320 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
1321 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
1322 static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
1323 static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
1324 static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
1325 static struct dvb_usb_device_properties cxusb_mygica_t230_properties;
1327 static int cxusb_probe(struct usb_interface *intf,
1328 const struct usb_device_id *id)
1330 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1331 THIS_MODULE, NULL, adapter_nr) ||
1332 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1333 THIS_MODULE, NULL, adapter_nr) ||
1334 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1335 THIS_MODULE, NULL, adapter_nr) ||
1336 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1337 THIS_MODULE, NULL, adapter_nr) ||
1338 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1339 THIS_MODULE, NULL, adapter_nr) ||
1340 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1341 THIS_MODULE, NULL, adapter_nr) ||
1342 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1343 THIS_MODULE, NULL, adapter_nr) ||
1344 0 == dvb_usb_device_init(intf,
1345 &cxusb_bluebird_nano2_needsfirmware_properties,
1346 THIS_MODULE, NULL, adapter_nr) ||
1347 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1348 THIS_MODULE, NULL, adapter_nr) ||
1349 0 == dvb_usb_device_init(intf,
1350 &cxusb_bluebird_dualdig4_rev2_properties,
1351 THIS_MODULE, NULL, adapter_nr) ||
1352 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1353 THIS_MODULE, NULL, adapter_nr) ||
1354 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1355 THIS_MODULE, NULL, adapter_nr) ||
1356 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties,
1357 THIS_MODULE, NULL, adapter_nr) ||
1364 static void cxusb_disconnect(struct usb_interface *intf)
1366 struct dvb_usb_device *d = usb_get_intfdata(intf);
1367 struct cxusb_state *st = d->priv;
1368 struct i2c_client *client;
1370 /* remove I2C client for tuner */
1371 client = st->i2c_client_tuner;
1373 module_put(client->dev.driver->owner);
1374 i2c_unregister_device(client);
1377 /* remove I2C client for demodulator */
1378 client = st->i2c_client_demod;
1380 module_put(client->dev.driver->owner);
1381 i2c_unregister_device(client);
1384 dvb_usb_device_exit(intf);
1387 enum cxusb_table_index {
1389 DVICO_BLUEBIRD_LG064F_COLD,
1390 DVICO_BLUEBIRD_LG064F_WARM,
1391 DVICO_BLUEBIRD_DUAL_1_COLD,
1392 DVICO_BLUEBIRD_DUAL_1_WARM,
1393 DVICO_BLUEBIRD_LGZ201_COLD,
1394 DVICO_BLUEBIRD_LGZ201_WARM,
1395 DVICO_BLUEBIRD_TH7579_COLD,
1396 DVICO_BLUEBIRD_TH7579_WARM,
1397 DIGITALNOW_BLUEBIRD_DUAL_1_COLD,
1398 DIGITALNOW_BLUEBIRD_DUAL_1_WARM,
1399 DVICO_BLUEBIRD_DUAL_2_COLD,
1400 DVICO_BLUEBIRD_DUAL_2_WARM,
1401 DVICO_BLUEBIRD_DUAL_4,
1402 DVICO_BLUEBIRD_DVB_T_NANO_2,
1403 DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM,
1404 AVERMEDIA_VOLAR_A868R,
1405 DVICO_BLUEBIRD_DUAL_4_REV_2,
1409 NR__cxusb_table_index
1412 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = {
1413 [MEDION_MD95700] = {
1414 USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700)
1416 [DVICO_BLUEBIRD_LG064F_COLD] = {
1417 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD)
1419 [DVICO_BLUEBIRD_LG064F_WARM] = {
1420 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM)
1422 [DVICO_BLUEBIRD_DUAL_1_COLD] = {
1423 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD)
1425 [DVICO_BLUEBIRD_DUAL_1_WARM] = {
1426 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM)
1428 [DVICO_BLUEBIRD_LGZ201_COLD] = {
1429 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD)
1431 [DVICO_BLUEBIRD_LGZ201_WARM] = {
1432 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM)
1434 [DVICO_BLUEBIRD_TH7579_COLD] = {
1435 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD)
1437 [DVICO_BLUEBIRD_TH7579_WARM] = {
1438 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM)
1440 [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = {
1441 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD)
1443 [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = {
1444 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM)
1446 [DVICO_BLUEBIRD_DUAL_2_COLD] = {
1447 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD)
1449 [DVICO_BLUEBIRD_DUAL_2_WARM] = {
1450 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM)
1452 [DVICO_BLUEBIRD_DUAL_4] = {
1453 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4)
1455 [DVICO_BLUEBIRD_DVB_T_NANO_2] = {
1456 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2)
1458 [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = {
1459 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM)
1461 [AVERMEDIA_VOLAR_A868R] = {
1462 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R)
1464 [DVICO_BLUEBIRD_DUAL_4_REV_2] = {
1465 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2)
1467 [CONEXANT_D680_DMB] = {
1468 USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB)
1471 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689)
1474 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230)
1476 {} /* Terminating entry */
1478 MODULE_DEVICE_TABLE (usb, cxusb_table);
1480 static struct dvb_usb_device_properties cxusb_medion_properties = {
1481 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1483 .usb_ctrl = CYPRESS_FX2,
1485 .size_of_priv = sizeof(struct cxusb_state),
1492 .streaming_ctrl = cxusb_streaming_ctrl,
1493 .frontend_attach = cxusb_cx22702_frontend_attach,
1494 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1495 /* parameter for the MPEG2-data transfer */
1509 .power_ctrl = cxusb_power_ctrl,
1511 .i2c_algo = &cxusb_i2c_algo,
1513 .generic_bulk_ctrl_endpoint = 0x01,
1515 .num_device_descs = 1,
1517 { "Medion MD95700 (MDUSBTV-HYBRID)",
1519 { &cxusb_table[MEDION_MD95700], NULL },
1524 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1525 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1527 .usb_ctrl = DEVICE_SPECIFIC,
1528 .firmware = "dvb-usb-bluebird-01.fw",
1529 .download_firmware = bluebird_patch_dvico_firmware_download,
1530 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1531 use usb alt setting 7 for EP2 transfer (atsc) */
1533 .size_of_priv = sizeof(struct cxusb_state),
1540 .streaming_ctrl = cxusb_streaming_ctrl,
1541 .frontend_attach = cxusb_lgdt3303_frontend_attach,
1542 .tuner_attach = cxusb_lgh064f_tuner_attach,
1544 /* parameter for the MPEG2-data transfer */
1559 .power_ctrl = cxusb_bluebird_power_ctrl,
1561 .i2c_algo = &cxusb_i2c_algo,
1565 .rc_codes = RC_MAP_DVICO_PORTABLE,
1566 .module_name = KBUILD_MODNAME,
1567 .rc_query = cxusb_rc_query,
1568 .allowed_protos = RC_PROTO_BIT_NEC,
1571 .generic_bulk_ctrl_endpoint = 0x01,
1573 .num_device_descs = 1,
1575 { "DViCO FusionHDTV5 USB Gold",
1576 { &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL },
1577 { &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL },
1582 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1583 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1585 .usb_ctrl = DEVICE_SPECIFIC,
1586 .firmware = "dvb-usb-bluebird-01.fw",
1587 .download_firmware = bluebird_patch_dvico_firmware_download,
1588 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1589 use usb alt setting 7 for EP2 transfer (atsc) */
1591 .size_of_priv = sizeof(struct cxusb_state),
1598 .streaming_ctrl = cxusb_streaming_ctrl,
1599 .frontend_attach = cxusb_dee1601_frontend_attach,
1600 .tuner_attach = cxusb_dee1601_tuner_attach,
1601 /* parameter for the MPEG2-data transfer */
1616 .power_ctrl = cxusb_bluebird_power_ctrl,
1618 .i2c_algo = &cxusb_i2c_algo,
1622 .rc_codes = RC_MAP_DVICO_MCE,
1623 .module_name = KBUILD_MODNAME,
1624 .rc_query = cxusb_rc_query,
1625 .allowed_protos = RC_PROTO_BIT_NEC,
1628 .generic_bulk_ctrl_endpoint = 0x01,
1630 .num_device_descs = 3,
1632 { "DViCO FusionHDTV DVB-T Dual USB",
1633 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL },
1634 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL },
1636 { "DigitalNow DVB-T Dual USB",
1637 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD], NULL },
1638 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL },
1640 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1641 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL },
1642 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL },
1647 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1648 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1650 .usb_ctrl = DEVICE_SPECIFIC,
1651 .firmware = "dvb-usb-bluebird-01.fw",
1652 .download_firmware = bluebird_patch_dvico_firmware_download,
1653 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1654 use usb alt setting 7 for EP2 transfer (atsc) */
1656 .size_of_priv = sizeof(struct cxusb_state),
1663 .streaming_ctrl = cxusb_streaming_ctrl,
1664 .frontend_attach = cxusb_mt352_frontend_attach,
1665 .tuner_attach = cxusb_lgz201_tuner_attach,
1667 /* parameter for the MPEG2-data transfer */
1681 .power_ctrl = cxusb_bluebird_power_ctrl,
1683 .i2c_algo = &cxusb_i2c_algo,
1687 .rc_codes = RC_MAP_DVICO_PORTABLE,
1688 .module_name = KBUILD_MODNAME,
1689 .rc_query = cxusb_rc_query,
1690 .allowed_protos = RC_PROTO_BIT_NEC,
1693 .generic_bulk_ctrl_endpoint = 0x01,
1694 .num_device_descs = 1,
1696 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1697 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL },
1698 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL },
1703 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1704 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1706 .usb_ctrl = DEVICE_SPECIFIC,
1707 .firmware = "dvb-usb-bluebird-01.fw",
1708 .download_firmware = bluebird_patch_dvico_firmware_download,
1709 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1710 use usb alt setting 7 for EP2 transfer (atsc) */
1712 .size_of_priv = sizeof(struct cxusb_state),
1719 .streaming_ctrl = cxusb_streaming_ctrl,
1720 .frontend_attach = cxusb_mt352_frontend_attach,
1721 .tuner_attach = cxusb_dtt7579_tuner_attach,
1723 /* parameter for the MPEG2-data transfer */
1737 .power_ctrl = cxusb_bluebird_power_ctrl,
1739 .i2c_algo = &cxusb_i2c_algo,
1743 .rc_codes = RC_MAP_DVICO_PORTABLE,
1744 .module_name = KBUILD_MODNAME,
1745 .rc_query = cxusb_rc_query,
1746 .allowed_protos = RC_PROTO_BIT_NEC,
1749 .generic_bulk_ctrl_endpoint = 0x01,
1751 .num_device_descs = 1,
1753 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1754 { &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL },
1755 { &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL },
1760 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1761 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1763 .usb_ctrl = CYPRESS_FX2,
1765 .size_of_priv = sizeof(struct cxusb_state),
1772 .streaming_ctrl = cxusb_streaming_ctrl,
1773 .frontend_attach = cxusb_dualdig4_frontend_attach,
1774 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1775 /* parameter for the MPEG2-data transfer */
1790 .power_ctrl = cxusb_power_ctrl,
1792 .i2c_algo = &cxusb_i2c_algo,
1794 .generic_bulk_ctrl_endpoint = 0x01,
1798 .rc_codes = RC_MAP_DVICO_MCE,
1799 .module_name = KBUILD_MODNAME,
1800 .rc_query = cxusb_bluebird2_rc_query,
1801 .allowed_protos = RC_PROTO_BIT_NEC,
1804 .num_device_descs = 1,
1806 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1808 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL },
1813 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1814 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1816 .usb_ctrl = CYPRESS_FX2,
1817 .identify_state = bluebird_fx2_identify_state,
1819 .size_of_priv = sizeof(struct cxusb_state),
1826 .streaming_ctrl = cxusb_streaming_ctrl,
1827 .frontend_attach = cxusb_nano2_frontend_attach,
1828 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1829 /* parameter for the MPEG2-data transfer */
1844 .power_ctrl = cxusb_nano2_power_ctrl,
1846 .i2c_algo = &cxusb_i2c_algo,
1848 .generic_bulk_ctrl_endpoint = 0x01,
1852 .rc_codes = RC_MAP_DVICO_PORTABLE,
1853 .module_name = KBUILD_MODNAME,
1854 .rc_query = cxusb_bluebird2_rc_query,
1855 .allowed_protos = RC_PROTO_BIT_NEC,
1858 .num_device_descs = 1,
1860 { "DViCO FusionHDTV DVB-T NANO2",
1862 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
1867 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1868 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1870 .usb_ctrl = DEVICE_SPECIFIC,
1871 .firmware = "dvb-usb-bluebird-02.fw",
1872 .download_firmware = bluebird_patch_dvico_firmware_download,
1873 .identify_state = bluebird_fx2_identify_state,
1875 .size_of_priv = sizeof(struct cxusb_state),
1882 .streaming_ctrl = cxusb_streaming_ctrl,
1883 .frontend_attach = cxusb_nano2_frontend_attach,
1884 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1885 /* parameter for the MPEG2-data transfer */
1900 .power_ctrl = cxusb_nano2_power_ctrl,
1902 .i2c_algo = &cxusb_i2c_algo,
1904 .generic_bulk_ctrl_endpoint = 0x01,
1908 .rc_codes = RC_MAP_DVICO_PORTABLE,
1909 .module_name = KBUILD_MODNAME,
1910 .rc_query = cxusb_rc_query,
1911 .allowed_protos = RC_PROTO_BIT_NEC,
1914 .num_device_descs = 1,
1916 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1917 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL },
1918 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL },
1923 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
1924 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1926 .usb_ctrl = CYPRESS_FX2,
1928 .size_of_priv = sizeof(struct cxusb_state),
1935 .streaming_ctrl = cxusb_aver_streaming_ctrl,
1936 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
1937 .tuner_attach = cxusb_mxl5003s_tuner_attach,
1938 /* parameter for the MPEG2-data transfer */
1952 .power_ctrl = cxusb_aver_power_ctrl,
1954 .i2c_algo = &cxusb_i2c_algo,
1956 .generic_bulk_ctrl_endpoint = 0x01,
1958 .num_device_descs = 1,
1960 { "AVerMedia AVerTVHD Volar (A868R)",
1962 { &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL },
1968 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
1969 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1971 .usb_ctrl = CYPRESS_FX2,
1973 .size_of_priv = sizeof(struct cxusb_state),
1978 .size_of_priv = sizeof(struct dib0700_adapter_state),
1981 .streaming_ctrl = cxusb_streaming_ctrl,
1982 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
1983 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
1984 /* parameter for the MPEG2-data transfer */
1999 .power_ctrl = cxusb_bluebird_power_ctrl,
2001 .i2c_algo = &cxusb_i2c_algo,
2003 .generic_bulk_ctrl_endpoint = 0x01,
2007 .rc_codes = RC_MAP_DVICO_MCE,
2008 .module_name = KBUILD_MODNAME,
2009 .rc_query = cxusb_rc_query,
2010 .allowed_protos = RC_PROTO_BIT_NEC,
2013 .num_device_descs = 1,
2015 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
2017 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL },
2022 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2023 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2025 .usb_ctrl = CYPRESS_FX2,
2027 .size_of_priv = sizeof(struct cxusb_state),
2034 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2035 .frontend_attach = cxusb_d680_dmb_frontend_attach,
2036 .tuner_attach = cxusb_d680_dmb_tuner_attach,
2038 /* parameter for the MPEG2-data transfer */
2053 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2055 .i2c_algo = &cxusb_i2c_algo,
2057 .generic_bulk_ctrl_endpoint = 0x01,
2061 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2062 .module_name = KBUILD_MODNAME,
2063 .rc_query = cxusb_d680_dmb_rc_query,
2064 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2067 .num_device_descs = 1,
2070 "Conexant DMB-TH Stick",
2072 { &cxusb_table[CONEXANT_D680_DMB], NULL },
2077 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2078 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2080 .usb_ctrl = CYPRESS_FX2,
2082 .size_of_priv = sizeof(struct cxusb_state),
2089 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
2090 .frontend_attach = cxusb_mygica_d689_frontend_attach,
2091 .tuner_attach = cxusb_mygica_d689_tuner_attach,
2093 /* parameter for the MPEG2-data transfer */
2108 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2110 .i2c_algo = &cxusb_i2c_algo,
2112 .generic_bulk_ctrl_endpoint = 0x01,
2116 .rc_codes = RC_MAP_D680_DMB,
2117 .module_name = KBUILD_MODNAME,
2118 .rc_query = cxusb_d680_dmb_rc_query,
2119 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2122 .num_device_descs = 1,
2125 "Mygica D689 DMB-TH",
2127 { &cxusb_table[MYGICA_D689], NULL },
2132 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2133 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
2135 .usb_ctrl = CYPRESS_FX2,
2137 .size_of_priv = sizeof(struct cxusb_state),
2144 .streaming_ctrl = cxusb_streaming_ctrl,
2145 .frontend_attach = cxusb_mygica_t230_frontend_attach,
2147 /* parameter for the MPEG2-data transfer */
2162 .power_ctrl = cxusb_d680_dmb_power_ctrl,
2164 .i2c_algo = &cxusb_i2c_algo,
2166 .generic_bulk_ctrl_endpoint = 0x01,
2170 .rc_codes = RC_MAP_D680_DMB,
2171 .module_name = KBUILD_MODNAME,
2172 .rc_query = cxusb_d680_dmb_rc_query,
2173 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2176 .num_device_descs = 1,
2179 "Mygica T230 DVB-T/T2/C",
2181 { &cxusb_table[MYGICA_T230], NULL },
2186 static struct usb_driver cxusb_driver = {
2187 .name = "dvb_usb_cxusb",
2188 .probe = cxusb_probe,
2189 .disconnect = cxusb_disconnect,
2190 .id_table = cxusb_table,
2193 module_usb_driver(cxusb_driver);
2195 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
2196 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
2197 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
2198 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
2199 MODULE_VERSION("1.0-alpha");
2200 MODULE_LICENSE("GPL");