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