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 void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d) 373 { 374 int ep = d->props.generic_bulk_ctrl_endpoint; 375 const int timeout = 100; 376 const int junk_len = 32; 377 u8 *junk; 378 int rd_count; 379 380 /* Discard remaining data in video pipe */ 381 junk = kmalloc(junk_len, GFP_KERNEL); 382 if (!junk) 383 return; 384 while (1) { 385 if (usb_bulk_msg(d->udev, 386 usb_rcvbulkpipe(d->udev, ep), 387 junk, junk_len, &rd_count, timeout) < 0) 388 break; 389 if (!rd_count) 390 break; 391 } 392 kfree(junk); 393 } 394 395 static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d) 396 { 397 struct usb_data_stream_properties *p = &d->props.adapter[0].fe[0].stream; 398 const int timeout = 100; 399 const int junk_len = p->u.bulk.buffersize; 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, p->endpoint), 410 junk, junk_len, &rd_count, timeout) < 0) 411 break; 412 if (!rd_count) 413 break; 414 } 415 kfree(junk); 416 } 417 418 static int cxusb_d680_dmb_streaming_ctrl( 419 struct dvb_usb_adapter *adap, int onoff) 420 { 421 if (onoff) { 422 u8 buf[2] = { 0x03, 0x00 }; 423 cxusb_d680_dmb_drain_video(adap->dev); 424 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, 425 buf, sizeof(buf), NULL, 0); 426 } else { 427 int ret = cxusb_ctrl_msg(adap->dev, 428 CMD_STREAMING_OFF, NULL, 0, NULL, 0); 429 return ret; 430 } 431 } 432 433 static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 434 { 435 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; 436 u8 ircode[4]; 437 int i; 438 439 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4); 440 441 *event = 0; 442 *state = REMOTE_NO_KEY_PRESSED; 443 444 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { 445 if (rc5_custom(&keymap[i]) == ircode[2] && 446 rc5_data(&keymap[i]) == ircode[3]) { 447 *event = keymap[i].keycode; 448 *state = REMOTE_KEY_PRESSED; 449 450 return 0; 451 } 452 } 453 454 return 0; 455 } 456 457 static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event, 458 int *state) 459 { 460 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; 461 u8 ircode[4]; 462 int i; 463 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, 464 .buf = ircode, .len = 4 }; 465 466 *event = 0; 467 *state = REMOTE_NO_KEY_PRESSED; 468 469 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1) 470 return 0; 471 472 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { 473 if (rc5_custom(&keymap[i]) == ircode[1] && 474 rc5_data(&keymap[i]) == ircode[2]) { 475 *event = keymap[i].keycode; 476 *state = REMOTE_KEY_PRESSED; 477 478 return 0; 479 } 480 } 481 482 return 0; 483 } 484 485 static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event, 486 int *state) 487 { 488 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; 489 u8 ircode[2]; 490 int i; 491 492 *event = 0; 493 *state = REMOTE_NO_KEY_PRESSED; 494 495 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0) 496 return 0; 497 498 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { 499 if (rc5_custom(&keymap[i]) == ircode[0] && 500 rc5_data(&keymap[i]) == ircode[1]) { 501 *event = keymap[i].keycode; 502 *state = REMOTE_KEY_PRESSED; 503 504 return 0; 505 } 506 } 507 508 return 0; 509 } 510 511 static struct rc_map_table rc_map_dvico_mce_table[] = { 512 { 0xfe02, KEY_TV }, 513 { 0xfe0e, KEY_MP3 }, 514 { 0xfe1a, KEY_DVD }, 515 { 0xfe1e, KEY_FAVORITES }, 516 { 0xfe16, KEY_SETUP }, 517 { 0xfe46, KEY_POWER2 }, 518 { 0xfe0a, KEY_EPG }, 519 { 0xfe49, KEY_BACK }, 520 { 0xfe4d, KEY_MENU }, 521 { 0xfe51, KEY_UP }, 522 { 0xfe5b, KEY_LEFT }, 523 { 0xfe5f, KEY_RIGHT }, 524 { 0xfe53, KEY_DOWN }, 525 { 0xfe5e, KEY_OK }, 526 { 0xfe59, KEY_INFO }, 527 { 0xfe55, KEY_TAB }, 528 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */ 529 { 0xfe12, KEY_NEXTSONG }, /* Skip */ 530 { 0xfe42, KEY_ENTER }, /* Windows/Start */ 531 { 0xfe15, KEY_VOLUMEUP }, 532 { 0xfe05, KEY_VOLUMEDOWN }, 533 { 0xfe11, KEY_CHANNELUP }, 534 { 0xfe09, KEY_CHANNELDOWN }, 535 { 0xfe52, KEY_CAMERA }, 536 { 0xfe5a, KEY_TUNER }, /* Live */ 537 { 0xfe19, KEY_OPEN }, 538 { 0xfe0b, KEY_1 }, 539 { 0xfe17, KEY_2 }, 540 { 0xfe1b, KEY_3 }, 541 { 0xfe07, KEY_4 }, 542 { 0xfe50, KEY_5 }, 543 { 0xfe54, KEY_6 }, 544 { 0xfe48, KEY_7 }, 545 { 0xfe4c, KEY_8 }, 546 { 0xfe58, KEY_9 }, 547 { 0xfe13, KEY_ANGLE }, /* Aspect */ 548 { 0xfe03, KEY_0 }, 549 { 0xfe1f, KEY_ZOOM }, 550 { 0xfe43, KEY_REWIND }, 551 { 0xfe47, KEY_PLAYPAUSE }, 552 { 0xfe4f, KEY_FASTFORWARD }, 553 { 0xfe57, KEY_MUTE }, 554 { 0xfe0d, KEY_STOP }, 555 { 0xfe01, KEY_RECORD }, 556 { 0xfe4e, KEY_POWER }, 557 }; 558 559 static struct rc_map_table rc_map_dvico_portable_table[] = { 560 { 0xfc02, KEY_SETUP }, /* Profile */ 561 { 0xfc43, KEY_POWER2 }, 562 { 0xfc06, KEY_EPG }, 563 { 0xfc5a, KEY_BACK }, 564 { 0xfc05, KEY_MENU }, 565 { 0xfc47, KEY_INFO }, 566 { 0xfc01, KEY_TAB }, 567 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */ 568 { 0xfc49, KEY_VOLUMEUP }, 569 { 0xfc09, KEY_VOLUMEDOWN }, 570 { 0xfc54, KEY_CHANNELUP }, 571 { 0xfc0b, KEY_CHANNELDOWN }, 572 { 0xfc16, KEY_CAMERA }, 573 { 0xfc40, KEY_TUNER }, /* ATV/DTV */ 574 { 0xfc45, KEY_OPEN }, 575 { 0xfc19, KEY_1 }, 576 { 0xfc18, KEY_2 }, 577 { 0xfc1b, KEY_3 }, 578 { 0xfc1a, KEY_4 }, 579 { 0xfc58, KEY_5 }, 580 { 0xfc59, KEY_6 }, 581 { 0xfc15, KEY_7 }, 582 { 0xfc14, KEY_8 }, 583 { 0xfc17, KEY_9 }, 584 { 0xfc44, KEY_ANGLE }, /* Aspect */ 585 { 0xfc55, KEY_0 }, 586 { 0xfc07, KEY_ZOOM }, 587 { 0xfc0a, KEY_REWIND }, 588 { 0xfc08, KEY_PLAYPAUSE }, 589 { 0xfc4b, KEY_FASTFORWARD }, 590 { 0xfc5b, KEY_MUTE }, 591 { 0xfc04, KEY_STOP }, 592 { 0xfc56, KEY_RECORD }, 593 { 0xfc57, KEY_POWER }, 594 { 0xfc41, KEY_UNKNOWN }, /* INPUT */ 595 { 0xfc00, KEY_UNKNOWN }, /* HD */ 596 }; 597 598 static struct rc_map_table rc_map_d680_dmb_table[] = { 599 { 0x0038, KEY_UNKNOWN }, /* TV/AV */ 600 { 0x080c, KEY_ZOOM }, 601 { 0x0800, KEY_0 }, 602 { 0x0001, KEY_1 }, 603 { 0x0802, KEY_2 }, 604 { 0x0003, KEY_3 }, 605 { 0x0804, KEY_4 }, 606 { 0x0005, KEY_5 }, 607 { 0x0806, KEY_6 }, 608 { 0x0007, KEY_7 }, 609 { 0x0808, KEY_8 }, 610 { 0x0009, KEY_9 }, 611 { 0x000a, KEY_MUTE }, 612 { 0x0829, KEY_BACK }, 613 { 0x0012, KEY_CHANNELUP }, 614 { 0x0813, KEY_CHANNELDOWN }, 615 { 0x002b, KEY_VOLUMEUP }, 616 { 0x082c, KEY_VOLUMEDOWN }, 617 { 0x0020, KEY_UP }, 618 { 0x0821, KEY_DOWN }, 619 { 0x0011, KEY_LEFT }, 620 { 0x0810, KEY_RIGHT }, 621 { 0x000d, KEY_OK }, 622 { 0x081f, KEY_RECORD }, 623 { 0x0017, KEY_PLAYPAUSE }, 624 { 0x0816, KEY_PLAYPAUSE }, 625 { 0x000b, KEY_STOP }, 626 { 0x0827, KEY_FASTFORWARD }, 627 { 0x0026, KEY_REWIND }, 628 { 0x081e, KEY_UNKNOWN }, /* Time Shift */ 629 { 0x000e, KEY_UNKNOWN }, /* Snapshot */ 630 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */ 631 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */ 632 { 0x0814, KEY_UNKNOWN }, /* Shuffle */ 633 { 0x0025, KEY_POWER }, 634 }; 635 636 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 637 { 638 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; 639 static u8 reset [] = { RESET, 0x80 }; 640 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 641 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; 642 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 643 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 644 645 mt352_write(fe, clock_config, sizeof(clock_config)); 646 udelay(200); 647 mt352_write(fe, reset, sizeof(reset)); 648 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 649 650 mt352_write(fe, agc_cfg, sizeof(agc_cfg)); 651 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); 652 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); 653 654 return 0; 655 } 656 657 static int cxusb_mt352_demod_init(struct dvb_frontend* fe) 658 { /* used in both lgz201 and th7579 */ 659 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 }; 660 static u8 reset [] = { RESET, 0x80 }; 661 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; 662 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 }; 663 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; 664 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; 665 666 mt352_write(fe, clock_config, sizeof(clock_config)); 667 udelay(200); 668 mt352_write(fe, reset, sizeof(reset)); 669 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); 670 671 mt352_write(fe, agc_cfg, sizeof(agc_cfg)); 672 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); 673 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); 674 return 0; 675 } 676 677 static struct cx22702_config cxusb_cx22702_config = { 678 .demod_address = 0x63, 679 .output_mode = CX22702_PARALLEL_OUTPUT, 680 }; 681 682 static struct lgdt330x_config cxusb_lgdt3303_config = { 683 .demod_address = 0x0e, 684 .demod_chip = LGDT3303, 685 }; 686 687 static struct lgdt330x_config cxusb_aver_lgdt3303_config = { 688 .demod_address = 0x0e, 689 .demod_chip = LGDT3303, 690 .clock_polarity_flip = 2, 691 }; 692 693 static struct mt352_config cxusb_dee1601_config = { 694 .demod_address = 0x0f, 695 .demod_init = cxusb_dee1601_demod_init, 696 }; 697 698 static struct zl10353_config cxusb_zl10353_dee1601_config = { 699 .demod_address = 0x0f, 700 .parallel_ts = 1, 701 }; 702 703 static struct mt352_config cxusb_mt352_config = { 704 /* used in both lgz201 and th7579 */ 705 .demod_address = 0x0f, 706 .demod_init = cxusb_mt352_demod_init, 707 }; 708 709 static struct zl10353_config cxusb_zl10353_xc3028_config = { 710 .demod_address = 0x0f, 711 .if2 = 45600, 712 .no_tuner = 1, 713 .parallel_ts = 1, 714 }; 715 716 static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = { 717 .demod_address = 0x0f, 718 .if2 = 45600, 719 .no_tuner = 1, 720 .parallel_ts = 1, 721 .disable_i2c_gate_ctrl = 1, 722 }; 723 724 static struct mt352_config cxusb_mt352_xc3028_config = { 725 .demod_address = 0x0f, 726 .if2 = 4560, 727 .no_tuner = 1, 728 .demod_init = cxusb_mt352_demod_init, 729 }; 730 731 /* FIXME: needs tweaking */ 732 static struct mxl5005s_config aver_a868r_tuner = { 733 .i2c_address = 0x63, 734 .if_freq = 6000000UL, 735 .xtal_freq = CRYSTAL_FREQ_16000000HZ, 736 .agc_mode = MXL_SINGLE_AGC, 737 .tracking_filter = MXL_TF_C, 738 .rssi_enable = MXL_RSSI_ENABLE, 739 .cap_select = MXL_CAP_SEL_ENABLE, 740 .div_out = MXL_DIV_OUT_4, 741 .clock_out = MXL_CLOCK_OUT_DISABLE, 742 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, 743 .top = MXL5005S_TOP_25P2, 744 .mod_mode = MXL_DIGITAL_MODE, 745 .if_mode = MXL_ZERO_IF, 746 .AgcMasterByte = 0x00, 747 }; 748 749 /* FIXME: needs tweaking */ 750 static struct mxl5005s_config d680_dmb_tuner = { 751 .i2c_address = 0x63, 752 .if_freq = 36125000UL, 753 .xtal_freq = CRYSTAL_FREQ_16000000HZ, 754 .agc_mode = MXL_SINGLE_AGC, 755 .tracking_filter = MXL_TF_C, 756 .rssi_enable = MXL_RSSI_ENABLE, 757 .cap_select = MXL_CAP_SEL_ENABLE, 758 .div_out = MXL_DIV_OUT_4, 759 .clock_out = MXL_CLOCK_OUT_DISABLE, 760 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM, 761 .top = MXL5005S_TOP_25P2, 762 .mod_mode = MXL_DIGITAL_MODE, 763 .if_mode = MXL_ZERO_IF, 764 .AgcMasterByte = 0x00, 765 }; 766 767 static struct max2165_config mygica_d689_max2165_cfg = { 768 .i2c_address = 0x60, 769 .osc_clk = 20 770 }; 771 772 /* Callbacks for DVB USB */ 773 static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) 774 { 775 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe, 776 &adap->dev->i2c_adap, 0x61, 777 TUNER_PHILIPS_FMD1216ME_MK3); 778 return 0; 779 } 780 781 static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap) 782 { 783 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, 784 NULL, DVB_PLL_THOMSON_DTT7579); 785 return 0; 786 } 787 788 static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap) 789 { 790 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x61, NULL, DVB_PLL_LG_Z201); 791 return 0; 792 } 793 794 static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap) 795 { 796 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 797 NULL, DVB_PLL_THOMSON_DTT7579); 798 return 0; 799 } 800 801 static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap) 802 { 803 dvb_attach(simple_tuner_attach, adap->fe_adap[0].fe, 804 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF); 805 return 0; 806 } 807 808 static int dvico_bluebird_xc2028_callback(void *ptr, int component, 809 int command, int arg) 810 { 811 struct dvb_usb_adapter *adap = ptr; 812 struct dvb_usb_device *d = adap->dev; 813 814 switch (command) { 815 case XC2028_TUNER_RESET: 816 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg); 817 cxusb_bluebird_gpio_pulse(d, 0x01, 1); 818 break; 819 case XC2028_RESET_CLK: 820 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg); 821 break; 822 default: 823 deb_info("%s: unknown command %d, arg %d\n", __func__, 824 command, arg); 825 return -EINVAL; 826 } 827 828 return 0; 829 } 830 831 static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap) 832 { 833 struct dvb_frontend *fe; 834 struct xc2028_config cfg = { 835 .i2c_adap = &adap->dev->i2c_adap, 836 .i2c_addr = 0x61, 837 }; 838 static struct xc2028_ctrl ctl = { 839 .fname = XC2028_DEFAULT_FIRMWARE, 840 .max_len = 64, 841 .demod = XC3028_FE_ZARLINK456, 842 }; 843 844 /* FIXME: generalize & move to common area */ 845 adap->fe_adap[0].fe->callback = dvico_bluebird_xc2028_callback; 846 847 fe = dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &cfg); 848 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL) 849 return -EIO; 850 851 fe->ops.tuner_ops.set_config(fe, &ctl); 852 853 return 0; 854 } 855 856 static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap) 857 { 858 dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, 859 &adap->dev->i2c_adap, &aver_a868r_tuner); 860 return 0; 861 } 862 863 static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap) 864 { 865 struct dvb_frontend *fe; 866 fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, 867 &adap->dev->i2c_adap, &d680_dmb_tuner); 868 return (fe == NULL) ? -EIO : 0; 869 } 870 871 static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap) 872 { 873 struct dvb_frontend *fe; 874 fe = dvb_attach(max2165_attach, adap->fe_adap[0].fe, 875 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg); 876 return (fe == NULL) ? -EIO : 0; 877 } 878 879 static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap) 880 { 881 u8 b; 882 if (usb_set_interface(adap->dev->udev, 0, 6) < 0) 883 err("set interface failed"); 884 885 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1); 886 887 adap->fe_adap[0].fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, 888 &adap->dev->i2c_adap); 889 if ((adap->fe_adap[0].fe) != NULL) 890 return 0; 891 892 return -EIO; 893 } 894 895 static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap) 896 { 897 if (usb_set_interface(adap->dev->udev, 0, 7) < 0) 898 err("set interface failed"); 899 900 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 901 902 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, 903 &cxusb_lgdt3303_config, 904 &adap->dev->i2c_adap); 905 if ((adap->fe_adap[0].fe) != NULL) 906 return 0; 907 908 return -EIO; 909 } 910 911 static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap) 912 { 913 adap->fe_adap[0].fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config, 914 &adap->dev->i2c_adap); 915 if (adap->fe_adap[0].fe != NULL) 916 return 0; 917 918 return -EIO; 919 } 920 921 static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap) 922 { 923 /* used in both lgz201 and th7579 */ 924 if (usb_set_interface(adap->dev->udev, 0, 0) < 0) 925 err("set interface failed"); 926 927 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 928 929 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_mt352_config, 930 &adap->dev->i2c_adap); 931 if ((adap->fe_adap[0].fe) != NULL) 932 return 0; 933 934 return -EIO; 935 } 936 937 static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap) 938 { 939 if (usb_set_interface(adap->dev->udev, 0, 0) < 0) 940 err("set interface failed"); 941 942 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 943 944 adap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, 945 &adap->dev->i2c_adap); 946 if ((adap->fe_adap[0].fe) != NULL) 947 return 0; 948 949 adap->fe_adap[0].fe = dvb_attach(zl10353_attach, 950 &cxusb_zl10353_dee1601_config, 951 &adap->dev->i2c_adap); 952 if ((adap->fe_adap[0].fe) != NULL) 953 return 0; 954 955 return -EIO; 956 } 957 958 static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap) 959 { 960 u8 ircode[4]; 961 int i; 962 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, 963 .buf = ircode, .len = 4 }; 964 965 if (usb_set_interface(adap->dev->udev, 0, 1) < 0) 966 err("set interface failed"); 967 968 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 969 970 /* reset the tuner and demodulator */ 971 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0); 972 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1); 973 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 974 975 adap->fe_adap[0].fe = 976 dvb_attach(zl10353_attach, 977 &cxusb_zl10353_xc3028_config_no_i2c_gate, 978 &adap->dev->i2c_adap); 979 if ((adap->fe_adap[0].fe) == NULL) 980 return -EIO; 981 982 /* try to determine if there is no IR decoder on the I2C bus */ 983 for (i = 0; adap->dev->props.rc.legacy.rc_map_table != NULL && i < 5; i++) { 984 msleep(20); 985 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1) 986 goto no_IR; 987 if (ircode[0] == 0 && ircode[1] == 0) 988 continue; 989 if (ircode[2] + ircode[3] != 0xff) { 990 no_IR: 991 adap->dev->props.rc.legacy.rc_map_table = NULL; 992 info("No IR receiver detected on this device."); 993 break; 994 } 995 } 996 997 return 0; 998 } 999 1000 static struct dibx000_agc_config dib7070_agc_config = { 1001 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, 1002 1003 /* 1004 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, 1005 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 1006 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 1007 */ 1008 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | 1009 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 1010 .inv_gain = 600, 1011 .time_stabiliz = 10, 1012 .alpha_level = 0, 1013 .thlock = 118, 1014 .wbd_inv = 0, 1015 .wbd_ref = 3530, 1016 .wbd_sel = 1, 1017 .wbd_alpha = 5, 1018 .agc1_max = 65535, 1019 .agc1_min = 0, 1020 .agc2_max = 65535, 1021 .agc2_min = 0, 1022 .agc1_pt1 = 0, 1023 .agc1_pt2 = 40, 1024 .agc1_pt3 = 183, 1025 .agc1_slope1 = 206, 1026 .agc1_slope2 = 255, 1027 .agc2_pt1 = 72, 1028 .agc2_pt2 = 152, 1029 .agc2_slope1 = 88, 1030 .agc2_slope2 = 90, 1031 .alpha_mant = 17, 1032 .alpha_exp = 27, 1033 .beta_mant = 23, 1034 .beta_exp = 51, 1035 .perform_agc_softsplit = 0, 1036 }; 1037 1038 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = { 1039 .internal = 60000, 1040 .sampling = 15000, 1041 .pll_prediv = 1, 1042 .pll_ratio = 20, 1043 .pll_range = 3, 1044 .pll_reset = 1, 1045 .pll_bypass = 0, 1046 .enable_refdiv = 0, 1047 .bypclk_div = 0, 1048 .IO_CLK_en_core = 1, 1049 .ADClkSrc = 1, 1050 .modulo = 2, 1051 /* refsel, sel, freq_15k */ 1052 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 1053 .ifreq = (0 << 25) | 0, 1054 .timf = 20452225, 1055 .xtal_hz = 12000000, 1056 }; 1057 1058 static struct dib7000p_config cxusb_dualdig4_rev2_config = { 1059 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, 1060 .output_mpeg2_in_188_bytes = 1, 1061 1062 .agc_config_count = 1, 1063 .agc = &dib7070_agc_config, 1064 .bw = &dib7070_bw_config_12_mhz, 1065 .tuner_is_baseband = 1, 1066 .spur_protect = 1, 1067 1068 .gpio_dir = 0xfcef, 1069 .gpio_val = 0x0110, 1070 1071 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 1072 1073 .hostbus_diversity = 1, 1074 }; 1075 1076 struct dib0700_adapter_state { 1077 int (*set_param_save)(struct dvb_frontend *); 1078 struct dib7000p_ops dib7000p_ops; 1079 }; 1080 1081 static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap) 1082 { 1083 struct dib0700_adapter_state *state = adap->priv; 1084 1085 if (usb_set_interface(adap->dev->udev, 0, 1) < 0) 1086 err("set interface failed"); 1087 1088 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 1089 1090 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 1091 1092 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 1093 return -ENODEV; 1094 1095 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 1096 &cxusb_dualdig4_rev2_config) < 0) { 1097 printk(KERN_WARNING "Unable to enumerate dib7000p\n"); 1098 return -ENODEV; 1099 } 1100 1101 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, 1102 &cxusb_dualdig4_rev2_config); 1103 if (adap->fe_adap[0].fe == NULL) 1104 return -EIO; 1105 1106 return 0; 1107 } 1108 1109 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff) 1110 { 1111 struct dvb_usb_adapter *adap = fe->dvb->priv; 1112 struct dib0700_adapter_state *state = adap->priv; 1113 1114 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff); 1115 } 1116 1117 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff) 1118 { 1119 return 0; 1120 } 1121 1122 static struct dib0070_config dib7070p_dib0070_config = { 1123 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 1124 .reset = dib7070_tuner_reset, 1125 .sleep = dib7070_tuner_sleep, 1126 .clock_khz = 12000, 1127 }; 1128 1129 static int dib7070_set_param_override(struct dvb_frontend *fe) 1130 { 1131 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 1132 struct dvb_usb_adapter *adap = fe->dvb->priv; 1133 struct dib0700_adapter_state *state = adap->priv; 1134 1135 u16 offset; 1136 u8 band = BAND_OF_FREQUENCY(p->frequency/1000); 1137 switch (band) { 1138 case BAND_VHF: offset = 950; break; 1139 default: 1140 case BAND_UHF: offset = 550; break; 1141 } 1142 1143 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe)); 1144 1145 return state->set_param_save(fe); 1146 } 1147 1148 static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap) 1149 { 1150 struct dib0700_adapter_state *st = adap->priv; 1151 struct i2c_adapter *tun_i2c; 1152 1153 /* 1154 * No need to call dvb7000p_attach here, as it was called 1155 * already, as frontend_attach method is called first, and 1156 * tuner_attach is only called on sucess. 1157 */ 1158 tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, 1159 DIBX000_I2C_INTERFACE_TUNER, 1); 1160 1161 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, 1162 &dib7070p_dib0070_config) == NULL) 1163 return -ENODEV; 1164 1165 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 1166 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override; 1167 return 0; 1168 } 1169 1170 static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap) 1171 { 1172 if (usb_set_interface(adap->dev->udev, 0, 1) < 0) 1173 err("set interface failed"); 1174 1175 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); 1176 1177 /* reset the tuner and demodulator */ 1178 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0); 1179 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1); 1180 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); 1181 1182 adap->fe_adap[0].fe = dvb_attach(zl10353_attach, 1183 &cxusb_zl10353_xc3028_config, 1184 &adap->dev->i2c_adap); 1185 if ((adap->fe_adap[0].fe) != NULL) 1186 return 0; 1187 1188 adap->fe_adap[0].fe = dvb_attach(mt352_attach, 1189 &cxusb_mt352_xc3028_config, 1190 &adap->dev->i2c_adap); 1191 if ((adap->fe_adap[0].fe) != NULL) 1192 return 0; 1193 1194 return -EIO; 1195 } 1196 1197 static struct lgs8gxx_config d680_lgs8gl5_cfg = { 1198 .prod = LGS8GXX_PROD_LGS8GL5, 1199 .demod_address = 0x19, 1200 .serial_ts = 0, 1201 .ts_clk_pol = 0, 1202 .ts_clk_gated = 1, 1203 .if_clk_freq = 30400, /* 30.4 MHz */ 1204 .if_freq = 5725, /* 5.725 MHz */ 1205 .if_neg_center = 0, 1206 .ext_adc = 0, 1207 .adc_signed = 0, 1208 .if_neg_edge = 0, 1209 }; 1210 1211 static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap) 1212 { 1213 struct dvb_usb_device *d = adap->dev; 1214 int n; 1215 1216 /* Select required USB configuration */ 1217 if (usb_set_interface(d->udev, 0, 0) < 0) 1218 err("set interface failed"); 1219 1220 /* Unblock all USB pipes */ 1221 usb_clear_halt(d->udev, 1222 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1223 usb_clear_halt(d->udev, 1224 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1225 usb_clear_halt(d->udev, 1226 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); 1227 1228 /* Drain USB pipes to avoid hang after reboot */ 1229 for (n = 0; n < 5; n++) { 1230 cxusb_d680_dmb_drain_message(d); 1231 cxusb_d680_dmb_drain_video(d); 1232 msleep(200); 1233 } 1234 1235 /* Reset the tuner */ 1236 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) { 1237 err("clear tuner gpio failed"); 1238 return -EIO; 1239 } 1240 msleep(100); 1241 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) { 1242 err("set tuner gpio failed"); 1243 return -EIO; 1244 } 1245 msleep(100); 1246 1247 /* Attach frontend */ 1248 adap->fe_adap[0].fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap); 1249 if (adap->fe_adap[0].fe == NULL) 1250 return -EIO; 1251 1252 return 0; 1253 } 1254 1255 static struct atbm8830_config mygica_d689_atbm8830_cfg = { 1256 .prod = ATBM8830_PROD_8830, 1257 .demod_address = 0x40, 1258 .serial_ts = 0, 1259 .ts_sampling_edge = 1, 1260 .ts_clk_gated = 0, 1261 .osc_clk_freq = 30400, /* in kHz */ 1262 .if_freq = 0, /* zero IF */ 1263 .zif_swap_iq = 1, 1264 .agc_min = 0x2E, 1265 .agc_max = 0x90, 1266 .agc_hold_loop = 0, 1267 }; 1268 1269 static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap) 1270 { 1271 struct dvb_usb_device *d = adap->dev; 1272 1273 /* Select required USB configuration */ 1274 if (usb_set_interface(d->udev, 0, 0) < 0) 1275 err("set interface failed"); 1276 1277 /* Unblock all USB pipes */ 1278 usb_clear_halt(d->udev, 1279 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1280 usb_clear_halt(d->udev, 1281 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1282 usb_clear_halt(d->udev, 1283 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); 1284 1285 1286 /* Reset the tuner */ 1287 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) { 1288 err("clear tuner gpio failed"); 1289 return -EIO; 1290 } 1291 msleep(100); 1292 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) { 1293 err("set tuner gpio failed"); 1294 return -EIO; 1295 } 1296 msleep(100); 1297 1298 /* Attach frontend */ 1299 adap->fe_adap[0].fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg, 1300 &d->i2c_adap); 1301 if (adap->fe_adap[0].fe == NULL) 1302 return -EIO; 1303 1304 return 0; 1305 } 1306 1307 static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap) 1308 { 1309 struct dvb_usb_device *d = adap->dev; 1310 struct cxusb_state *st = d->priv; 1311 struct i2c_adapter *adapter; 1312 struct i2c_client *client_demod; 1313 struct i2c_client *client_tuner; 1314 struct i2c_board_info info; 1315 struct si2168_config si2168_config; 1316 struct si2157_config si2157_config; 1317 1318 /* Select required USB configuration */ 1319 if (usb_set_interface(d->udev, 0, 0) < 0) 1320 err("set interface failed"); 1321 1322 /* Unblock all USB pipes */ 1323 usb_clear_halt(d->udev, 1324 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1325 usb_clear_halt(d->udev, 1326 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint)); 1327 usb_clear_halt(d->udev, 1328 usb_rcvbulkpipe(d->udev, d->props.adapter[0].fe[0].stream.endpoint)); 1329 1330 /* attach frontend */ 1331 si2168_config.i2c_adapter = &adapter; 1332 si2168_config.fe = &adap->fe_adap[0].fe; 1333 si2168_config.ts_mode = SI2168_TS_PARALLEL; 1334 si2168_config.ts_clock_inv = 1; 1335 memset(&info, 0, sizeof(struct i2c_board_info)); 1336 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 1337 info.addr = 0x64; 1338 info.platform_data = &si2168_config; 1339 request_module(info.type); 1340 client_demod = i2c_new_device(&d->i2c_adap, &info); 1341 if (client_demod == NULL || client_demod->dev.driver == NULL) 1342 return -ENODEV; 1343 1344 if (!try_module_get(client_demod->dev.driver->owner)) { 1345 i2c_unregister_device(client_demod); 1346 return -ENODEV; 1347 } 1348 1349 st->i2c_client_demod = client_demod; 1350 1351 /* attach tuner */ 1352 memset(&si2157_config, 0, sizeof(si2157_config)); 1353 si2157_config.fe = adap->fe_adap[0].fe; 1354 si2157_config.if_port = 1; 1355 memset(&info, 0, sizeof(struct i2c_board_info)); 1356 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 1357 info.addr = 0x60; 1358 info.platform_data = &si2157_config; 1359 request_module(info.type); 1360 client_tuner = i2c_new_device(adapter, &info); 1361 if (client_tuner == NULL || client_tuner->dev.driver == NULL) { 1362 module_put(client_demod->dev.driver->owner); 1363 i2c_unregister_device(client_demod); 1364 return -ENODEV; 1365 } 1366 if (!try_module_get(client_tuner->dev.driver->owner)) { 1367 i2c_unregister_device(client_tuner); 1368 module_put(client_demod->dev.driver->owner); 1369 i2c_unregister_device(client_demod); 1370 return -ENODEV; 1371 } 1372 1373 st->i2c_client_tuner = client_tuner; 1374 1375 return 0; 1376 } 1377 1378 /* 1379 * DViCO has shipped two devices with the same USB ID, but only one of them 1380 * needs a firmware download. Check the device class details to see if they 1381 * have non-default values to decide whether the device is actually cold or 1382 * not, and forget a match if it turns out we selected the wrong device. 1383 */ 1384 static int bluebird_fx2_identify_state(struct usb_device *udev, 1385 struct dvb_usb_device_properties *props, 1386 struct dvb_usb_device_description **desc, 1387 int *cold) 1388 { 1389 int wascold = *cold; 1390 1391 *cold = udev->descriptor.bDeviceClass == 0xff && 1392 udev->descriptor.bDeviceSubClass == 0xff && 1393 udev->descriptor.bDeviceProtocol == 0xff; 1394 1395 if (*cold && !wascold) 1396 *desc = NULL; 1397 1398 return 0; 1399 } 1400 1401 /* 1402 * DViCO bluebird firmware needs the "warm" product ID to be patched into the 1403 * firmware file before download. 1404 */ 1405 1406 static const int dvico_firmware_id_offsets[] = { 6638, 3204 }; 1407 static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, 1408 const struct firmware *fw) 1409 { 1410 int pos; 1411 1412 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) { 1413 int idoff = dvico_firmware_id_offsets[pos]; 1414 1415 if (fw->size < idoff + 4) 1416 continue; 1417 1418 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) && 1419 fw->data[idoff + 1] == USB_VID_DVICO >> 8) { 1420 struct firmware new_fw; 1421 u8 *new_fw_data = vmalloc(fw->size); 1422 int ret; 1423 1424 if (!new_fw_data) 1425 return -ENOMEM; 1426 1427 memcpy(new_fw_data, fw->data, fw->size); 1428 new_fw.size = fw->size; 1429 new_fw.data = new_fw_data; 1430 1431 new_fw_data[idoff + 2] = 1432 le16_to_cpu(udev->descriptor.idProduct) + 1; 1433 new_fw_data[idoff + 3] = 1434 le16_to_cpu(udev->descriptor.idProduct) >> 8; 1435 1436 ret = usb_cypress_load_firmware(udev, &new_fw, 1437 CYPRESS_FX2); 1438 vfree(new_fw_data); 1439 return ret; 1440 } 1441 } 1442 1443 return -EINVAL; 1444 } 1445 1446 /* DVB USB Driver stuff */ 1447 static struct dvb_usb_device_properties cxusb_medion_properties; 1448 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties; 1449 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties; 1450 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties; 1451 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties; 1452 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties; 1453 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties; 1454 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties; 1455 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties; 1456 static struct dvb_usb_device_properties cxusb_aver_a868r_properties; 1457 static struct dvb_usb_device_properties cxusb_d680_dmb_properties; 1458 static struct dvb_usb_device_properties cxusb_mygica_d689_properties; 1459 static struct dvb_usb_device_properties cxusb_mygica_t230_properties; 1460 1461 static int cxusb_probe(struct usb_interface *intf, 1462 const struct usb_device_id *id) 1463 { 1464 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties, 1465 THIS_MODULE, NULL, adapter_nr) || 1466 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties, 1467 THIS_MODULE, NULL, adapter_nr) || 1468 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties, 1469 THIS_MODULE, NULL, adapter_nr) || 1470 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties, 1471 THIS_MODULE, NULL, adapter_nr) || 1472 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties, 1473 THIS_MODULE, NULL, adapter_nr) || 1474 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties, 1475 THIS_MODULE, NULL, adapter_nr) || 1476 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties, 1477 THIS_MODULE, NULL, adapter_nr) || 1478 0 == dvb_usb_device_init(intf, 1479 &cxusb_bluebird_nano2_needsfirmware_properties, 1480 THIS_MODULE, NULL, adapter_nr) || 1481 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties, 1482 THIS_MODULE, NULL, adapter_nr) || 1483 0 == dvb_usb_device_init(intf, 1484 &cxusb_bluebird_dualdig4_rev2_properties, 1485 THIS_MODULE, NULL, adapter_nr) || 1486 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties, 1487 THIS_MODULE, NULL, adapter_nr) || 1488 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties, 1489 THIS_MODULE, NULL, adapter_nr) || 1490 0 == dvb_usb_device_init(intf, &cxusb_mygica_t230_properties, 1491 THIS_MODULE, NULL, adapter_nr) || 1492 0) 1493 return 0; 1494 1495 return -EINVAL; 1496 } 1497 1498 static void cxusb_disconnect(struct usb_interface *intf) 1499 { 1500 struct dvb_usb_device *d = usb_get_intfdata(intf); 1501 struct cxusb_state *st = d->priv; 1502 struct i2c_client *client; 1503 1504 /* remove I2C client for tuner */ 1505 client = st->i2c_client_tuner; 1506 if (client) { 1507 module_put(client->dev.driver->owner); 1508 i2c_unregister_device(client); 1509 } 1510 1511 /* remove I2C client for demodulator */ 1512 client = st->i2c_client_demod; 1513 if (client) { 1514 module_put(client->dev.driver->owner); 1515 i2c_unregister_device(client); 1516 } 1517 1518 dvb_usb_device_exit(intf); 1519 } 1520 1521 enum cxusb_table_index { 1522 MEDION_MD95700, 1523 DVICO_BLUEBIRD_LG064F_COLD, 1524 DVICO_BLUEBIRD_LG064F_WARM, 1525 DVICO_BLUEBIRD_DUAL_1_COLD, 1526 DVICO_BLUEBIRD_DUAL_1_WARM, 1527 DVICO_BLUEBIRD_LGZ201_COLD, 1528 DVICO_BLUEBIRD_LGZ201_WARM, 1529 DVICO_BLUEBIRD_TH7579_COLD, 1530 DVICO_BLUEBIRD_TH7579_WARM, 1531 DIGITALNOW_BLUEBIRD_DUAL_1_COLD, 1532 DIGITALNOW_BLUEBIRD_DUAL_1_WARM, 1533 DVICO_BLUEBIRD_DUAL_2_COLD, 1534 DVICO_BLUEBIRD_DUAL_2_WARM, 1535 DVICO_BLUEBIRD_DUAL_4, 1536 DVICO_BLUEBIRD_DVB_T_NANO_2, 1537 DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM, 1538 AVERMEDIA_VOLAR_A868R, 1539 DVICO_BLUEBIRD_DUAL_4_REV_2, 1540 CONEXANT_D680_DMB, 1541 MYGICA_D689, 1542 MYGICA_T230, 1543 NR__cxusb_table_index 1544 }; 1545 1546 static struct usb_device_id cxusb_table[NR__cxusb_table_index + 1] = { 1547 [MEDION_MD95700] = { 1548 USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) 1549 }, 1550 [DVICO_BLUEBIRD_LG064F_COLD] = { 1551 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) 1552 }, 1553 [DVICO_BLUEBIRD_LG064F_WARM] = { 1554 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) 1555 }, 1556 [DVICO_BLUEBIRD_DUAL_1_COLD] = { 1557 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) 1558 }, 1559 [DVICO_BLUEBIRD_DUAL_1_WARM] = { 1560 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) 1561 }, 1562 [DVICO_BLUEBIRD_LGZ201_COLD] = { 1563 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) 1564 }, 1565 [DVICO_BLUEBIRD_LGZ201_WARM] = { 1566 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) 1567 }, 1568 [DVICO_BLUEBIRD_TH7579_COLD] = { 1569 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) 1570 }, 1571 [DVICO_BLUEBIRD_TH7579_WARM] = { 1572 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) 1573 }, 1574 [DIGITALNOW_BLUEBIRD_DUAL_1_COLD] = { 1575 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) 1576 }, 1577 [DIGITALNOW_BLUEBIRD_DUAL_1_WARM] = { 1578 USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) 1579 }, 1580 [DVICO_BLUEBIRD_DUAL_2_COLD] = { 1581 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) 1582 }, 1583 [DVICO_BLUEBIRD_DUAL_2_WARM] = { 1584 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) 1585 }, 1586 [DVICO_BLUEBIRD_DUAL_4] = { 1587 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) 1588 }, 1589 [DVICO_BLUEBIRD_DVB_T_NANO_2] = { 1590 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) 1591 }, 1592 [DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM] = { 1593 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) 1594 }, 1595 [AVERMEDIA_VOLAR_A868R] = { 1596 USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) 1597 }, 1598 [DVICO_BLUEBIRD_DUAL_4_REV_2] = { 1599 USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) 1600 }, 1601 [CONEXANT_D680_DMB] = { 1602 USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) 1603 }, 1604 [MYGICA_D689] = { 1605 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) 1606 }, 1607 [MYGICA_T230] = { 1608 USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230) 1609 }, 1610 {} /* Terminating entry */ 1611 }; 1612 MODULE_DEVICE_TABLE (usb, cxusb_table); 1613 1614 static struct dvb_usb_device_properties cxusb_medion_properties = { 1615 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1616 1617 .usb_ctrl = CYPRESS_FX2, 1618 1619 .size_of_priv = sizeof(struct cxusb_state), 1620 1621 .num_adapters = 1, 1622 .adapter = { 1623 { 1624 .num_frontends = 1, 1625 .fe = {{ 1626 .streaming_ctrl = cxusb_streaming_ctrl, 1627 .frontend_attach = cxusb_cx22702_frontend_attach, 1628 .tuner_attach = cxusb_fmd1216me_tuner_attach, 1629 /* parameter for the MPEG2-data transfer */ 1630 .stream = { 1631 .type = USB_BULK, 1632 .count = 5, 1633 .endpoint = 0x02, 1634 .u = { 1635 .bulk = { 1636 .buffersize = 8192, 1637 } 1638 } 1639 }, 1640 }}, 1641 }, 1642 }, 1643 .power_ctrl = cxusb_power_ctrl, 1644 1645 .i2c_algo = &cxusb_i2c_algo, 1646 1647 .generic_bulk_ctrl_endpoint = 0x01, 1648 1649 .num_device_descs = 1, 1650 .devices = { 1651 { "Medion MD95700 (MDUSBTV-HYBRID)", 1652 { NULL }, 1653 { &cxusb_table[MEDION_MD95700], NULL }, 1654 }, 1655 } 1656 }; 1657 1658 static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = { 1659 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1660 1661 .usb_ctrl = DEVICE_SPECIFIC, 1662 .firmware = "dvb-usb-bluebird-01.fw", 1663 .download_firmware = bluebird_patch_dvico_firmware_download, 1664 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1665 use usb alt setting 7 for EP2 transfer (atsc) */ 1666 1667 .size_of_priv = sizeof(struct cxusb_state), 1668 1669 .num_adapters = 1, 1670 .adapter = { 1671 { 1672 .num_frontends = 1, 1673 .fe = {{ 1674 .streaming_ctrl = cxusb_streaming_ctrl, 1675 .frontend_attach = cxusb_lgdt3303_frontend_attach, 1676 .tuner_attach = cxusb_lgh064f_tuner_attach, 1677 1678 /* parameter for the MPEG2-data transfer */ 1679 .stream = { 1680 .type = USB_BULK, 1681 .count = 5, 1682 .endpoint = 0x02, 1683 .u = { 1684 .bulk = { 1685 .buffersize = 8192, 1686 } 1687 } 1688 }, 1689 }}, 1690 }, 1691 }, 1692 1693 .power_ctrl = cxusb_bluebird_power_ctrl, 1694 1695 .i2c_algo = &cxusb_i2c_algo, 1696 1697 .rc.legacy = { 1698 .rc_interval = 100, 1699 .rc_map_table = rc_map_dvico_portable_table, 1700 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1701 .rc_query = cxusb_rc_query, 1702 }, 1703 1704 .generic_bulk_ctrl_endpoint = 0x01, 1705 1706 .num_device_descs = 1, 1707 .devices = { 1708 { "DViCO FusionHDTV5 USB Gold", 1709 { &cxusb_table[DVICO_BLUEBIRD_LG064F_COLD], NULL }, 1710 { &cxusb_table[DVICO_BLUEBIRD_LG064F_WARM], NULL }, 1711 }, 1712 } 1713 }; 1714 1715 static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = { 1716 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1717 1718 .usb_ctrl = DEVICE_SPECIFIC, 1719 .firmware = "dvb-usb-bluebird-01.fw", 1720 .download_firmware = bluebird_patch_dvico_firmware_download, 1721 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1722 use usb alt setting 7 for EP2 transfer (atsc) */ 1723 1724 .size_of_priv = sizeof(struct cxusb_state), 1725 1726 .num_adapters = 1, 1727 .adapter = { 1728 { 1729 .num_frontends = 1, 1730 .fe = {{ 1731 .streaming_ctrl = cxusb_streaming_ctrl, 1732 .frontend_attach = cxusb_dee1601_frontend_attach, 1733 .tuner_attach = cxusb_dee1601_tuner_attach, 1734 /* parameter for the MPEG2-data transfer */ 1735 .stream = { 1736 .type = USB_BULK, 1737 .count = 5, 1738 .endpoint = 0x04, 1739 .u = { 1740 .bulk = { 1741 .buffersize = 8192, 1742 } 1743 } 1744 }, 1745 }}, 1746 }, 1747 }, 1748 1749 .power_ctrl = cxusb_bluebird_power_ctrl, 1750 1751 .i2c_algo = &cxusb_i2c_algo, 1752 1753 .rc.legacy = { 1754 .rc_interval = 150, 1755 .rc_map_table = rc_map_dvico_mce_table, 1756 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table), 1757 .rc_query = cxusb_rc_query, 1758 }, 1759 1760 .generic_bulk_ctrl_endpoint = 0x01, 1761 1762 .num_device_descs = 3, 1763 .devices = { 1764 { "DViCO FusionHDTV DVB-T Dual USB", 1765 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_COLD], NULL }, 1766 { &cxusb_table[DVICO_BLUEBIRD_DUAL_1_WARM], NULL }, 1767 }, 1768 { "DigitalNow DVB-T Dual USB", 1769 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_COLD], NULL }, 1770 { &cxusb_table[DIGITALNOW_BLUEBIRD_DUAL_1_WARM], NULL }, 1771 }, 1772 { "DViCO FusionHDTV DVB-T Dual Digital 2", 1773 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_COLD], NULL }, 1774 { &cxusb_table[DVICO_BLUEBIRD_DUAL_2_WARM], NULL }, 1775 }, 1776 } 1777 }; 1778 1779 static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = { 1780 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1781 1782 .usb_ctrl = DEVICE_SPECIFIC, 1783 .firmware = "dvb-usb-bluebird-01.fw", 1784 .download_firmware = bluebird_patch_dvico_firmware_download, 1785 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1786 use usb alt setting 7 for EP2 transfer (atsc) */ 1787 1788 .size_of_priv = sizeof(struct cxusb_state), 1789 1790 .num_adapters = 2, 1791 .adapter = { 1792 { 1793 .num_frontends = 1, 1794 .fe = {{ 1795 .streaming_ctrl = cxusb_streaming_ctrl, 1796 .frontend_attach = cxusb_mt352_frontend_attach, 1797 .tuner_attach = cxusb_lgz201_tuner_attach, 1798 1799 /* parameter for the MPEG2-data transfer */ 1800 .stream = { 1801 .type = USB_BULK, 1802 .count = 5, 1803 .endpoint = 0x04, 1804 .u = { 1805 .bulk = { 1806 .buffersize = 8192, 1807 } 1808 } 1809 }, 1810 }}, 1811 }, 1812 }, 1813 .power_ctrl = cxusb_bluebird_power_ctrl, 1814 1815 .i2c_algo = &cxusb_i2c_algo, 1816 1817 .rc.legacy = { 1818 .rc_interval = 100, 1819 .rc_map_table = rc_map_dvico_portable_table, 1820 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1821 .rc_query = cxusb_rc_query, 1822 }, 1823 1824 .generic_bulk_ctrl_endpoint = 0x01, 1825 .num_device_descs = 1, 1826 .devices = { 1827 { "DViCO FusionHDTV DVB-T USB (LGZ201)", 1828 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_COLD], NULL }, 1829 { &cxusb_table[DVICO_BLUEBIRD_LGZ201_WARM], NULL }, 1830 }, 1831 } 1832 }; 1833 1834 static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = { 1835 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1836 1837 .usb_ctrl = DEVICE_SPECIFIC, 1838 .firmware = "dvb-usb-bluebird-01.fw", 1839 .download_firmware = bluebird_patch_dvico_firmware_download, 1840 /* use usb alt setting 0 for EP4 transfer (dvb-t), 1841 use usb alt setting 7 for EP2 transfer (atsc) */ 1842 1843 .size_of_priv = sizeof(struct cxusb_state), 1844 1845 .num_adapters = 1, 1846 .adapter = { 1847 { 1848 .num_frontends = 1, 1849 .fe = {{ 1850 .streaming_ctrl = cxusb_streaming_ctrl, 1851 .frontend_attach = cxusb_mt352_frontend_attach, 1852 .tuner_attach = cxusb_dtt7579_tuner_attach, 1853 1854 /* parameter for the MPEG2-data transfer */ 1855 .stream = { 1856 .type = USB_BULK, 1857 .count = 5, 1858 .endpoint = 0x04, 1859 .u = { 1860 .bulk = { 1861 .buffersize = 8192, 1862 } 1863 } 1864 }, 1865 }}, 1866 }, 1867 }, 1868 .power_ctrl = cxusb_bluebird_power_ctrl, 1869 1870 .i2c_algo = &cxusb_i2c_algo, 1871 1872 .rc.legacy = { 1873 .rc_interval = 100, 1874 .rc_map_table = rc_map_dvico_portable_table, 1875 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1876 .rc_query = cxusb_rc_query, 1877 }, 1878 1879 .generic_bulk_ctrl_endpoint = 0x01, 1880 1881 .num_device_descs = 1, 1882 .devices = { 1883 { "DViCO FusionHDTV DVB-T USB (TH7579)", 1884 { &cxusb_table[DVICO_BLUEBIRD_TH7579_COLD], NULL }, 1885 { &cxusb_table[DVICO_BLUEBIRD_TH7579_WARM], NULL }, 1886 }, 1887 } 1888 }; 1889 1890 static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = { 1891 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1892 1893 .usb_ctrl = CYPRESS_FX2, 1894 1895 .size_of_priv = sizeof(struct cxusb_state), 1896 1897 .num_adapters = 1, 1898 .adapter = { 1899 { 1900 .num_frontends = 1, 1901 .fe = {{ 1902 .streaming_ctrl = cxusb_streaming_ctrl, 1903 .frontend_attach = cxusb_dualdig4_frontend_attach, 1904 .tuner_attach = cxusb_dvico_xc3028_tuner_attach, 1905 /* parameter for the MPEG2-data transfer */ 1906 .stream = { 1907 .type = USB_BULK, 1908 .count = 5, 1909 .endpoint = 0x02, 1910 .u = { 1911 .bulk = { 1912 .buffersize = 8192, 1913 } 1914 } 1915 }, 1916 }}, 1917 }, 1918 }, 1919 1920 .power_ctrl = cxusb_power_ctrl, 1921 1922 .i2c_algo = &cxusb_i2c_algo, 1923 1924 .generic_bulk_ctrl_endpoint = 0x01, 1925 1926 .rc.legacy = { 1927 .rc_interval = 100, 1928 .rc_map_table = rc_map_dvico_mce_table, 1929 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table), 1930 .rc_query = cxusb_bluebird2_rc_query, 1931 }, 1932 1933 .num_device_descs = 1, 1934 .devices = { 1935 { "DViCO FusionHDTV DVB-T Dual Digital 4", 1936 { NULL }, 1937 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4], NULL }, 1938 }, 1939 } 1940 }; 1941 1942 static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = { 1943 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1944 1945 .usb_ctrl = CYPRESS_FX2, 1946 .identify_state = bluebird_fx2_identify_state, 1947 1948 .size_of_priv = sizeof(struct cxusb_state), 1949 1950 .num_adapters = 1, 1951 .adapter = { 1952 { 1953 .num_frontends = 1, 1954 .fe = {{ 1955 .streaming_ctrl = cxusb_streaming_ctrl, 1956 .frontend_attach = cxusb_nano2_frontend_attach, 1957 .tuner_attach = cxusb_dvico_xc3028_tuner_attach, 1958 /* parameter for the MPEG2-data transfer */ 1959 .stream = { 1960 .type = USB_BULK, 1961 .count = 5, 1962 .endpoint = 0x02, 1963 .u = { 1964 .bulk = { 1965 .buffersize = 8192, 1966 } 1967 } 1968 }, 1969 }}, 1970 }, 1971 }, 1972 1973 .power_ctrl = cxusb_nano2_power_ctrl, 1974 1975 .i2c_algo = &cxusb_i2c_algo, 1976 1977 .generic_bulk_ctrl_endpoint = 0x01, 1978 1979 .rc.legacy = { 1980 .rc_interval = 100, 1981 .rc_map_table = rc_map_dvico_portable_table, 1982 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 1983 .rc_query = cxusb_bluebird2_rc_query, 1984 }, 1985 1986 .num_device_descs = 1, 1987 .devices = { 1988 { "DViCO FusionHDTV DVB-T NANO2", 1989 { NULL }, 1990 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL }, 1991 }, 1992 } 1993 }; 1994 1995 static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = { 1996 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1997 1998 .usb_ctrl = DEVICE_SPECIFIC, 1999 .firmware = "dvb-usb-bluebird-02.fw", 2000 .download_firmware = bluebird_patch_dvico_firmware_download, 2001 .identify_state = bluebird_fx2_identify_state, 2002 2003 .size_of_priv = sizeof(struct cxusb_state), 2004 2005 .num_adapters = 1, 2006 .adapter = { 2007 { 2008 .num_frontends = 1, 2009 .fe = {{ 2010 .streaming_ctrl = cxusb_streaming_ctrl, 2011 .frontend_attach = cxusb_nano2_frontend_attach, 2012 .tuner_attach = cxusb_dvico_xc3028_tuner_attach, 2013 /* parameter for the MPEG2-data transfer */ 2014 .stream = { 2015 .type = USB_BULK, 2016 .count = 5, 2017 .endpoint = 0x02, 2018 .u = { 2019 .bulk = { 2020 .buffersize = 8192, 2021 } 2022 } 2023 }, 2024 }}, 2025 }, 2026 }, 2027 2028 .power_ctrl = cxusb_nano2_power_ctrl, 2029 2030 .i2c_algo = &cxusb_i2c_algo, 2031 2032 .generic_bulk_ctrl_endpoint = 0x01, 2033 2034 .rc.legacy = { 2035 .rc_interval = 100, 2036 .rc_map_table = rc_map_dvico_portable_table, 2037 .rc_map_size = ARRAY_SIZE(rc_map_dvico_portable_table), 2038 .rc_query = cxusb_rc_query, 2039 }, 2040 2041 .num_device_descs = 1, 2042 .devices = { 2043 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware", 2044 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2], NULL }, 2045 { &cxusb_table[DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM], NULL }, 2046 }, 2047 } 2048 }; 2049 2050 static struct dvb_usb_device_properties cxusb_aver_a868r_properties = { 2051 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2052 2053 .usb_ctrl = CYPRESS_FX2, 2054 2055 .size_of_priv = sizeof(struct cxusb_state), 2056 2057 .num_adapters = 1, 2058 .adapter = { 2059 { 2060 .num_frontends = 1, 2061 .fe = {{ 2062 .streaming_ctrl = cxusb_aver_streaming_ctrl, 2063 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach, 2064 .tuner_attach = cxusb_mxl5003s_tuner_attach, 2065 /* parameter for the MPEG2-data transfer */ 2066 .stream = { 2067 .type = USB_BULK, 2068 .count = 5, 2069 .endpoint = 0x04, 2070 .u = { 2071 .bulk = { 2072 .buffersize = 8192, 2073 } 2074 } 2075 }, 2076 }}, 2077 }, 2078 }, 2079 .power_ctrl = cxusb_aver_power_ctrl, 2080 2081 .i2c_algo = &cxusb_i2c_algo, 2082 2083 .generic_bulk_ctrl_endpoint = 0x01, 2084 2085 .num_device_descs = 1, 2086 .devices = { 2087 { "AVerMedia AVerTVHD Volar (A868R)", 2088 { NULL }, 2089 { &cxusb_table[AVERMEDIA_VOLAR_A868R], NULL }, 2090 }, 2091 } 2092 }; 2093 2094 static 2095 struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = { 2096 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2097 2098 .usb_ctrl = CYPRESS_FX2, 2099 2100 .size_of_priv = sizeof(struct cxusb_state), 2101 2102 .num_adapters = 1, 2103 .adapter = { 2104 { 2105 .size_of_priv = sizeof(struct dib0700_adapter_state), 2106 .num_frontends = 1, 2107 .fe = {{ 2108 .streaming_ctrl = cxusb_streaming_ctrl, 2109 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach, 2110 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach, 2111 /* parameter for the MPEG2-data transfer */ 2112 .stream = { 2113 .type = USB_BULK, 2114 .count = 7, 2115 .endpoint = 0x02, 2116 .u = { 2117 .bulk = { 2118 .buffersize = 4096, 2119 } 2120 } 2121 }, 2122 }}, 2123 }, 2124 }, 2125 2126 .power_ctrl = cxusb_bluebird_power_ctrl, 2127 2128 .i2c_algo = &cxusb_i2c_algo, 2129 2130 .generic_bulk_ctrl_endpoint = 0x01, 2131 2132 .rc.legacy = { 2133 .rc_interval = 100, 2134 .rc_map_table = rc_map_dvico_mce_table, 2135 .rc_map_size = ARRAY_SIZE(rc_map_dvico_mce_table), 2136 .rc_query = cxusb_rc_query, 2137 }, 2138 2139 .num_device_descs = 1, 2140 .devices = { 2141 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)", 2142 { NULL }, 2143 { &cxusb_table[DVICO_BLUEBIRD_DUAL_4_REV_2], NULL }, 2144 }, 2145 } 2146 }; 2147 2148 static struct dvb_usb_device_properties cxusb_d680_dmb_properties = { 2149 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2150 2151 .usb_ctrl = CYPRESS_FX2, 2152 2153 .size_of_priv = sizeof(struct cxusb_state), 2154 2155 .num_adapters = 1, 2156 .adapter = { 2157 { 2158 .num_frontends = 1, 2159 .fe = {{ 2160 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl, 2161 .frontend_attach = cxusb_d680_dmb_frontend_attach, 2162 .tuner_attach = cxusb_d680_dmb_tuner_attach, 2163 2164 /* parameter for the MPEG2-data transfer */ 2165 .stream = { 2166 .type = USB_BULK, 2167 .count = 5, 2168 .endpoint = 0x02, 2169 .u = { 2170 .bulk = { 2171 .buffersize = 8192, 2172 } 2173 } 2174 }, 2175 }}, 2176 }, 2177 }, 2178 2179 .power_ctrl = cxusb_d680_dmb_power_ctrl, 2180 2181 .i2c_algo = &cxusb_i2c_algo, 2182 2183 .generic_bulk_ctrl_endpoint = 0x01, 2184 2185 .rc.legacy = { 2186 .rc_interval = 100, 2187 .rc_map_table = rc_map_d680_dmb_table, 2188 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), 2189 .rc_query = cxusb_d680_dmb_rc_query, 2190 }, 2191 2192 .num_device_descs = 1, 2193 .devices = { 2194 { 2195 "Conexant DMB-TH Stick", 2196 { NULL }, 2197 { &cxusb_table[CONEXANT_D680_DMB], NULL }, 2198 }, 2199 } 2200 }; 2201 2202 static struct dvb_usb_device_properties cxusb_mygica_d689_properties = { 2203 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2204 2205 .usb_ctrl = CYPRESS_FX2, 2206 2207 .size_of_priv = sizeof(struct cxusb_state), 2208 2209 .num_adapters = 1, 2210 .adapter = { 2211 { 2212 .num_frontends = 1, 2213 .fe = {{ 2214 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl, 2215 .frontend_attach = cxusb_mygica_d689_frontend_attach, 2216 .tuner_attach = cxusb_mygica_d689_tuner_attach, 2217 2218 /* parameter for the MPEG2-data transfer */ 2219 .stream = { 2220 .type = USB_BULK, 2221 .count = 5, 2222 .endpoint = 0x02, 2223 .u = { 2224 .bulk = { 2225 .buffersize = 8192, 2226 } 2227 } 2228 }, 2229 }}, 2230 }, 2231 }, 2232 2233 .power_ctrl = cxusb_d680_dmb_power_ctrl, 2234 2235 .i2c_algo = &cxusb_i2c_algo, 2236 2237 .generic_bulk_ctrl_endpoint = 0x01, 2238 2239 .rc.legacy = { 2240 .rc_interval = 100, 2241 .rc_map_table = rc_map_d680_dmb_table, 2242 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), 2243 .rc_query = cxusb_d680_dmb_rc_query, 2244 }, 2245 2246 .num_device_descs = 1, 2247 .devices = { 2248 { 2249 "Mygica D689 DMB-TH", 2250 { NULL }, 2251 { &cxusb_table[MYGICA_D689], NULL }, 2252 }, 2253 } 2254 }; 2255 2256 static struct dvb_usb_device_properties cxusb_mygica_t230_properties = { 2257 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2258 2259 .usb_ctrl = CYPRESS_FX2, 2260 2261 .size_of_priv = sizeof(struct cxusb_state), 2262 2263 .num_adapters = 1, 2264 .adapter = { 2265 { 2266 .num_frontends = 1, 2267 .fe = {{ 2268 .streaming_ctrl = cxusb_streaming_ctrl, 2269 .frontend_attach = cxusb_mygica_t230_frontend_attach, 2270 2271 /* parameter for the MPEG2-data transfer */ 2272 .stream = { 2273 .type = USB_BULK, 2274 .count = 5, 2275 .endpoint = 0x02, 2276 .u = { 2277 .bulk = { 2278 .buffersize = 8192, 2279 } 2280 } 2281 }, 2282 } }, 2283 }, 2284 }, 2285 2286 .power_ctrl = cxusb_d680_dmb_power_ctrl, 2287 2288 .i2c_algo = &cxusb_i2c_algo, 2289 2290 .generic_bulk_ctrl_endpoint = 0x01, 2291 2292 .rc.legacy = { 2293 .rc_interval = 100, 2294 .rc_map_table = rc_map_d680_dmb_table, 2295 .rc_map_size = ARRAY_SIZE(rc_map_d680_dmb_table), 2296 .rc_query = cxusb_d680_dmb_rc_query, 2297 }, 2298 2299 .num_device_descs = 1, 2300 .devices = { 2301 { 2302 "Mygica T230 DVB-T/T2/C", 2303 { NULL }, 2304 { &cxusb_table[MYGICA_T230], NULL }, 2305 }, 2306 } 2307 }; 2308 2309 static struct usb_driver cxusb_driver = { 2310 .name = "dvb_usb_cxusb", 2311 .probe = cxusb_probe, 2312 .disconnect = cxusb_disconnect, 2313 .id_table = cxusb_table, 2314 }; 2315 2316 module_usb_driver(cxusb_driver); 2317 2318 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>"); 2319 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); 2320 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); 2321 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design"); 2322 MODULE_VERSION("1.0-alpha"); 2323 MODULE_LICENSE("GPL"); 2324