1 /* DVB USB compliant linux driver for Conexant USB reference design. 2 * 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. 8 * 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 12 * appear at all). 13 * 14 * TODO: Use the cx25840-driver for the analogue part 15 * 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) 19 * 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. 23 * 24 * see Documentation/dvb/README.dvb-usb for more information 25 */ 26 #include <media/tuner.h> 27 #include <linux/vmalloc.h> 28 #include <linux/slab.h> 29 30 #include "cxusb.h" 31 32 #include "cx22702.h" 33 #include "lgdt330x.h" 34 #include "mt352.h" 35 #include "mt352_priv.h" 36 #include "zl10353.h" 37 #include "tuner-xc2028.h" 38 #include "tuner-simple.h" 39 #include "mxl5005s.h" 40 #include "max2165.h" 41 #include "dib7000p.h" 42 #include "dib0070.h" 43 #include "lgs8gxx.h" 44 #include "atbm8830.h" 45 #include "si2168.h" 46 #include "si2157.h" 47 48 /* debug */ 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); 52 53 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 54 55 #define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args) 56 #define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args) 57 58 static int cxusb_ctrl_msg(struct dvb_usb_device *d, 59 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) 60 { 61 struct cxusb_state *st = d->priv; 62 int ret, wo; 63 64 if (1 + wlen > MAX_XFER_SIZE) { 65 warn("i2c wr: len=%d is too big!\n", wlen); 66 return -EOPNOTSUPP; 67 } 68 69 wo = (rbuf == NULL || rlen == 0); /* write-only */ 70 71 mutex_lock(&d->data_mutex); 72 st->data[0] = cmd; 73 memcpy(&st->data[1], wbuf, wlen); 74 if (wo) 75 ret = dvb_usb_generic_write(d, st->data, 1 + wlen); 76 else 77 ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, 78 rbuf, rlen, 0); 79 80 mutex_unlock(&d->data_mutex); 81 return ret; 82 } 83 84 /* GPIO */ 85 static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff) 86 { 87 struct cxusb_state *st = d->priv; 88 u8 o[2], i; 89 90 if (st->gpio_write_state[GPIO_TUNER] == onoff) 91 return; 92 93 o[0] = GPIO_TUNER; 94 o[1] = onoff; 95 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1); 96 97 if (i != 0x01) 98 deb_info("gpio_write failed.\n"); 99 100 st->gpio_write_state[GPIO_TUNER] = onoff; 101 } 102 103 static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask, 104 u8 newval) 105 { 106 u8 o[2], gpio_state; 107 int rc; 108 109 o[0] = 0xff & ~changemask; /* mask of bits to keep */ 110 o[1] = newval & changemask; /* new values for bits */ 111 112 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1); 113 if (rc < 0 || (gpio_state & changemask) != (newval & changemask)) 114 deb_info("bluebird_gpio_write failed.\n"); 115 116 return rc < 0 ? rc : gpio_state; 117 } 118 119 static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low) 120 { 121 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin); 122 msleep(5); 123 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0); 124 } 125 126 static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff) 127 { 128 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40); 129 } 130 131 static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d, 132 u8 addr, int onoff) 133 { 134 u8 o[2] = {addr, onoff}; 135 u8 i; 136 int rc; 137 138 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1); 139 140 if (rc < 0) 141 return rc; 142 if (i == 0x01) 143 return 0; 144 else { 145 deb_info("gpio_write failed.\n"); 146 return -EIO; 147 } 148 } 149 150 /* I2C */ 151 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], 152 int num) 153 { 154 struct dvb_usb_device *d = i2c_get_adapdata(adap); 155 int ret; 156 int i; 157 158 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 159 return -EAGAIN; 160 161 for (i = 0; i < num; i++) { 162 163 if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_MEDION) 164 switch (msg[i].addr) { 165 case 0x63: 166 cxusb_gpio_tuner(d, 0); 167 break; 168 default: 169 cxusb_gpio_tuner(d, 1); 170 break; 171 } 172 173 if (msg[i].flags & I2C_M_RD) { 174 /* read only */ 175 u8 obuf[3], ibuf[MAX_XFER_SIZE]; 176 177 if (1 + msg[i].len > sizeof(ibuf)) { 178 warn("i2c rd: len=%d is too big!\n", 179 msg[i].len); 180 ret = -EOPNOTSUPP; 181 goto unlock; 182 } 183 obuf[0] = 0; 184 obuf[1] = msg[i].len; 185 obuf[2] = msg[i].addr; 186 if (cxusb_ctrl_msg(d, CMD_I2C_READ, 187 obuf, 3, 188 ibuf, 1+msg[i].len) < 0) { 189 warn("i2c read failed"); 190 break; 191 } 192 memcpy(msg[i].buf, &ibuf[1], msg[i].len); 193 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) && 194 msg[i].addr == msg[i+1].addr) { 195 /* write to then read from same address */ 196 u8 obuf[MAX_XFER_SIZE], ibuf[MAX_XFER_SIZE]; 197 198 if (3 + msg[i].len > sizeof(obuf)) { 199 warn("i2c wr: len=%d is too big!\n", 200 msg[i].len); 201 ret = -EOPNOTSUPP; 202 goto unlock; 203 } 204 if (1 + msg[i + 1].len > sizeof(ibuf)) { 205 warn("i2c rd: len=%d is too big!\n", 206 msg[i + 1].len); 207 ret = -EOPNOTSUPP; 208 goto unlock; 209 } 210 obuf[0] = msg[i].len; 211 obuf[1] = msg[i+1].len; 212 obuf[2] = msg[i].addr; 213 memcpy(&obuf[3], msg[i].buf, msg[i].len); 214 215 if (cxusb_ctrl_msg(d, CMD_I2C_READ, 216 obuf, 3+msg[i].len, 217 ibuf, 1+msg[i+1].len) < 0) 218 break; 219 220 if (ibuf[0] != 0x08) 221 deb_i2c("i2c read may have failed\n"); 222 223 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len); 224 225 i++; 226 } else { 227 /* write only */ 228 u8 obuf[MAX_XFER_SIZE], ibuf; 229 230 if (2 + msg[i].len > sizeof(obuf)) { 231 warn("i2c wr: len=%d is too big!\n", 232 msg[i].len); 233 ret = -EOPNOTSUPP; 234 goto unlock; 235 } 236 obuf[0] = msg[i].addr; 237 obuf[1] = msg[i].len; 238 memcpy(&obuf[2], msg[i].buf, msg[i].len); 239 240 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf, 241 2+msg[i].len, &ibuf,1) < 0) 242 break; 243 if (ibuf != 0x08) 244 deb_i2c("i2c write may have failed\n"); 245 } 246 } 247 248 if (i == num) 249 ret = num; 250 else 251 ret = -EREMOTEIO; 252 253 unlock: 254 mutex_unlock(&d->i2c_mutex); 255 return ret; 256 } 257 258 static u32 cxusb_i2c_func(struct i2c_adapter *adapter) 259 { 260 return I2C_FUNC_I2C; 261 } 262 263 static struct i2c_algorithm cxusb_i2c_algo = { 264 .master_xfer = cxusb_i2c_xfer, 265 .functionality = cxusb_i2c_func, 266 }; 267 268 static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) 269 { 270 u8 b = 0; 271 if (onoff) 272 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); 273 else 274 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); 275 } 276 277 static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff) 278 { 279 int ret; 280 if (!onoff) 281 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0); 282 if (d->state == DVB_USB_STATE_INIT && 283 usb_set_interface(d->udev, 0, 0) < 0) 284 err("set interface failed"); 285 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) && 286 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) && 287 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0); 288 if (!ret) { 289 /* FIXME: We don't know why, but we need to configure the 290 * lgdt3303 with the register settings below on resume */ 291 int i; 292 u8 buf, 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, 303 }; 304 msleep(20); 305 for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) { 306 ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE, 307 bufs+i, 4, &buf, 1); 308 if (ret) 309 break; 310 if (buf != 0x8) 311 return -EREMOTEIO; 312 } 313 } 314 return ret; 315 } 316 317 static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff) 318 { 319 u8 b = 0; 320 if (onoff) 321 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); 322 else 323 return 0; 324 } 325 326 static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff) 327 { 328 int rc = 0; 329 330 rc = cxusb_power_ctrl(d, onoff); 331 if (!onoff) 332 cxusb_nano2_led(d, 0); 333 334 return rc; 335 } 336 337 static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff) 338 { 339 int ret; 340 u8 b; 341 ret = cxusb_power_ctrl(d, onoff); 342 if (!onoff) 343 return ret; 344 345 msleep(128); 346 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1); 347 msleep(100); 348 return ret; 349 } 350 351 static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 352 { 353 u8 buf[2] = { 0x03, 0x00 }; 354 if (onoff) 355 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0); 356 else 357 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0); 358 359 return 0; 360 } 361 362 static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 363 { 364 if (onoff) 365 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0); 366 else 367 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF, 368 NULL, 0, NULL, 0); 369 return 0; 370 } 371 372 static int cxusb_read_status(struct dvb_frontend *fe, 373 enum fe_status *status) 374 { 375 struct dvb_usb_adapter *adap = (struct dvb_usb_adapter *)fe->dvb->priv; 376 struct cxusb_state *state = (struct cxusb_state *)adap->dev->priv; 377 int ret; 378 379 ret = state->fe_read_status(fe, status); 380 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); 386 } 387 388 state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0; 389 return ret; 390 } 391 392 static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d) 393 { 394 int ep = d->props.generic_bulk_ctrl_endpoint; 395 const int timeout = 100; 396 const int junk_len = 32; 397 u8 *junk; 398 int rd_count; 399 400 /* Discard remaining data in video pipe */ 401 junk = kmalloc(junk_len, GFP_KERNEL); 402 if (!junk) 403 return; 404 while (1) { 405 if (usb_bulk_msg(d->udev, 406 usb_rcvbulkpipe(d->udev, ep), 407 junk, junk_len, &rd_count, timeout) < 0) 408 break; 409 if (!rd_count) 410 break; 411 } 412 kfree(junk); 413 } 414 415 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d) 416 { 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; 420 u8 *junk; 421 int rd_count; 422 423 /* Discard remaining data in video pipe */ 424 junk = kmalloc(junk_len, GFP_KERNEL); 425 if (!junk) 426 return; 427 while (1) { 428 if (usb_bulk_msg(d->udev, 429 usb_rcvbulkpipe(d->udev, p->endpoint), 430 junk, junk_len, &rd_count, timeout) < 0) 431 break; 432 if (!rd_count) 433 break; 434 } 435 kfree(junk); 436 } 437 438 static int cxusb_d680_dmb_streaming_ctrl( 439 struct dvb_usb_adapter *adap, int onoff) 440 { 441 if (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); 446 } else { 447 int ret = cxusb_ctrl_msg(adap->dev, 448 CMD_STREAMING_OFF, NULL, 0, NULL, 0); 449 return ret; 450 } 451 } 452 453 static int cxusb_rc_query(struct dvb_usb_device *d) 454 { 455 u8 ircode[4]; 456 457 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4); 458 459 if (ircode[2] || ircode[3]) 460 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, 461 RC_SCANCODE_RC5(ircode[2], ircode[3]), 0); 462 return 0; 463 } 464 465 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d) 466 { 467 u8 ircode[4]; 468 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, 469 .buf = ircode, .len = 4 }; 470 471 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1) 472 return 0; 473 474 if (ircode[1] || ircode[2]) 475 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, 476 RC_SCANCODE_RC5(ircode[1], ircode[2]), 0); 477 return 0; 478 } 479 480 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d) 481 { 482 u8 ircode[2]; 483 484 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0) 485 return 0; 486 487 if (ircode[0] || ircode[1]) 488 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, 489 RC_SCANCODE_RC5(ircode[0], ircode[1]), 0); 490 return 0; 491 } 492 493 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 494 { 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 }; 501 502 mt352_write(fe, clock_config, sizeof(clock_config)); 503 udelay(200); 504 mt352_write(fe, reset, sizeof(reset)); 505 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 506 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)); 510 511 return 0; 512 } 513 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 }; 522 523 mt352_write(fe, clock_config, sizeof(clock_config)); 524 udelay(200); 525 mt352_write(fe, reset, sizeof(reset)); 526 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 527 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)); 531 return 0; 532 } 533 534 static struct cx22702_config cxusb_cx22702_config = { 535 .demod_address = 0x63, 536 .output_mode = CX22702_PARALLEL_OUTPUT, 537 }; 538 539 static struct lgdt330x_config cxusb_lgdt3303_config = { 540 .demod_address = 0x0e, 541 .demod_chip = LGDT3303, 542 }; 543 544 static struct lgdt330x_config cxusb_aver_lgdt3303_config = { 545 .demod_address = 0x0e, 546 .demod_chip = LGDT3303, 547 .clock_polarity_flip = 2, 548 }; 549 550 static struct mt352_config cxusb_dee1601_config = { 551 .demod_address = 0x0f, 552 .demod_init = cxusb_dee1601_demod_init, 553 }; 554 555 static struct zl10353_config cxusb_zl10353_dee1601_config = { 556 .demod_address = 0x0f, 557 .parallel_ts = 1, 558 }; 559 560 static struct mt352_config cxusb_mt352_config = { 561 /* used in both lgz201 and th7579 */ 562 .demod_address = 0x0f, 563 .demod_init = cxusb_mt352_demod_init, 564 }; 565 566 static struct zl10353_config cxusb_zl10353_xc3028_config = { 567 .demod_address = 0x0f, 568 .if2 = 45600, 569 .no_tuner = 1, 570 .parallel_ts = 1, 571 }; 572 573 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = { 574 .demod_address = 0x0f, 575 .if2 = 45600, 576 .no_tuner = 1, 577 .parallel_ts = 1, 578 .disable_i2c_gate_ctrl = 1, 579 }; 580 581 static struct mt352_config cxusb_mt352_xc3028_config = { 582 .demod_address = 0x0f, 583 .if2 = 4560, 584 .no_tuner = 1, 585 .demod_init = cxusb_mt352_demod_init, 586 }; 587 588 /* FIXME: needs tweaking */ 589 static struct mxl5005s_config aver_a868r_tuner = { 590 .i2c_address = 0x63, 591 .if_freq = 6000000UL, 592 .xtal_freq = CRYSTAL_FREQ_16000000HZ, 593 .agc_mode = MXL_SINGLE_AGC, 594 .tracking_filter = MXL_TF_C, 595 .rssi_enable = MXL_RSSI_ENABLE, 596 .cap_select = MXL_CAP_SEL_ENABLE, 597 .div_out = MXL_DIV_OUT_4, 598 .clock_out = MXL_CLOCK_OUT_DISABLE, 599 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, 600 .top = MXL5005S_TOP_25P2, 601 .mod_mode = MXL_DIGITAL_MODE, 602 .if_mode = MXL_ZERO_IF, 603 .AgcMasterByte = 0x00, 604 }; 605 606 /* FIXME: needs tweaking */ 607 static struct mxl5005s_config d680_dmb_tuner = { 608 .i2c_address = 0x63, 609 .if_freq = 36125000UL, 610 .xtal_freq = CRYSTAL_FREQ_16000000HZ, 611 .agc_mode = MXL_SINGLE_AGC, 612 .tracking_filter = MXL_TF_C, 613 .rssi_enable = MXL_RSSI_ENABLE, 614 .cap_select = MXL_CAP_SEL_ENABLE, 615 .div_out = MXL_DIV_OUT_4, 616 .clock_out = MXL_CLOCK_OUT_DISABLE, 617 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, 618 .top = MXL5005S_TOP_25P2, 619 .mod_mode = MXL_DIGITAL_MODE, 620 .if_mode = MXL_ZERO_IF, 621 .AgcMasterByte = 0x00, 622 }; 623 624 static struct max2165_config mygica_d689_max2165_cfg = { 625 .i2c_address = 0x60, 626 .osc_clk = 20 627 }; 628 629 /* Callbacks for DVB USB */ 630 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) 631 { 632 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe, 633 &adap->dev->i2c_adap, 0x61, 634 TUNER_PHILIPS_FMD1216ME_MK3); 635 return 0; 636 } 637 638 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap) 639 { 640 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, 641 NULL, DVB_PLL_THOMSON_DTT7579); 642 return 0; 643 } 644 645 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap) 646 { 647 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201); 648 return 0; 649 } 650 651 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap) 652 { 653 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 654 NULL, DVB_PLL_THOMSON_DTT7579); 655 return 0; 656 } 657 658 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap) 659 { 660 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe, 661 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF); 662 return 0; 663 } 664 665 static int dvico_bluebird_xc2028_callback(void *ptr, int component, 666 int command, int arg) 667 { 668 struct dvb_usb_adapter *adap = ptr; 669 struct dvb_usb_device *d = adap->dev; 670 671 switch (command) { 672 case XC2028_TUNER_RESET: 673 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg); 674 cxusb_bluebird_gpio_pulse(d, 0x01, 1); 675 break; 676 case XC2028_RESET_CLK: 677 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg); 678 break; 679 default: 680 deb_info("%s: unknown command %d, arg %d\n", __func__, 681 command, arg); 682 return -EINVAL; 683 } 684 685 return 0; 686 } 687 688 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap) 689 { 690 struct dvb_frontend *fe; 691 struct xc2028_config cfg = { 692 .i2c_adap = &adap->dev->i2c_adap, 693 .i2c_addr = 0x61, 694 }; 695 static struct xc2028_ctrl ctl = { 696 .fname = XC2028_DEFAULT_FIRMWARE, 697 .max_len = 64, 698 .demod = XC3028_FE_ZARLINK456, 699 }; 700 701 /* FIXME: generalize & move to common area */ 702 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback; 703 704 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg); 705 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL) 706 return -EIO; 707 708 fe->ops.tuner_ops.set_config(fe, &ctl); 709 710 return 0; 711 } 712 713 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap) 714 { 715 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, 716 &adap->dev->i2c_adap, &aver_a868r_tuner); 717 return 0; 718 } 719 720 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap) 721 { 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; 726 } 727 728 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap) 729 { 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; 734 } 735 736 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap) 737 { 738 u8 b; 739 if (usb_set_interface(adap->dev->udev, 0, 6) < 0) 740 err("set interface failed"); 741 742 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1); 743 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) 747 return 0; 748 749 return -EIO; 750 } 751 752 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap) 753 { 754 if (usb_set_interface(adap->dev->udev, 0, 7) < 0) 755 err("set interface failed"); 756 757 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 758 759 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, 760 &cxusb_lgdt3303_config, 761 &adap->dev->i2c_adap); 762 if ((adap->fe_adap[0].fe) != NULL) 763 return 0; 764 765 return -EIO; 766 } 767 768 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap) 769 { 770 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config, 771 &adap->dev->i2c_adap); 772 if (adap->fe_adap[0].fe != NULL) 773 return 0; 774 775 return -EIO; 776 } 777 778 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap) 779 { 780 /* used in both lgz201 and th7579 */ 781 if (usb_set_interface(adap->dev->udev, 0, 0) < 0) 782 err("set interface failed"); 783 784 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 785 786 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config, 787 &adap->dev->i2c_adap); 788 if ((adap->fe_adap[0].fe) != NULL) 789 return 0; 790 791 return -EIO; 792 } 793 794 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap) 795 { 796 if (usb_set_interface(adap->dev->udev, 0, 0) < 0) 797 err("set interface failed"); 798 799 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 800 801 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, 802 &adap->dev->i2c_adap); 803 if ((adap->fe_adap[0].fe) != NULL) 804 return 0; 805 806 adap->fe_adap[0].fe = dvb_attach(zl10353_attach, 807 &cxusb_zl10353_dee1601_config, 808 &adap->dev->i2c_adap); 809 if ((adap->fe_adap[0].fe) != NULL) 810 return 0; 811 812 return -EIO; 813 } 814 815 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap) 816 { 817 u8 ircode[4]; 818 int i; 819 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, 820 .buf = ircode, .len = 4 }; 821 822 if (usb_set_interface(adap->dev->udev, 0, 1) < 0) 823 err("set interface failed"); 824 825 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 826 827 /* reset the tuner and demodulator */ 828 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0); 829 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1); 830 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 831 832 adap->fe_adap[0].fe = 833 dvb_attach(zl10353_attach, 834 &cxusb_zl10353_xc3028_config_no_i2c_gate, 835 &adap->dev->i2c_adap); 836 if ((adap->fe_adap[0].fe) == NULL) 837 return -EIO; 838 839 /* try to determine if there is no IR decoder on the I2C bus */ 840 for (i = 0; adap->dev->props.rc.core.rc_codes && i < 5; i++) { 841 msleep(20); 842 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1) 843 goto no_IR; 844 if (ircode[0] == 0 && ircode[1] == 0) 845 continue; 846 if (ircode[2] + ircode[3] != 0xff) { 847 no_IR: 848 adap->dev->props.rc.core.rc_codes = NULL; 849 info("No IR receiver detected on this device."); 850 break; 851 } 852 } 853 854 return 0; 855 } 856 857 static struct dibx000_agc_config dib7070_agc_config = { 858 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, 859 860 /* 861 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, 862 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 863 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 864 */ 865 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | 866 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 867 .inv_gain = 600, 868 .time_stabiliz = 10, 869 .alpha_level = 0, 870 .thlock = 118, 871 .wbd_inv = 0, 872 .wbd_ref = 3530, 873 .wbd_sel = 1, 874 .wbd_alpha = 5, 875 .agc1_max = 65535, 876 .agc1_min = 0, 877 .agc2_max = 65535, 878 .agc2_min = 0, 879 .agc1_pt1 = 0, 880 .agc1_pt2 = 40, 881 .agc1_pt3 = 183, 882 .agc1_slope1 = 206, 883 .agc1_slope2 = 255, 884 .agc2_pt1 = 72, 885 .agc2_pt2 = 152, 886 .agc2_slope1 = 88, 887 .agc2_slope2 = 90, 888 .alpha_mant = 17, 889 .alpha_exp = 27, 890 .beta_mant = 23, 891 .beta_exp = 51, 892 .perform_agc_softsplit = 0, 893 }; 894 895 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = { 896 .internal = 60000, 897 .sampling = 15000, 898 .pll_prediv = 1, 899 .pll_ratio = 20, 900 .pll_range = 3, 901 .pll_reset = 1, 902 .pll_bypass = 0, 903 .enable_refdiv = 0, 904 .bypclk_div = 0, 905 .IO_CLK_en_core = 1, 906 .ADClkSrc = 1, 907 .modulo = 2, 908 /* refsel, sel, freq_15k */ 909 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 910 .ifreq = (0 << 25) | 0, 911 .timf = 20452225, 912 .xtal_hz = 12000000, 913 }; 914 915 static struct dib7000p_config cxusb_dualdig4_rev2_config = { 916 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, 917 .output_mpeg2_in_188_bytes = 1, 918 919 .agc_config_count = 1, 920 .agc = &dib7070_agc_config, 921 .bw = &dib7070_bw_config_12_mhz, 922 .tuner_is_baseband = 1, 923 .spur_protect = 1, 924 925 .gpio_dir = 0xfcef, 926 .gpio_val = 0x0110, 927 928 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 929 930 .hostbus_diversity = 1, 931 }; 932 933 struct dib0700_adapter_state { 934 int (*set_param_save)(struct dvb_frontend *); 935 struct dib7000p_ops dib7000p_ops; 936 }; 937 938 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap) 939 { 940 struct dib0700_adapter_state *state = adap->priv; 941 942 if (usb_set_interface(adap->dev->udev, 0, 1) < 0) 943 err("set interface failed"); 944 945 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 946 947 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 948 949 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 950 return -ENODEV; 951 952 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 953 &cxusb_dualdig4_rev2_config) < 0) { 954 printk(KERN_WARNING "Unable to enumerate dib7000p\n"); 955 return -ENODEV; 956 } 957 958 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, 959 &cxusb_dualdig4_rev2_config); 960 if (adap->fe_adap[0].fe == NULL) 961 return -EIO; 962 963 return 0; 964 } 965 966 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff) 967 { 968 struct dvb_usb_adapter *adap = fe->dvb->priv; 969 struct dib0700_adapter_state *state = adap->priv; 970 971 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff); 972 } 973 974 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff) 975 { 976 return 0; 977 } 978 979 static struct dib0070_config dib7070p_dib0070_config = { 980 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 981 .reset = dib7070_tuner_reset, 982 .sleep = dib7070_tuner_sleep, 983 .clock_khz = 12000, 984 }; 985 986 static int dib7070_set_param_override(struct dvb_frontend *fe) 987 { 988 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 989 struct dvb_usb_adapter *adap = fe->dvb->priv; 990 struct dib0700_adapter_state *state = adap->priv; 991 992 u16 offset; 993 u8 band = BAND_OF_FREQUENCY(p->frequency/1000); 994 switch (band) { 995 case BAND_VHF: offset = 950; break; 996 default: 997 case BAND_UHF: offset = 550; break; 998 } 999 1000 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe)); 1001 1002 return state->set_param_save(fe); 1003 } 1004 1005 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap) 1006 { 1007 struct dib0700_adapter_state *st = adap->priv; 1008 struct i2c_adapter *tun_i2c; 1009 1010 /* 1011 * No need to call dvb7000p_attach here, as it was called 1012 * already, as frontend_attach method is called first, and 1013 * tuner_attach is only called on sucess. 1014 */ 1015 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, 1016 DIBX000_I2C_INTERFACE_TUNER, 1); 1017 1018 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, 1019 &dib7070p_dib0070_config) == NULL) 1020 return -ENODEV; 1021 1022 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 1023 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override; 1024 return 0; 1025 } 1026 1027 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap) 1028 { 1029 if (usb_set_interface(adap->dev->udev, 0, 1) < 0) 1030 err("set interface failed"); 1031 1032 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 1033 1034 /* reset the tuner and demodulator */ 1035 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0); 1036 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1); 1037 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 1038 1039 adap->fe_adap[0].fe = dvb_attach(zl10353_attach, 1040 &cxusb_zl10353_xc3028_config, 1041 &adap->dev->i2c_adap); 1042 if ((adap->fe_adap[0].fe) != NULL) 1043 return 0; 1044 1045 adap->fe_adap[0].fe = dvb_attach(mt352_attach, 1046 &cxusb_mt352_xc3028_config, 1047 &adap->dev->i2c_adap); 1048 if ((adap->fe_adap[0].fe) != NULL) 1049 return 0; 1050 1051 return -EIO; 1052 } 1053 1054 static struct lgs8gxx_config d680_lgs8gl5_cfg = { 1055 .prod = LGS8GXX_PROD_LGS8GL5, 1056 .demod_address = 0x19, 1057 .serial_ts = 0, 1058 .ts_clk_pol = 0, 1059 .ts_clk_gated = 1, 1060 .if_clk_freq = 30400, /* 30.4 MHz */ 1061 .if_freq = 5725, /* 5.725 MHz */ 1062 .if_neg_center = 0, 1063 .ext_adc = 0, 1064 .adc_signed = 0, 1065 .if_neg_edge = 0, 1066 }; 1067 1068 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap) 1069 { 1070 struct dvb_usb_device *d = adap->dev; 1071 int n; 1072 1073 /* Select required USB configuration */ 1074 if (usb_set_interface(d->udev, 0, 0) < 0) 1075 err("set interface failed"); 1076 1077 /* Unblock all USB pipes */ 1078 usb_clear_halt(d->udev, 1079 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1080 usb_clear_halt(d->udev, 1081 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1082 usb_clear_halt(d->udev, 1083 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); 1084 1085 /* Drain USB pipes to avoid hang after reboot */ 1086 for (n = 0; n < 5; n++) { 1087 cxusb_d680_dmb_drain_message(d); 1088 cxusb_d680_dmb_drain_video(d); 1089 msleep(200); 1090 } 1091 1092 /* Reset the tuner */ 1093 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) { 1094 err("clear tuner gpio failed"); 1095 return -EIO; 1096 } 1097 msleep(100); 1098 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) { 1099 err("set tuner gpio failed"); 1100 return -EIO; 1101 } 1102 msleep(100); 1103 1104 /* Attach frontend */ 1105 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap); 1106 if (adap->fe_adap[0].fe == NULL) 1107 return -EIO; 1108 1109 return 0; 1110 } 1111 1112 static struct atbm8830_config mygica_d689_atbm8830_cfg = { 1113 .prod = ATBM8830_PROD_8830, 1114 .demod_address = 0x40, 1115 .serial_ts = 0, 1116 .ts_sampling_edge = 1, 1117 .ts_clk_gated = 0, 1118 .osc_clk_freq = 30400, /* in kHz */ 1119 .if_freq = 0, /* zero IF */ 1120 .zif_swap_iq = 1, 1121 .agc_min = 0x2E, 1122 .agc_max = 0x90, 1123 .agc_hold_loop = 0, 1124 }; 1125 1126 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap) 1127 { 1128 struct dvb_usb_device *d = adap->dev; 1129 1130 /* Select required USB configuration */ 1131 if (usb_set_interface(d->udev, 0, 0) < 0) 1132 err("set interface failed"); 1133 1134 /* Unblock all USB pipes */ 1135 usb_clear_halt(d->udev, 1136 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1137 usb_clear_halt(d->udev, 1138 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1139 usb_clear_halt(d->udev, 1140 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); 1141 1142 1143 /* Reset the tuner */ 1144 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) { 1145 err("clear tuner gpio failed"); 1146 return -EIO; 1147 } 1148 msleep(100); 1149 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) { 1150 err("set tuner gpio failed"); 1151 return -EIO; 1152 } 1153 msleep(100); 1154 1155 /* Attach frontend */ 1156 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg, 1157 &d->i2c_adap); 1158 if (adap->fe_adap[0].fe == NULL) 1159 return -EIO; 1160 1161 return 0; 1162 } 1163 1164 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap) 1165 { 1166 struct dvb_usb_device *d = adap->dev; 1167 struct cxusb_state *st = d->priv; 1168 struct i2c_adapter *adapter; 1169 struct i2c_client *client_demod; 1170 struct i2c_client *client_tuner; 1171 struct i2c_board_info info; 1172 struct si2168_config si2168_config; 1173 struct si2157_config si2157_config; 1174 1175 /* Select required USB configuration */ 1176 if (usb_set_interface(d->udev, 0, 0) < 0) 1177 err("set interface failed"); 1178 1179 /* Unblock all USB pipes */ 1180 usb_clear_halt(d->udev, 1181 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1182 usb_clear_halt(d->udev, 1183 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1184 usb_clear_halt(d->udev, 1185 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); 1186 1187 /* attach frontend */ 1188 si2168_config.i2c_adapter = &adapter; 1189 si2168_config.fe = &adap->fe_adap[0].fe; 1190 si2168_config.ts_mode = SI2168_TS_PARALLEL; 1191 si2168_config.ts_clock_inv = 1; 1192 memset(&info, 0, sizeof(struct i2c_board_info)); 1193 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 1194 info.addr = 0x64; 1195 info.platform_data = &si2168_config; 1196 request_module(info.type); 1197 client_demod = i2c_new_device(&d->i2c_adap, &info); 1198 if (client_demod == NULL || client_demod->dev.driver == NULL) 1199 return -ENODEV; 1200 1201 if (!try_module_get(client_demod->dev.driver->owner)) { 1202 i2c_unregister_device(client_demod); 1203 return -ENODEV; 1204 } 1205 1206 st->i2c_client_demod = client_demod; 1207 1208 /* attach tuner */ 1209 memset(&si2157_config, 0, sizeof(si2157_config)); 1210 si2157_config.fe = adap->fe_adap[0].fe; 1211 si2157_config.if_port = 1; 1212 memset(&info, 0, sizeof(struct i2c_board_info)); 1213 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 1214 info.addr = 0x60; 1215 info.platform_data = &si2157_config; 1216 request_module(info.type); 1217 client_tuner = i2c_new_device(adapter, &info); 1218 if (client_tuner == NULL || client_tuner->dev.driver == NULL) { 1219 module_put(client_demod->dev.driver->owner); 1220 i2c_unregister_device(client_demod); 1221 return -ENODEV; 1222 } 1223 if (!try_module_get(client_tuner->dev.driver->owner)) { 1224 i2c_unregister_device(client_tuner); 1225 module_put(client_demod->dev.driver->owner); 1226 i2c_unregister_device(client_demod); 1227 return -ENODEV; 1228 } 1229 1230 st->i2c_client_tuner = client_tuner; 1231 1232 /* hook fe: need to resync the slave fifo when signal locks. */ 1233 mutex_init(&st->stream_mutex); 1234 st->last_lock = 0; 1235 st->fe_read_status = adap->fe_adap[0].fe->ops.read_status; 1236 adap->fe_adap[0].fe->ops.read_status = cxusb_read_status; 1237 1238 return 0; 1239 } 1240 1241 /* 1242 * DViCO has shipped two devices with the same USB ID, but only one of them 1243 * needs a firmware download. Check the device class details to see if they 1244 * have non-default values to decide whether the device is actually cold or 1245 * not, and forget a match if it turns out we selected the wrong device. 1246 */ 1247 static int bluebird_fx2_identify_state(struct usb_device *udev, 1248 struct dvb_usb_device_properties *props, 1249 struct dvb_usb_device_description **desc, 1250 int *cold) 1251 { 1252 int wascold = *cold; 1253 1254 *cold = udev->descriptor.bDeviceClass == 0xff && 1255 udev->descriptor.bDeviceSubClass == 0xff && 1256 udev->descriptor.bDeviceProtocol == 0xff; 1257 1258 if (*cold && !wascold) 1259 *desc = NULL; 1260 1261 return 0; 1262 } 1263 1264 /* 1265 * DViCO bluebird firmware needs the "warm" product ID to be patched into the 1266 * firmware file before download. 1267 */ 1268 1269 static const int dvico_firmware_id_offsets[] = { 6638, 3204 }; 1270 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, 1271 const struct firmware *fw) 1272 { 1273 int pos; 1274 1275 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) { 1276 int idoff = dvico_firmware_id_offsets[pos]; 1277 1278 if (fw->size < idoff + 4) 1279 continue; 1280 1281 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) && 1282 fw->data[idoff + 1] == USB_VID_DVICO >> 8) { 1283 struct firmware new_fw; 1284 u8 *new_fw_data = vmalloc(fw->size); 1285 int ret; 1286 1287 if (!new_fw_data) 1288 return -ENOMEM; 1289 1290 memcpy(new_fw_data, fw->data, fw->size); 1291 new_fw.size = fw->size; 1292 new_fw.data = new_fw_data; 1293 1294 new_fw_data[idoff + 2] = 1295 le16_to_cpu(udev->descriptor.idProduct) + 1; 1296 new_fw_data[idoff + 3] = 1297 le16_to_cpu(udev->descriptor.idProduct) >> 8; 1298 1299 ret = usb_cypress_load_firmware(udev, &new_fw, 1300 CYPRESS_FX2); 1301 vfree(new_fw_data); 1302 return ret; 1303 } 1304 } 1305 1306 return -EINVAL; 1307 } 1308 1309 /* DVB USB Driver stuff */ 1310 static struct dvb_usb_device_properties cxusb_medion_properties; 1311 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties; 1312 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties; 1313 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties; 1314 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties; 1315 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties; 1316 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties; 1317 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties; 1318 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties; 1319 static struct dvb_usb_device_properties cxusb_aver_a868r_properties; 1320 static struct dvb_usb_device_properties cxusb_d680_dmb_properties; 1321 static struct dvb_usb_device_properties cxusb_mygica_d689_properties; 1322 static struct dvb_usb_device_properties cxusb_mygica_t230_properties; 1323 1324 static int cxusb_probe(struct usb_interface *intf, 1325 const struct usb_device_id *id) 1326 { 1327 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties, 1328 THIS_MODULE, NULL, adapter_nr) || 1329 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties, 1330 THIS_MODULE, NULL, adapter_nr) || 1331 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties, 1332 THIS_MODULE, NULL, adapter_nr) || 1333 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties, 1334 THIS_MODULE, NULL, adapter_nr) || 1335 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties, 1336 THIS_MODULE, NULL, adapter_nr) || 1337 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties, 1338 THIS_MODULE, NULL, adapter_nr) || 1339 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties, 1340 THIS_MODULE, NULL, adapter_nr) || 1341 0 == dvb_usb_device_init(intf, 1342 &cxusb_bluebird_nano2_needsfirmware_properties, 1343 THIS_MODULE, NULL, adapter_nr) || 1344 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties, 1345 THIS_MODULE, NULL, adapter_nr) || 1346 0 == dvb_usb_device_init(intf, 1347 &cxusb_bluebird_dualdig4_rev2_properties, 1348 THIS_MODULE, NULL, adapter_nr) || 1349 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties, 1350 THIS_MODULE, NULL, adapter_nr) || 1351 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties, 1352 THIS_MODULE, NULL, adapter_nr) || 1353 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties, 1354 THIS_MODULE, NULL, adapter_nr) || 1355 0) 1356 return 0; 1357 1358 return -EINVAL; 1359 } 1360 1361 static void cxusb_disconnect(struct usb_interface *intf) 1362 { 1363 struct dvb_usb_device *d = usb_get_intfdata(intf); 1364 struct cxusb_state *st = d->priv; 1365 struct i2c_client *client; 1366 1367 /* remove I2C client for tuner */ 1368 client = st->i2c_client_tuner; 1369 if (client) { 1370 module_put(client->dev.driver->owner); 1371 i2c_unregister_device(client); 1372 } 1373 1374 /* remove I2C client for demodulator */ 1375 client = st->i2c_client_demod; 1376 if (client) { 1377 module_put(client->dev.driver->owner); 1378 i2c_unregister_device(client); 1379 } 1380 1381 dvb_usb_device_exit(intf); 1382 } 1383 1384 enum cxusb_table_index { 1385 MEDION_MD95700, 1386 DVICO_BLUEBIRD_LG064F_COLD, 1387 DVICO_BLUEBIRD_LG064F_WARM, 1388 DVICO_BLUEBIRD_DUAL_1_COLD, 1389 DVICO_BLUEBIRD_DUAL_1_WARM, 1390 DVICO_BLUEBIRD_LGZ201_COLD, 1391 DVICO_BLUEBIRD_LGZ201_WARM, 1392 DVICO_BLUEBIRD_TH7579_COLD, 1393 DVICO_BLUEBIRD_TH7579_WARM, 1394 DIGITALNOW_BLUEBIRD_DUAL_1_COLD, 1395 DIGITALNOW_BLUEBIRD_DUAL_1_WARM, 1396 DVICO_BLUEBIRD_DUAL_2_COLD, 1397 DVICO_BLUEBIRD_DUAL_2_WARM, 1398 DVICO_BLUEBIRD_DUAL_4, 1399 DVICO_BLUEBIRD_DVB_T_NANO_2, 1400 DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM, 1401 AVERMEDIA_VOLAR_A868R, 1402 DVICO_BLUEBIRD_DUAL_4_REV_2, 1403 CONEXANT_D680_DMB, 1404 MYGICA_D689, 1405 MYGICA_T230, 1406 NR__cxusb_table_index 1407 }; 1408 1409 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = { 1410 [MEDION_MD95700] = { 1411 USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) 1412 }, 1413 [DVICO_BLUEBIRD_LG064F_COLD] = { 1414 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) 1415 }, 1416 [DVICO_BLUEBIRD_LG064F_WARM] = { 1417 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) 1418 }, 1419 [DVICO_BLUEBIRD_DUAL_1_COLD] = { 1420 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) 1421 }, 1422 [DVICO_BLUEBIRD_DUAL_1_WARM] = { 1423 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) 1424 }, 1425 [DVICO_BLUEBIRD_LGZ201_COLD] = { 1426 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) 1427 }, 1428 [DVICO_BLUEBIRD_LGZ201_WARM] = { 1429 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) 1430 }, 1431 [DVICO_BLUEBIRD_TH7579_COLD] = { 1432 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) 1433 }, 1434 [DVICO_BLUEBIRD_TH7579_WARM] = { 1435 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) 1436 }, 1437 [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = { 1438 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) 1439 }, 1440 [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = { 1441 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) 1442 }, 1443 [DVICO_BLUEBIRD_DUAL_2_COLD] = { 1444 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) 1445 }, 1446 [DVICO_BLUEBIRD_DUAL_2_WARM] = { 1447 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) 1448 }, 1449 [DVICO_BLUEBIRD_DUAL_4] = { 1450 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) 1451 }, 1452 [DVICO_BLUEBIRD_DVB_T_NANO_2] = { 1453 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) 1454 }, 1455 [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = { 1456 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) 1457 }, 1458 [AVERMEDIA_VOLAR_A868R] = { 1459 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) 1460 }, 1461 [DVICO_BLUEBIRD_DUAL_4_REV_2] = { 1462 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) 1463 }, 1464 [CONEXANT_D680_DMB] = { 1465 USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) 1466 }, 1467 [MYGICA_D689] = { 1468 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) 1469 }, 1470 [MYGICA_T230] = { 1471 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230) 1472 }, 1473 {} /* Terminating entry */ 1474 }; 1475 MODULE_DEVICE_TABLE (usb, cxusb_table); 1476 1477 static struct dvb_usb_device_properties cxusb_medion_properties = { 1478 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1479 1480 .usb_ctrl = CYPRESS_FX2, 1481 1482 .size_of_priv = sizeof(struct cxusb_state), 1483 1484 .num_adapters = 1, 1485 .adapter = { 1486 { 1487 .num_frontends = 1, 1488 .fe = {{ 1489 .streaming_ctrl = cxusb_streaming_ctrl, 1490 .frontend_attach = cxusb_cx22702_frontend_attach, 1491 .tuner_attach = cxusb_fmd1216me_tuner_attach, 1492 /* parameter for the MPEG2-data transfer */ 1493 .stream = { 1494 .type = USB_BULK, 1495 .count = 5, 1496 .endpoint = 0x02, 1497 .u = { 1498 .bulk = { 1499 .buffersize = 8192, 1500 } 1501 } 1502 }, 1503 }}, 1504 }, 1505 }, 1506 .power_ctrl = cxusb_power_ctrl, 1507 1508 .i2c_algo = &cxusb_i2c_algo, 1509 1510 .generic_bulk_ctrl_endpoint = 0x01, 1511 1512 .num_device_descs = 1, 1513 .devices = { 1514 { "Medion MD95700 (MDUSBTV-HYBRID)", 1515 { NULL }, 1516 { &cxusb_table[MEDION_MD95700], NULL }, 1517 }, 1518 } 1519 }; 1520 1521 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = { 1522 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1523 1524 .usb_ctrl = DEVICE_SPECIFIC, 1525 .firmware = "dvb-usb-bluebird-01.fw", 1526 .download_firmware = bluebird_patch_dvico_firmware_download, 1527 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1528 use usb alt setting 7 for EP2 transfer (atsc) */ 1529 1530 .size_of_priv = sizeof(struct cxusb_state), 1531 1532 .num_adapters = 1, 1533 .adapter = { 1534 { 1535 .num_frontends = 1, 1536 .fe = {{ 1537 .streaming_ctrl = cxusb_streaming_ctrl, 1538 .frontend_attach = cxusb_lgdt3303_frontend_attach, 1539 .tuner_attach = cxusb_lgh064f_tuner_attach, 1540 1541 /* parameter for the MPEG2-data transfer */ 1542 .stream = { 1543 .type = USB_BULK, 1544 .count = 5, 1545 .endpoint = 0x02, 1546 .u = { 1547 .bulk = { 1548 .buffersize = 8192, 1549 } 1550 } 1551 }, 1552 }}, 1553 }, 1554 }, 1555 1556 .power_ctrl = cxusb_bluebird_power_ctrl, 1557 1558 .i2c_algo = &cxusb_i2c_algo, 1559 1560 .rc.core = { 1561 .rc_interval = 100, 1562 .rc_codes = RC_MAP_DVICO_PORTABLE, 1563 .module_name = KBUILD_MODNAME, 1564 .rc_query = cxusb_rc_query, 1565 .allowed_protos = RC_BIT_UNKNOWN, 1566 }, 1567 1568 .generic_bulk_ctrl_endpoint = 0x01, 1569 1570 .num_device_descs = 1, 1571 .devices = { 1572 { "DViCO FusionHDTV5 USB Gold", 1573 { &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL }, 1574 { &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL }, 1575 }, 1576 } 1577 }; 1578 1579 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = { 1580 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1581 1582 .usb_ctrl = DEVICE_SPECIFIC, 1583 .firmware = "dvb-usb-bluebird-01.fw", 1584 .download_firmware = bluebird_patch_dvico_firmware_download, 1585 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1586 use usb alt setting 7 for EP2 transfer (atsc) */ 1587 1588 .size_of_priv = sizeof(struct cxusb_state), 1589 1590 .num_adapters = 1, 1591 .adapter = { 1592 { 1593 .num_frontends = 1, 1594 .fe = {{ 1595 .streaming_ctrl = cxusb_streaming_ctrl, 1596 .frontend_attach = cxusb_dee1601_frontend_attach, 1597 .tuner_attach = cxusb_dee1601_tuner_attach, 1598 /* parameter for the MPEG2-data transfer */ 1599 .stream = { 1600 .type = USB_BULK, 1601 .count = 5, 1602 .endpoint = 0x04, 1603 .u = { 1604 .bulk = { 1605 .buffersize = 8192, 1606 } 1607 } 1608 }, 1609 }}, 1610 }, 1611 }, 1612 1613 .power_ctrl = cxusb_bluebird_power_ctrl, 1614 1615 .i2c_algo = &cxusb_i2c_algo, 1616 1617 .rc.core = { 1618 .rc_interval = 100, 1619 .rc_codes = RC_MAP_DVICO_MCE, 1620 .module_name = KBUILD_MODNAME, 1621 .rc_query = cxusb_rc_query, 1622 .allowed_protos = RC_BIT_UNKNOWN, 1623 }, 1624 1625 .generic_bulk_ctrl_endpoint = 0x01, 1626 1627 .num_device_descs = 3, 1628 .devices = { 1629 { "DViCO FusionHDTV DVB-T Dual USB", 1630 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL }, 1631 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL }, 1632 }, 1633 { "DigitalNow DVB-T Dual USB", 1634 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD], NULL }, 1635 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL }, 1636 }, 1637 { "DViCO FusionHDTV DVB-T Dual Digital 2", 1638 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL }, 1639 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL }, 1640 }, 1641 } 1642 }; 1643 1644 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = { 1645 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1646 1647 .usb_ctrl = DEVICE_SPECIFIC, 1648 .firmware = "dvb-usb-bluebird-01.fw", 1649 .download_firmware = bluebird_patch_dvico_firmware_download, 1650 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1651 use usb alt setting 7 for EP2 transfer (atsc) */ 1652 1653 .size_of_priv = sizeof(struct cxusb_state), 1654 1655 .num_adapters = 2, 1656 .adapter = { 1657 { 1658 .num_frontends = 1, 1659 .fe = {{ 1660 .streaming_ctrl = cxusb_streaming_ctrl, 1661 .frontend_attach = cxusb_mt352_frontend_attach, 1662 .tuner_attach = cxusb_lgz201_tuner_attach, 1663 1664 /* parameter for the MPEG2-data transfer */ 1665 .stream = { 1666 .type = USB_BULK, 1667 .count = 5, 1668 .endpoint = 0x04, 1669 .u = { 1670 .bulk = { 1671 .buffersize = 8192, 1672 } 1673 } 1674 }, 1675 }}, 1676 }, 1677 }, 1678 .power_ctrl = cxusb_bluebird_power_ctrl, 1679 1680 .i2c_algo = &cxusb_i2c_algo, 1681 1682 .rc.core = { 1683 .rc_interval = 100, 1684 .rc_codes = RC_MAP_DVICO_PORTABLE, 1685 .module_name = KBUILD_MODNAME, 1686 .rc_query = cxusb_rc_query, 1687 .allowed_protos = RC_BIT_UNKNOWN, 1688 }, 1689 1690 .generic_bulk_ctrl_endpoint = 0x01, 1691 .num_device_descs = 1, 1692 .devices = { 1693 { "DViCO FusionHDTV DVB-T USB (LGZ201)", 1694 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL }, 1695 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL }, 1696 }, 1697 } 1698 }; 1699 1700 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = { 1701 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1702 1703 .usb_ctrl = DEVICE_SPECIFIC, 1704 .firmware = "dvb-usb-bluebird-01.fw", 1705 .download_firmware = bluebird_patch_dvico_firmware_download, 1706 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1707 use usb alt setting 7 for EP2 transfer (atsc) */ 1708 1709 .size_of_priv = sizeof(struct cxusb_state), 1710 1711 .num_adapters = 1, 1712 .adapter = { 1713 { 1714 .num_frontends = 1, 1715 .fe = {{ 1716 .streaming_ctrl = cxusb_streaming_ctrl, 1717 .frontend_attach = cxusb_mt352_frontend_attach, 1718 .tuner_attach = cxusb_dtt7579_tuner_attach, 1719 1720 /* parameter for the MPEG2-data transfer */ 1721 .stream = { 1722 .type = USB_BULK, 1723 .count = 5, 1724 .endpoint = 0x04, 1725 .u = { 1726 .bulk = { 1727 .buffersize = 8192, 1728 } 1729 } 1730 }, 1731 }}, 1732 }, 1733 }, 1734 .power_ctrl = cxusb_bluebird_power_ctrl, 1735 1736 .i2c_algo = &cxusb_i2c_algo, 1737 1738 .rc.core = { 1739 .rc_interval = 100, 1740 .rc_codes = RC_MAP_DVICO_PORTABLE, 1741 .module_name = KBUILD_MODNAME, 1742 .rc_query = cxusb_rc_query, 1743 .allowed_protos = RC_BIT_UNKNOWN, 1744 }, 1745 1746 .generic_bulk_ctrl_endpoint = 0x01, 1747 1748 .num_device_descs = 1, 1749 .devices = { 1750 { "DViCO FusionHDTV DVB-T USB (TH7579)", 1751 { &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL }, 1752 { &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL }, 1753 }, 1754 } 1755 }; 1756 1757 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = { 1758 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1759 1760 .usb_ctrl = CYPRESS_FX2, 1761 1762 .size_of_priv = sizeof(struct cxusb_state), 1763 1764 .num_adapters = 1, 1765 .adapter = { 1766 { 1767 .num_frontends = 1, 1768 .fe = {{ 1769 .streaming_ctrl = cxusb_streaming_ctrl, 1770 .frontend_attach = cxusb_dualdig4_frontend_attach, 1771 .tuner_attach = cxusb_dvico_xc3028_tuner_attach, 1772 /* parameter for the MPEG2-data transfer */ 1773 .stream = { 1774 .type = USB_BULK, 1775 .count = 5, 1776 .endpoint = 0x02, 1777 .u = { 1778 .bulk = { 1779 .buffersize = 8192, 1780 } 1781 } 1782 }, 1783 }}, 1784 }, 1785 }, 1786 1787 .power_ctrl = cxusb_power_ctrl, 1788 1789 .i2c_algo = &cxusb_i2c_algo, 1790 1791 .generic_bulk_ctrl_endpoint = 0x01, 1792 1793 .rc.core = { 1794 .rc_interval = 100, 1795 .rc_codes = RC_MAP_DVICO_MCE, 1796 .module_name = KBUILD_MODNAME, 1797 .rc_query = cxusb_bluebird2_rc_query, 1798 .allowed_protos = RC_BIT_UNKNOWN, 1799 }, 1800 1801 .num_device_descs = 1, 1802 .devices = { 1803 { "DViCO FusionHDTV DVB-T Dual Digital 4", 1804 { NULL }, 1805 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL }, 1806 }, 1807 } 1808 }; 1809 1810 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = { 1811 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1812 1813 .usb_ctrl = CYPRESS_FX2, 1814 .identify_state = bluebird_fx2_identify_state, 1815 1816 .size_of_priv = sizeof(struct cxusb_state), 1817 1818 .num_adapters = 1, 1819 .adapter = { 1820 { 1821 .num_frontends = 1, 1822 .fe = {{ 1823 .streaming_ctrl = cxusb_streaming_ctrl, 1824 .frontend_attach = cxusb_nano2_frontend_attach, 1825 .tuner_attach = cxusb_dvico_xc3028_tuner_attach, 1826 /* parameter for the MPEG2-data transfer */ 1827 .stream = { 1828 .type = USB_BULK, 1829 .count = 5, 1830 .endpoint = 0x02, 1831 .u = { 1832 .bulk = { 1833 .buffersize = 8192, 1834 } 1835 } 1836 }, 1837 }}, 1838 }, 1839 }, 1840 1841 .power_ctrl = cxusb_nano2_power_ctrl, 1842 1843 .i2c_algo = &cxusb_i2c_algo, 1844 1845 .generic_bulk_ctrl_endpoint = 0x01, 1846 1847 .rc.core = { 1848 .rc_interval = 100, 1849 .rc_codes = RC_MAP_DVICO_PORTABLE, 1850 .module_name = KBUILD_MODNAME, 1851 .rc_query = cxusb_bluebird2_rc_query, 1852 .allowed_protos = RC_BIT_UNKNOWN, 1853 }, 1854 1855 .num_device_descs = 1, 1856 .devices = { 1857 { "DViCO FusionHDTV DVB-T NANO2", 1858 { NULL }, 1859 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL }, 1860 }, 1861 } 1862 }; 1863 1864 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = { 1865 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1866 1867 .usb_ctrl = DEVICE_SPECIFIC, 1868 .firmware = "dvb-usb-bluebird-02.fw", 1869 .download_firmware = bluebird_patch_dvico_firmware_download, 1870 .identify_state = bluebird_fx2_identify_state, 1871 1872 .size_of_priv = sizeof(struct cxusb_state), 1873 1874 .num_adapters = 1, 1875 .adapter = { 1876 { 1877 .num_frontends = 1, 1878 .fe = {{ 1879 .streaming_ctrl = cxusb_streaming_ctrl, 1880 .frontend_attach = cxusb_nano2_frontend_attach, 1881 .tuner_attach = cxusb_dvico_xc3028_tuner_attach, 1882 /* parameter for the MPEG2-data transfer */ 1883 .stream = { 1884 .type = USB_BULK, 1885 .count = 5, 1886 .endpoint = 0x02, 1887 .u = { 1888 .bulk = { 1889 .buffersize = 8192, 1890 } 1891 } 1892 }, 1893 }}, 1894 }, 1895 }, 1896 1897 .power_ctrl = cxusb_nano2_power_ctrl, 1898 1899 .i2c_algo = &cxusb_i2c_algo, 1900 1901 .generic_bulk_ctrl_endpoint = 0x01, 1902 1903 .rc.core = { 1904 .rc_interval = 100, 1905 .rc_codes = RC_MAP_DVICO_PORTABLE, 1906 .module_name = KBUILD_MODNAME, 1907 .rc_query = cxusb_rc_query, 1908 .allowed_protos = RC_BIT_UNKNOWN, 1909 }, 1910 1911 .num_device_descs = 1, 1912 .devices = { 1913 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware", 1914 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL }, 1915 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL }, 1916 }, 1917 } 1918 }; 1919 1920 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = { 1921 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1922 1923 .usb_ctrl = CYPRESS_FX2, 1924 1925 .size_of_priv = sizeof(struct cxusb_state), 1926 1927 .num_adapters = 1, 1928 .adapter = { 1929 { 1930 .num_frontends = 1, 1931 .fe = {{ 1932 .streaming_ctrl = cxusb_aver_streaming_ctrl, 1933 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach, 1934 .tuner_attach = cxusb_mxl5003s_tuner_attach, 1935 /* parameter for the MPEG2-data transfer */ 1936 .stream = { 1937 .type = USB_BULK, 1938 .count = 5, 1939 .endpoint = 0x04, 1940 .u = { 1941 .bulk = { 1942 .buffersize = 8192, 1943 } 1944 } 1945 }, 1946 }}, 1947 }, 1948 }, 1949 .power_ctrl = cxusb_aver_power_ctrl, 1950 1951 .i2c_algo = &cxusb_i2c_algo, 1952 1953 .generic_bulk_ctrl_endpoint = 0x01, 1954 1955 .num_device_descs = 1, 1956 .devices = { 1957 { "AVerMedia AVerTVHD Volar (A868R)", 1958 { NULL }, 1959 { &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL }, 1960 }, 1961 } 1962 }; 1963 1964 static 1965 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = { 1966 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1967 1968 .usb_ctrl = CYPRESS_FX2, 1969 1970 .size_of_priv = sizeof(struct cxusb_state), 1971 1972 .num_adapters = 1, 1973 .adapter = { 1974 { 1975 .size_of_priv = sizeof(struct dib0700_adapter_state), 1976 .num_frontends = 1, 1977 .fe = {{ 1978 .streaming_ctrl = cxusb_streaming_ctrl, 1979 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach, 1980 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach, 1981 /* parameter for the MPEG2-data transfer */ 1982 .stream = { 1983 .type = USB_BULK, 1984 .count = 7, 1985 .endpoint = 0x02, 1986 .u = { 1987 .bulk = { 1988 .buffersize = 4096, 1989 } 1990 } 1991 }, 1992 }}, 1993 }, 1994 }, 1995 1996 .power_ctrl = cxusb_bluebird_power_ctrl, 1997 1998 .i2c_algo = &cxusb_i2c_algo, 1999 2000 .generic_bulk_ctrl_endpoint = 0x01, 2001 2002 .rc.core = { 2003 .rc_interval = 100, 2004 .rc_codes = RC_MAP_DVICO_MCE, 2005 .module_name = KBUILD_MODNAME, 2006 .rc_query = cxusb_rc_query, 2007 .allowed_protos = RC_BIT_UNKNOWN, 2008 }, 2009 2010 .num_device_descs = 1, 2011 .devices = { 2012 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)", 2013 { NULL }, 2014 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL }, 2015 }, 2016 } 2017 }; 2018 2019 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = { 2020 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2021 2022 .usb_ctrl = CYPRESS_FX2, 2023 2024 .size_of_priv = sizeof(struct cxusb_state), 2025 2026 .num_adapters = 1, 2027 .adapter = { 2028 { 2029 .num_frontends = 1, 2030 .fe = {{ 2031 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl, 2032 .frontend_attach = cxusb_d680_dmb_frontend_attach, 2033 .tuner_attach = cxusb_d680_dmb_tuner_attach, 2034 2035 /* parameter for the MPEG2-data transfer */ 2036 .stream = { 2037 .type = USB_BULK, 2038 .count = 5, 2039 .endpoint = 0x02, 2040 .u = { 2041 .bulk = { 2042 .buffersize = 8192, 2043 } 2044 } 2045 }, 2046 }}, 2047 }, 2048 }, 2049 2050 .power_ctrl = cxusb_d680_dmb_power_ctrl, 2051 2052 .i2c_algo = &cxusb_i2c_algo, 2053 2054 .generic_bulk_ctrl_endpoint = 0x01, 2055 2056 .rc.core = { 2057 .rc_interval = 100, 2058 .rc_codes = RC_MAP_D680_DMB, 2059 .module_name = KBUILD_MODNAME, 2060 .rc_query = cxusb_d680_dmb_rc_query, 2061 .allowed_protos = RC_BIT_UNKNOWN, 2062 }, 2063 2064 .num_device_descs = 1, 2065 .devices = { 2066 { 2067 "Conexant DMB-TH Stick", 2068 { NULL }, 2069 { &cxusb_table[CONEXANT_D680_DMB], NULL }, 2070 }, 2071 } 2072 }; 2073 2074 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = { 2075 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2076 2077 .usb_ctrl = CYPRESS_FX2, 2078 2079 .size_of_priv = sizeof(struct cxusb_state), 2080 2081 .num_adapters = 1, 2082 .adapter = { 2083 { 2084 .num_frontends = 1, 2085 .fe = {{ 2086 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl, 2087 .frontend_attach = cxusb_mygica_d689_frontend_attach, 2088 .tuner_attach = cxusb_mygica_d689_tuner_attach, 2089 2090 /* parameter for the MPEG2-data transfer */ 2091 .stream = { 2092 .type = USB_BULK, 2093 .count = 5, 2094 .endpoint = 0x02, 2095 .u = { 2096 .bulk = { 2097 .buffersize = 8192, 2098 } 2099 } 2100 }, 2101 }}, 2102 }, 2103 }, 2104 2105 .power_ctrl = cxusb_d680_dmb_power_ctrl, 2106 2107 .i2c_algo = &cxusb_i2c_algo, 2108 2109 .generic_bulk_ctrl_endpoint = 0x01, 2110 2111 .rc.core = { 2112 .rc_interval = 100, 2113 .rc_codes = RC_MAP_D680_DMB, 2114 .module_name = KBUILD_MODNAME, 2115 .rc_query = cxusb_d680_dmb_rc_query, 2116 .allowed_protos = RC_BIT_UNKNOWN, 2117 }, 2118 2119 .num_device_descs = 1, 2120 .devices = { 2121 { 2122 "Mygica D689 DMB-TH", 2123 { NULL }, 2124 { &cxusb_table[MYGICA_D689], NULL }, 2125 }, 2126 } 2127 }; 2128 2129 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = { 2130 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2131 2132 .usb_ctrl = CYPRESS_FX2, 2133 2134 .size_of_priv = sizeof(struct cxusb_state), 2135 2136 .num_adapters = 1, 2137 .adapter = { 2138 { 2139 .num_frontends = 1, 2140 .fe = {{ 2141 .streaming_ctrl = cxusb_streaming_ctrl, 2142 .frontend_attach = cxusb_mygica_t230_frontend_attach, 2143 2144 /* parameter for the MPEG2-data transfer */ 2145 .stream = { 2146 .type = USB_BULK, 2147 .count = 5, 2148 .endpoint = 0x02, 2149 .u = { 2150 .bulk = { 2151 .buffersize = 8192, 2152 } 2153 } 2154 }, 2155 } }, 2156 }, 2157 }, 2158 2159 .power_ctrl = cxusb_d680_dmb_power_ctrl, 2160 2161 .i2c_algo = &cxusb_i2c_algo, 2162 2163 .generic_bulk_ctrl_endpoint = 0x01, 2164 2165 .rc.core = { 2166 .rc_interval = 100, 2167 .rc_codes = RC_MAP_D680_DMB, 2168 .module_name = KBUILD_MODNAME, 2169 .rc_query = cxusb_d680_dmb_rc_query, 2170 .allowed_protos = RC_BIT_UNKNOWN, 2171 }, 2172 2173 .num_device_descs = 1, 2174 .devices = { 2175 { 2176 "Mygica T230 DVB-T/T2/C", 2177 { NULL }, 2178 { &cxusb_table[MYGICA_T230], NULL }, 2179 }, 2180 } 2181 }; 2182 2183 static struct usb_driver cxusb_driver = { 2184 .name = "dvb_usb_cxusb", 2185 .probe = cxusb_probe, 2186 .disconnect = cxusb_disconnect, 2187 .id_table = cxusb_table, 2188 }; 2189 2190 module_usb_driver(cxusb_driver); 2191 2192 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>"); 2193 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); 2194 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); 2195 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design"); 2196 MODULE_VERSION("1.0-alpha"); 2197 MODULE_LICENSE("GPL"); 2198