1 // SPDX-License-Identifier: GPL-2.0-only 2 /* DVB USB framework compliant Linux driver for the 3 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 4 * TeVii S421, S480, S482, S600, S630, S632, S650, S660, S662, 5 * Prof 1100, 7500, 6 * Geniatech SU3000, T220, 7 * TechnoTrend S2-4600, 8 * Terratec Cinergy S2 cards 9 * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by) 10 * 11 * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information 12 */ 13 #include <media/dvb-usb-ids.h> 14 #include "dw2102.h" 15 #include "si21xx.h" 16 #include "stv0299.h" 17 #include "z0194a.h" 18 #include "stv0288.h" 19 #include "stb6000.h" 20 #include "eds1547.h" 21 #include "cx24116.h" 22 #include "tda1002x.h" 23 #include "mt312.h" 24 #include "zl10039.h" 25 #include "ts2020.h" 26 #include "ds3000.h" 27 #include "stv0900.h" 28 #include "stv6110.h" 29 #include "stb6100.h" 30 #include "stb6100_proc.h" 31 #include "m88rs2000.h" 32 #include "tda18271.h" 33 #include "cxd2820r.h" 34 #include "m88ds3103.h" 35 36 /* Max transfer size done by I2C transfer functions */ 37 #define MAX_XFER_SIZE 64 38 39 40 #define DW210X_READ_MSG 0 41 #define DW210X_WRITE_MSG 1 42 43 #define REG_1F_SYMBOLRATE_BYTE0 0x1f 44 #define REG_20_SYMBOLRATE_BYTE1 0x20 45 #define REG_21_SYMBOLRATE_BYTE2 0x21 46 /* on my own*/ 47 #define DW2102_VOLTAGE_CTRL (0x1800) 48 #define SU3000_STREAM_CTRL (0x1900) 49 #define DW2102_RC_QUERY (0x1a00) 50 #define DW2102_LED_CTRL (0x1b00) 51 52 #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" 53 #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" 54 #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" 55 #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" 56 #define S630_FIRMWARE "dvb-usb-s630.fw" 57 #define S660_FIRMWARE "dvb-usb-s660.fw" 58 #define P1100_FIRMWARE "dvb-usb-p1100.fw" 59 #define P7500_FIRMWARE "dvb-usb-p7500.fw" 60 61 #define err_str "did not find the firmware file '%s'. You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware" 62 63 struct dw2102_state { 64 u8 initialized; 65 u8 last_lock; 66 u8 data[MAX_XFER_SIZE + 4]; 67 struct i2c_client *i2c_client_demod; 68 struct i2c_client *i2c_client_tuner; 69 70 /* fe hook functions*/ 71 int (*old_set_voltage)(struct dvb_frontend *f, enum fe_sec_voltage v); 72 int (*fe_read_status)(struct dvb_frontend *fe, 73 enum fe_status *status); 74 }; 75 76 /* debug */ 77 static int dvb_usb_dw2102_debug; 78 module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); 79 MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." 80 DVB_USB_DEBUG_STATUS); 81 82 /* demod probe */ 83 static int demod_probe = 1; 84 module_param_named(demod, demod_probe, int, 0644); 85 MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able))."); 86 87 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 88 89 static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, 90 u16 index, u8 * data, u16 len, int flags) 91 { 92 int ret; 93 u8 *u8buf; 94 unsigned int pipe = (flags == DW210X_READ_MSG) ? 95 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); 96 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; 97 98 u8buf = kmalloc(len, GFP_KERNEL); 99 if (!u8buf) 100 return -ENOMEM; 101 102 103 if (flags == DW210X_WRITE_MSG) 104 memcpy(u8buf, data, len); 105 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, 106 value, index , u8buf, len, 2000); 107 108 if (flags == DW210X_READ_MSG) 109 memcpy(data, u8buf, len); 110 111 kfree(u8buf); 112 return ret; 113 } 114 115 /* I2C */ 116 static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 117 int num) 118 { 119 struct dvb_usb_device *d = i2c_get_adapdata(adap); 120 int i = 0; 121 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; 122 u16 value; 123 124 if (!d) 125 return -ENODEV; 126 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 127 return -EAGAIN; 128 129 switch (num) { 130 case 2: 131 if (msg[0].len < 1) { 132 num = -EOPNOTSUPP; 133 break; 134 } 135 /* read stv0299 register */ 136 value = msg[0].buf[0];/* register */ 137 for (i = 0; i < msg[1].len; i++) { 138 dw210x_op_rw(d->udev, 0xb5, value + i, 0, 139 buf6, 2, DW210X_READ_MSG); 140 msg[1].buf[i] = buf6[0]; 141 } 142 break; 143 case 1: 144 switch (msg[0].addr) { 145 case 0x68: 146 if (msg[0].len < 2) { 147 num = -EOPNOTSUPP; 148 break; 149 } 150 /* write to stv0299 register */ 151 buf6[0] = 0x2a; 152 buf6[1] = msg[0].buf[0]; 153 buf6[2] = msg[0].buf[1]; 154 dw210x_op_rw(d->udev, 0xb2, 0, 0, 155 buf6, 3, DW210X_WRITE_MSG); 156 break; 157 case 0x60: 158 if (msg[0].flags == 0) { 159 if (msg[0].len < 4) { 160 num = -EOPNOTSUPP; 161 break; 162 } 163 /* write to tuner pll */ 164 buf6[0] = 0x2c; 165 buf6[1] = 5; 166 buf6[2] = 0xc0; 167 buf6[3] = msg[0].buf[0]; 168 buf6[4] = msg[0].buf[1]; 169 buf6[5] = msg[0].buf[2]; 170 buf6[6] = msg[0].buf[3]; 171 dw210x_op_rw(d->udev, 0xb2, 0, 0, 172 buf6, 7, DW210X_WRITE_MSG); 173 } else { 174 if (msg[0].len < 1) { 175 num = -EOPNOTSUPP; 176 break; 177 } 178 /* read from tuner */ 179 dw210x_op_rw(d->udev, 0xb5, 0, 0, 180 buf6, 1, DW210X_READ_MSG); 181 msg[0].buf[0] = buf6[0]; 182 } 183 break; 184 case (DW2102_RC_QUERY): 185 if (msg[0].len < 2) { 186 num = -EOPNOTSUPP; 187 break; 188 } 189 dw210x_op_rw(d->udev, 0xb8, 0, 0, 190 buf6, 2, DW210X_READ_MSG); 191 msg[0].buf[0] = buf6[0]; 192 msg[0].buf[1] = buf6[1]; 193 break; 194 case (DW2102_VOLTAGE_CTRL): 195 if (msg[0].len < 1) { 196 num = -EOPNOTSUPP; 197 break; 198 } 199 buf6[0] = 0x30; 200 buf6[1] = msg[0].buf[0]; 201 dw210x_op_rw(d->udev, 0xb2, 0, 0, 202 buf6, 2, DW210X_WRITE_MSG); 203 break; 204 } 205 206 break; 207 } 208 209 mutex_unlock(&d->i2c_mutex); 210 return num; 211 } 212 213 static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, 214 struct i2c_msg msg[], int num) 215 { 216 struct dvb_usb_device *d = i2c_get_adapdata(adap); 217 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; 218 219 if (!d) 220 return -ENODEV; 221 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 222 return -EAGAIN; 223 224 switch (num) { 225 case 2: 226 if (msg[0].len != 1) { 227 warn("i2c rd: len=%d is not 1!\n", 228 msg[0].len); 229 num = -EOPNOTSUPP; 230 break; 231 } 232 233 if (2 + msg[1].len > sizeof(buf6)) { 234 warn("i2c rd: len=%d is too big!\n", 235 msg[1].len); 236 num = -EOPNOTSUPP; 237 break; 238 } 239 240 /* read si2109 register by number */ 241 buf6[0] = msg[0].addr << 1; 242 buf6[1] = msg[0].len; 243 buf6[2] = msg[0].buf[0]; 244 dw210x_op_rw(d->udev, 0xc2, 0, 0, 245 buf6, msg[0].len + 2, DW210X_WRITE_MSG); 246 /* read si2109 register */ 247 dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, 248 buf6, msg[1].len + 2, DW210X_READ_MSG); 249 memcpy(msg[1].buf, buf6 + 2, msg[1].len); 250 251 break; 252 case 1: 253 switch (msg[0].addr) { 254 case 0x68: 255 if (2 + msg[0].len > sizeof(buf6)) { 256 warn("i2c wr: len=%d is too big!\n", 257 msg[0].len); 258 num = -EOPNOTSUPP; 259 break; 260 } 261 262 /* write to si2109 register */ 263 buf6[0] = msg[0].addr << 1; 264 buf6[1] = msg[0].len; 265 memcpy(buf6 + 2, msg[0].buf, msg[0].len); 266 dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, 267 msg[0].len + 2, DW210X_WRITE_MSG); 268 break; 269 case(DW2102_RC_QUERY): 270 dw210x_op_rw(d->udev, 0xb8, 0, 0, 271 buf6, 2, DW210X_READ_MSG); 272 msg[0].buf[0] = buf6[0]; 273 msg[0].buf[1] = buf6[1]; 274 break; 275 case(DW2102_VOLTAGE_CTRL): 276 buf6[0] = 0x30; 277 buf6[1] = msg[0].buf[0]; 278 dw210x_op_rw(d->udev, 0xb2, 0, 0, 279 buf6, 2, DW210X_WRITE_MSG); 280 break; 281 } 282 break; 283 } 284 285 mutex_unlock(&d->i2c_mutex); 286 return num; 287 } 288 289 static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 290 { 291 struct dvb_usb_device *d = i2c_get_adapdata(adap); 292 int ret; 293 294 if (!d) 295 return -ENODEV; 296 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 297 return -EAGAIN; 298 299 switch (num) { 300 case 2: { 301 /* read */ 302 /* first write first register number */ 303 u8 ibuf[MAX_XFER_SIZE], obuf[3]; 304 305 if (2 + msg[0].len != sizeof(obuf)) { 306 warn("i2c rd: len=%d is not 1!\n", 307 msg[0].len); 308 ret = -EOPNOTSUPP; 309 goto unlock; 310 } 311 312 if (2 + msg[1].len > sizeof(ibuf)) { 313 warn("i2c rd: len=%d is too big!\n", 314 msg[1].len); 315 ret = -EOPNOTSUPP; 316 goto unlock; 317 } 318 319 obuf[0] = msg[0].addr << 1; 320 obuf[1] = msg[0].len; 321 obuf[2] = msg[0].buf[0]; 322 dw210x_op_rw(d->udev, 0xc2, 0, 0, 323 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 324 /* second read registers */ 325 dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, 326 ibuf, msg[1].len + 2, DW210X_READ_MSG); 327 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 328 329 break; 330 } 331 case 1: 332 switch (msg[0].addr) { 333 case 0x68: { 334 /* write to register */ 335 u8 obuf[MAX_XFER_SIZE]; 336 337 if (2 + msg[0].len > sizeof(obuf)) { 338 warn("i2c wr: len=%d is too big!\n", 339 msg[1].len); 340 ret = -EOPNOTSUPP; 341 goto unlock; 342 } 343 344 obuf[0] = msg[0].addr << 1; 345 obuf[1] = msg[0].len; 346 memcpy(obuf + 2, msg[0].buf, msg[0].len); 347 dw210x_op_rw(d->udev, 0xc2, 0, 0, 348 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 349 break; 350 } 351 case 0x61: { 352 /* write to tuner */ 353 u8 obuf[MAX_XFER_SIZE]; 354 355 if (2 + msg[0].len > sizeof(obuf)) { 356 warn("i2c wr: len=%d is too big!\n", 357 msg[1].len); 358 ret = -EOPNOTSUPP; 359 goto unlock; 360 } 361 362 obuf[0] = msg[0].addr << 1; 363 obuf[1] = msg[0].len; 364 memcpy(obuf + 2, msg[0].buf, msg[0].len); 365 dw210x_op_rw(d->udev, 0xc2, 0, 0, 366 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 367 break; 368 } 369 case(DW2102_RC_QUERY): { 370 u8 ibuf[2]; 371 dw210x_op_rw(d->udev, 0xb8, 0, 0, 372 ibuf, 2, DW210X_READ_MSG); 373 memcpy(msg[0].buf, ibuf , 2); 374 break; 375 } 376 case(DW2102_VOLTAGE_CTRL): { 377 u8 obuf[2]; 378 obuf[0] = 0x30; 379 obuf[1] = msg[0].buf[0]; 380 dw210x_op_rw(d->udev, 0xb2, 0, 0, 381 obuf, 2, DW210X_WRITE_MSG); 382 break; 383 } 384 } 385 386 break; 387 } 388 ret = num; 389 390 unlock: 391 mutex_unlock(&d->i2c_mutex); 392 return ret; 393 } 394 395 static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 396 { 397 struct dvb_usb_device *d = i2c_get_adapdata(adap); 398 int len, i, j, ret; 399 400 if (!d) 401 return -ENODEV; 402 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 403 return -EAGAIN; 404 405 for (j = 0; j < num; j++) { 406 switch (msg[j].addr) { 407 case(DW2102_RC_QUERY): { 408 u8 ibuf[2]; 409 dw210x_op_rw(d->udev, 0xb8, 0, 0, 410 ibuf, 2, DW210X_READ_MSG); 411 memcpy(msg[j].buf, ibuf , 2); 412 break; 413 } 414 case(DW2102_VOLTAGE_CTRL): { 415 u8 obuf[2]; 416 obuf[0] = 0x30; 417 obuf[1] = msg[j].buf[0]; 418 dw210x_op_rw(d->udev, 0xb2, 0, 0, 419 obuf, 2, DW210X_WRITE_MSG); 420 break; 421 } 422 /*case 0x55: cx24116 423 case 0x6a: stv0903 424 case 0x68: ds3000, stv0903 425 case 0x60: ts2020, stv6110, stb6100 */ 426 default: { 427 if (msg[j].flags == I2C_M_RD) { 428 /* read registers */ 429 u8 ibuf[MAX_XFER_SIZE]; 430 431 if (2 + msg[j].len > sizeof(ibuf)) { 432 warn("i2c rd: len=%d is too big!\n", 433 msg[j].len); 434 ret = -EOPNOTSUPP; 435 goto unlock; 436 } 437 438 dw210x_op_rw(d->udev, 0xc3, 439 (msg[j].addr << 1) + 1, 0, 440 ibuf, msg[j].len + 2, 441 DW210X_READ_MSG); 442 memcpy(msg[j].buf, ibuf + 2, msg[j].len); 443 mdelay(10); 444 } else if (((msg[j].buf[0] == 0xb0) && 445 (msg[j].addr == 0x68)) || 446 ((msg[j].buf[0] == 0xf7) && 447 (msg[j].addr == 0x55))) { 448 /* write firmware */ 449 u8 obuf[19]; 450 obuf[0] = msg[j].addr << 1; 451 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); 452 obuf[2] = msg[j].buf[0]; 453 len = msg[j].len - 1; 454 i = 1; 455 do { 456 memcpy(obuf + 3, msg[j].buf + i, 457 (len > 16 ? 16 : len)); 458 dw210x_op_rw(d->udev, 0xc2, 0, 0, 459 obuf, (len > 16 ? 16 : len) + 3, 460 DW210X_WRITE_MSG); 461 i += 16; 462 len -= 16; 463 } while (len > 0); 464 } else { 465 /* write registers */ 466 u8 obuf[MAX_XFER_SIZE]; 467 468 if (2 + msg[j].len > sizeof(obuf)) { 469 warn("i2c wr: len=%d is too big!\n", 470 msg[j].len); 471 ret = -EOPNOTSUPP; 472 goto unlock; 473 } 474 475 obuf[0] = msg[j].addr << 1; 476 obuf[1] = msg[j].len; 477 memcpy(obuf + 2, msg[j].buf, msg[j].len); 478 dw210x_op_rw(d->udev, 0xc2, 0, 0, 479 obuf, msg[j].len + 2, 480 DW210X_WRITE_MSG); 481 } 482 break; 483 } 484 } 485 486 } 487 ret = num; 488 489 unlock: 490 mutex_unlock(&d->i2c_mutex); 491 return ret; 492 } 493 494 static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 495 int num) 496 { 497 struct dvb_usb_device *d = i2c_get_adapdata(adap); 498 int ret; 499 int i; 500 501 if (!d) 502 return -ENODEV; 503 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 504 return -EAGAIN; 505 506 switch (num) { 507 case 2: { 508 /* read */ 509 /* first write first register number */ 510 u8 ibuf[MAX_XFER_SIZE], obuf[3]; 511 512 if (2 + msg[0].len != sizeof(obuf)) { 513 warn("i2c rd: len=%d is not 1!\n", 514 msg[0].len); 515 ret = -EOPNOTSUPP; 516 goto unlock; 517 } 518 if (2 + msg[1].len > sizeof(ibuf)) { 519 warn("i2c rd: len=%d is too big!\n", 520 msg[1].len); 521 ret = -EOPNOTSUPP; 522 goto unlock; 523 } 524 obuf[0] = msg[0].addr << 1; 525 obuf[1] = msg[0].len; 526 obuf[2] = msg[0].buf[0]; 527 dw210x_op_rw(d->udev, 0xc2, 0, 0, 528 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 529 /* second read registers */ 530 dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, 531 ibuf, msg[1].len + 2, DW210X_READ_MSG); 532 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 533 534 break; 535 } 536 case 1: 537 switch (msg[0].addr) { 538 case 0x60: 539 case 0x0c: { 540 /* write to register */ 541 u8 obuf[MAX_XFER_SIZE]; 542 543 if (2 + msg[0].len > sizeof(obuf)) { 544 warn("i2c wr: len=%d is too big!\n", 545 msg[0].len); 546 ret = -EOPNOTSUPP; 547 goto unlock; 548 } 549 obuf[0] = msg[0].addr << 1; 550 obuf[1] = msg[0].len; 551 memcpy(obuf + 2, msg[0].buf, msg[0].len); 552 dw210x_op_rw(d->udev, 0xc2, 0, 0, 553 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 554 break; 555 } 556 case(DW2102_RC_QUERY): { 557 u8 ibuf[2]; 558 dw210x_op_rw(d->udev, 0xb8, 0, 0, 559 ibuf, 2, DW210X_READ_MSG); 560 memcpy(msg[0].buf, ibuf , 2); 561 break; 562 } 563 } 564 565 break; 566 } 567 568 for (i = 0; i < num; i++) { 569 deb_xfer("%02x:%02x: %s ", i, msg[i].addr, 570 msg[i].flags == 0 ? ">>>" : "<<<"); 571 debug_dump(msg[i].buf, msg[i].len, deb_xfer); 572 } 573 ret = num; 574 575 unlock: 576 mutex_unlock(&d->i2c_mutex); 577 return ret; 578 } 579 580 static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 581 int num) 582 { 583 struct dvb_usb_device *d = i2c_get_adapdata(adap); 584 struct usb_device *udev; 585 int len, i, j, ret; 586 587 if (!d) 588 return -ENODEV; 589 udev = d->udev; 590 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 591 return -EAGAIN; 592 593 for (j = 0; j < num; j++) { 594 switch (msg[j].addr) { 595 case (DW2102_RC_QUERY): { 596 u8 ibuf[5]; 597 dw210x_op_rw(d->udev, 0xb8, 0, 0, 598 ibuf, 5, DW210X_READ_MSG); 599 memcpy(msg[j].buf, ibuf + 3, 2); 600 break; 601 } 602 case (DW2102_VOLTAGE_CTRL): { 603 u8 obuf[2]; 604 605 obuf[0] = 1; 606 obuf[1] = msg[j].buf[1];/* off-on */ 607 dw210x_op_rw(d->udev, 0x8a, 0, 0, 608 obuf, 2, DW210X_WRITE_MSG); 609 obuf[0] = 3; 610 obuf[1] = msg[j].buf[0];/* 13v-18v */ 611 dw210x_op_rw(d->udev, 0x8a, 0, 0, 612 obuf, 2, DW210X_WRITE_MSG); 613 break; 614 } 615 case (DW2102_LED_CTRL): { 616 u8 obuf[2]; 617 618 obuf[0] = 5; 619 obuf[1] = msg[j].buf[0]; 620 dw210x_op_rw(d->udev, 0x8a, 0, 0, 621 obuf, 2, DW210X_WRITE_MSG); 622 break; 623 } 624 /*case 0x55: cx24116 625 case 0x6a: stv0903 626 case 0x68: ds3000, stv0903, rs2000 627 case 0x60: ts2020, stv6110, stb6100 628 case 0xa0: eeprom */ 629 default: { 630 if (msg[j].flags == I2C_M_RD) { 631 /* read registers */ 632 u8 ibuf[MAX_XFER_SIZE]; 633 634 if (msg[j].len > sizeof(ibuf)) { 635 warn("i2c rd: len=%d is too big!\n", 636 msg[j].len); 637 ret = -EOPNOTSUPP; 638 goto unlock; 639 } 640 641 dw210x_op_rw(d->udev, 0x91, 0, 0, 642 ibuf, msg[j].len, 643 DW210X_READ_MSG); 644 memcpy(msg[j].buf, ibuf, msg[j].len); 645 break; 646 } else if ((msg[j].buf[0] == 0xb0) && 647 (msg[j].addr == 0x68)) { 648 /* write firmware */ 649 u8 obuf[19]; 650 obuf[0] = (msg[j].len > 16 ? 651 18 : msg[j].len + 1); 652 obuf[1] = msg[j].addr << 1; 653 obuf[2] = msg[j].buf[0]; 654 len = msg[j].len - 1; 655 i = 1; 656 do { 657 memcpy(obuf + 3, msg[j].buf + i, 658 (len > 16 ? 16 : len)); 659 dw210x_op_rw(d->udev, 0x80, 0, 0, 660 obuf, (len > 16 ? 16 : len) + 3, 661 DW210X_WRITE_MSG); 662 i += 16; 663 len -= 16; 664 } while (len > 0); 665 } else if (j < (num - 1)) { 666 /* write register addr before read */ 667 u8 obuf[MAX_XFER_SIZE]; 668 669 if (2 + msg[j].len > sizeof(obuf)) { 670 warn("i2c wr: len=%d is too big!\n", 671 msg[j].len); 672 ret = -EOPNOTSUPP; 673 goto unlock; 674 } 675 676 obuf[0] = msg[j + 1].len; 677 obuf[1] = (msg[j].addr << 1); 678 memcpy(obuf + 2, msg[j].buf, msg[j].len); 679 dw210x_op_rw(d->udev, 680 le16_to_cpu(udev->descriptor.idProduct) == 681 0x7500 ? 0x92 : 0x90, 0, 0, 682 obuf, msg[j].len + 2, 683 DW210X_WRITE_MSG); 684 break; 685 } else { 686 /* write registers */ 687 u8 obuf[MAX_XFER_SIZE]; 688 689 if (2 + msg[j].len > sizeof(obuf)) { 690 warn("i2c wr: len=%d is too big!\n", 691 msg[j].len); 692 ret = -EOPNOTSUPP; 693 goto unlock; 694 } 695 obuf[0] = msg[j].len + 1; 696 obuf[1] = (msg[j].addr << 1); 697 memcpy(obuf + 2, msg[j].buf, msg[j].len); 698 dw210x_op_rw(d->udev, 0x80, 0, 0, 699 obuf, msg[j].len + 2, 700 DW210X_WRITE_MSG); 701 break; 702 } 703 break; 704 } 705 } 706 } 707 ret = num; 708 709 unlock: 710 mutex_unlock(&d->i2c_mutex); 711 return ret; 712 } 713 714 static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 715 int num) 716 { 717 struct dvb_usb_device *d = i2c_get_adapdata(adap); 718 struct dw2102_state *state; 719 int j; 720 721 if (!d) 722 return -ENODEV; 723 724 state = d->priv; 725 726 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 727 return -EAGAIN; 728 if (mutex_lock_interruptible(&d->data_mutex) < 0) { 729 mutex_unlock(&d->i2c_mutex); 730 return -EAGAIN; 731 } 732 733 j = 0; 734 while (j < num) { 735 switch (msg[j].addr) { 736 case SU3000_STREAM_CTRL: 737 state->data[0] = msg[j].buf[0] + 0x36; 738 state->data[1] = 3; 739 state->data[2] = 0; 740 if (dvb_usb_generic_rw(d, state->data, 3, 741 state->data, 0, 0) < 0) 742 err("i2c transfer failed."); 743 break; 744 case DW2102_RC_QUERY: 745 state->data[0] = 0x10; 746 if (dvb_usb_generic_rw(d, state->data, 1, 747 state->data, 2, 0) < 0) 748 err("i2c transfer failed."); 749 msg[j].buf[1] = state->data[0]; 750 msg[j].buf[0] = state->data[1]; 751 break; 752 default: 753 /* if the current write msg is followed by a another 754 * read msg to/from the same address 755 */ 756 if ((j+1 < num) && (msg[j+1].flags & I2C_M_RD) && 757 (msg[j].addr == msg[j+1].addr)) { 758 /* join both i2c msgs to one usb read command */ 759 if (4 + msg[j].len > sizeof(state->data)) { 760 warn("i2c combined wr/rd: write len=%d is too big!\n", 761 msg[j].len); 762 num = -EOPNOTSUPP; 763 break; 764 } 765 if (1 + msg[j+1].len > sizeof(state->data)) { 766 warn("i2c combined wr/rd: read len=%d is too big!\n", 767 msg[j+1].len); 768 num = -EOPNOTSUPP; 769 break; 770 } 771 772 state->data[0] = 0x09; 773 state->data[1] = msg[j].len; 774 state->data[2] = msg[j+1].len; 775 state->data[3] = msg[j].addr; 776 memcpy(&state->data[4], msg[j].buf, msg[j].len); 777 778 if (dvb_usb_generic_rw(d, state->data, msg[j].len + 4, 779 state->data, msg[j+1].len + 1, 0) < 0) 780 err("i2c transfer failed."); 781 782 memcpy(msg[j+1].buf, &state->data[1], msg[j+1].len); 783 j++; 784 break; 785 } 786 787 if (msg[j].flags & I2C_M_RD) { 788 /* single read */ 789 if (4 + msg[j].len > sizeof(state->data)) { 790 warn("i2c rd: len=%d is too big!\n", msg[j].len); 791 num = -EOPNOTSUPP; 792 break; 793 } 794 795 state->data[0] = 0x09; 796 state->data[1] = 0; 797 state->data[2] = msg[j].len; 798 state->data[3] = msg[j].addr; 799 memcpy(&state->data[4], msg[j].buf, msg[j].len); 800 801 if (dvb_usb_generic_rw(d, state->data, 4, 802 state->data, msg[j].len + 1, 0) < 0) 803 err("i2c transfer failed."); 804 805 memcpy(msg[j].buf, &state->data[1], msg[j].len); 806 break; 807 } 808 809 /* single write */ 810 if (3 + msg[j].len > sizeof(state->data)) { 811 warn("i2c wr: len=%d is too big!\n", msg[j].len); 812 num = -EOPNOTSUPP; 813 break; 814 } 815 816 state->data[0] = 0x08; 817 state->data[1] = msg[j].addr; 818 state->data[2] = msg[j].len; 819 820 memcpy(&state->data[3], msg[j].buf, msg[j].len); 821 822 if (dvb_usb_generic_rw(d, state->data, msg[j].len + 3, 823 state->data, 1, 0) < 0) 824 err("i2c transfer failed."); 825 } // switch 826 j++; 827 828 } // while 829 mutex_unlock(&d->data_mutex); 830 mutex_unlock(&d->i2c_mutex); 831 return num; 832 } 833 834 static u32 dw210x_i2c_func(struct i2c_adapter *adapter) 835 { 836 return I2C_FUNC_I2C; 837 } 838 839 static struct i2c_algorithm dw2102_i2c_algo = { 840 .master_xfer = dw2102_i2c_transfer, 841 .functionality = dw210x_i2c_func, 842 }; 843 844 static struct i2c_algorithm dw2102_serit_i2c_algo = { 845 .master_xfer = dw2102_serit_i2c_transfer, 846 .functionality = dw210x_i2c_func, 847 }; 848 849 static struct i2c_algorithm dw2102_earda_i2c_algo = { 850 .master_xfer = dw2102_earda_i2c_transfer, 851 .functionality = dw210x_i2c_func, 852 }; 853 854 static struct i2c_algorithm dw2104_i2c_algo = { 855 .master_xfer = dw2104_i2c_transfer, 856 .functionality = dw210x_i2c_func, 857 }; 858 859 static struct i2c_algorithm dw3101_i2c_algo = { 860 .master_xfer = dw3101_i2c_transfer, 861 .functionality = dw210x_i2c_func, 862 }; 863 864 static struct i2c_algorithm s6x0_i2c_algo = { 865 .master_xfer = s6x0_i2c_transfer, 866 .functionality = dw210x_i2c_func, 867 }; 868 869 static struct i2c_algorithm su3000_i2c_algo = { 870 .master_xfer = su3000_i2c_transfer, 871 .functionality = dw210x_i2c_func, 872 }; 873 874 static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 875 { 876 int i; 877 u8 ibuf[] = {0, 0}; 878 u8 eeprom[256], eepromline[16]; 879 880 for (i = 0; i < 256; i++) { 881 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { 882 err("read eeprom failed."); 883 return -EIO; 884 } else { 885 eepromline[i%16] = ibuf[0]; 886 eeprom[i] = ibuf[0]; 887 } 888 if ((i % 16) == 15) { 889 deb_xfer("%02x: ", i - 15); 890 debug_dump(eepromline, 16, deb_xfer); 891 } 892 } 893 894 memcpy(mac, eeprom + 8, 6); 895 return 0; 896 }; 897 898 static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 899 { 900 int i, ret; 901 u8 ibuf[] = { 0 }, obuf[] = { 0 }; 902 u8 eeprom[256], eepromline[16]; 903 struct i2c_msg msg[] = { 904 { 905 .addr = 0xa0 >> 1, 906 .flags = 0, 907 .buf = obuf, 908 .len = 1, 909 }, { 910 .addr = 0xa0 >> 1, 911 .flags = I2C_M_RD, 912 .buf = ibuf, 913 .len = 1, 914 } 915 }; 916 917 for (i = 0; i < 256; i++) { 918 obuf[0] = i; 919 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); 920 if (ret != 2) { 921 err("read eeprom failed."); 922 return -EIO; 923 } else { 924 eepromline[i % 16] = ibuf[0]; 925 eeprom[i] = ibuf[0]; 926 } 927 928 if ((i % 16) == 15) { 929 deb_xfer("%02x: ", i - 15); 930 debug_dump(eepromline, 16, deb_xfer); 931 } 932 } 933 934 memcpy(mac, eeprom + 16, 6); 935 return 0; 936 }; 937 938 static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 939 { 940 static u8 command_start[] = {0x00}; 941 static u8 command_stop[] = {0x01}; 942 struct i2c_msg msg = { 943 .addr = SU3000_STREAM_CTRL, 944 .flags = 0, 945 .buf = onoff ? command_start : command_stop, 946 .len = 1 947 }; 948 949 i2c_transfer(&adap->dev->i2c_adap, &msg, 1); 950 951 return 0; 952 } 953 954 static int su3000_power_ctrl(struct dvb_usb_device *d, int i) 955 { 956 struct dw2102_state *state = d->priv; 957 int ret = 0; 958 959 info("%s: %d, initialized %d", __func__, i, state->initialized); 960 961 if (i && !state->initialized) { 962 mutex_lock(&d->data_mutex); 963 964 state->data[0] = 0xde; 965 state->data[1] = 0; 966 967 state->initialized = 1; 968 /* reset board */ 969 ret = dvb_usb_generic_rw(d, state->data, 2, NULL, 0, 0); 970 mutex_unlock(&d->data_mutex); 971 } 972 973 return ret; 974 } 975 976 static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 977 { 978 int i; 979 u8 obuf[] = { 0x1f, 0xf0 }; 980 u8 ibuf[] = { 0 }; 981 struct i2c_msg msg[] = { 982 { 983 .addr = 0x51, 984 .flags = 0, 985 .buf = obuf, 986 .len = 2, 987 }, { 988 .addr = 0x51, 989 .flags = I2C_M_RD, 990 .buf = ibuf, 991 .len = 1, 992 993 } 994 }; 995 996 for (i = 0; i < 6; i++) { 997 obuf[1] = 0xf0 + i; 998 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) 999 return -EIO; 1000 else 1001 mac[i] = ibuf[0]; 1002 } 1003 1004 return 0; 1005 } 1006 1007 static int su3000_identify_state(struct usb_device *udev, 1008 const struct dvb_usb_device_properties *props, 1009 const struct dvb_usb_device_description **desc, 1010 int *cold) 1011 { 1012 info("%s", __func__); 1013 1014 *cold = 0; 1015 return 0; 1016 } 1017 1018 static int dw210x_set_voltage(struct dvb_frontend *fe, 1019 enum fe_sec_voltage voltage) 1020 { 1021 static u8 command_13v[] = {0x00, 0x01}; 1022 static u8 command_18v[] = {0x01, 0x01}; 1023 static u8 command_off[] = {0x00, 0x00}; 1024 struct i2c_msg msg = { 1025 .addr = DW2102_VOLTAGE_CTRL, 1026 .flags = 0, 1027 .buf = command_off, 1028 .len = 2, 1029 }; 1030 1031 struct dvb_usb_adapter *udev_adap = fe->dvb->priv; 1032 if (voltage == SEC_VOLTAGE_18) 1033 msg.buf = command_18v; 1034 else if (voltage == SEC_VOLTAGE_13) 1035 msg.buf = command_13v; 1036 1037 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 1038 1039 return 0; 1040 } 1041 1042 static int s660_set_voltage(struct dvb_frontend *fe, 1043 enum fe_sec_voltage voltage) 1044 { 1045 struct dvb_usb_adapter *d = fe->dvb->priv; 1046 struct dw2102_state *st = d->dev->priv; 1047 1048 dw210x_set_voltage(fe, voltage); 1049 if (st->old_set_voltage) 1050 st->old_set_voltage(fe, voltage); 1051 1052 return 0; 1053 } 1054 1055 static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) 1056 { 1057 static u8 led_off[] = { 0 }; 1058 static u8 led_on[] = { 1 }; 1059 struct i2c_msg msg = { 1060 .addr = DW2102_LED_CTRL, 1061 .flags = 0, 1062 .buf = led_off, 1063 .len = 1 1064 }; 1065 struct dvb_usb_adapter *udev_adap = fe->dvb->priv; 1066 1067 if (offon) 1068 msg.buf = led_on; 1069 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 1070 } 1071 1072 static int tt_s2_4600_read_status(struct dvb_frontend *fe, 1073 enum fe_status *status) 1074 { 1075 struct dvb_usb_adapter *d = fe->dvb->priv; 1076 struct dw2102_state *st = d->dev->priv; 1077 int ret; 1078 1079 ret = st->fe_read_status(fe, status); 1080 1081 /* resync slave fifo when signal change from unlock to lock */ 1082 if ((*status & FE_HAS_LOCK) && (!st->last_lock)) 1083 su3000_streaming_ctrl(d, 1); 1084 1085 st->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0; 1086 return ret; 1087 } 1088 1089 static struct stv0299_config sharp_z0194a_config = { 1090 .demod_address = 0x68, 1091 .inittab = sharp_z0194a_inittab, 1092 .mclk = 88000000UL, 1093 .invert = 1, 1094 .skip_reinit = 0, 1095 .lock_output = STV0299_LOCKOUTPUT_1, 1096 .volt13_op0_op1 = STV0299_VOLT13_OP1, 1097 .min_delay_ms = 100, 1098 .set_symbol_rate = sharp_z0194a_set_symbol_rate, 1099 }; 1100 1101 static struct cx24116_config dw2104_config = { 1102 .demod_address = 0x55, 1103 .mpg_clk_pos_pol = 0x01, 1104 }; 1105 1106 static struct si21xx_config serit_sp1511lhb_config = { 1107 .demod_address = 0x68, 1108 .min_delay_ms = 100, 1109 1110 }; 1111 1112 static struct tda10023_config dw3101_tda10023_config = { 1113 .demod_address = 0x0c, 1114 .invert = 1, 1115 }; 1116 1117 static struct mt312_config zl313_config = { 1118 .demod_address = 0x0e, 1119 }; 1120 1121 static struct ds3000_config dw2104_ds3000_config = { 1122 .demod_address = 0x68, 1123 }; 1124 1125 static struct ts2020_config dw2104_ts2020_config = { 1126 .tuner_address = 0x60, 1127 .clk_out_div = 1, 1128 .frequency_div = 1060000, 1129 }; 1130 1131 static struct ds3000_config s660_ds3000_config = { 1132 .demod_address = 0x68, 1133 .ci_mode = 1, 1134 .set_lock_led = dw210x_led_ctrl, 1135 }; 1136 1137 static struct ts2020_config s660_ts2020_config = { 1138 .tuner_address = 0x60, 1139 .clk_out_div = 1, 1140 .frequency_div = 1146000, 1141 }; 1142 1143 static struct stv0900_config dw2104a_stv0900_config = { 1144 .demod_address = 0x6a, 1145 .demod_mode = 0, 1146 .xtal = 27000000, 1147 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 1148 .diseqc_mode = 2,/* 2/3 PWM */ 1149 .tun1_maddress = 0,/* 0x60 */ 1150 .tun1_adc = 0,/* 2 Vpp */ 1151 .path1_mode = 3, 1152 }; 1153 1154 static struct stb6100_config dw2104a_stb6100_config = { 1155 .tuner_address = 0x60, 1156 .refclock = 27000000, 1157 }; 1158 1159 static struct stv0900_config dw2104_stv0900_config = { 1160 .demod_address = 0x68, 1161 .demod_mode = 0, 1162 .xtal = 8000000, 1163 .clkmode = 3, 1164 .diseqc_mode = 2, 1165 .tun1_maddress = 0, 1166 .tun1_adc = 1,/* 1 Vpp */ 1167 .path1_mode = 3, 1168 }; 1169 1170 static struct stv6110_config dw2104_stv6110_config = { 1171 .i2c_address = 0x60, 1172 .mclk = 16000000, 1173 .clk_div = 1, 1174 }; 1175 1176 static struct stv0900_config prof_7500_stv0900_config = { 1177 .demod_address = 0x6a, 1178 .demod_mode = 0, 1179 .xtal = 27000000, 1180 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 1181 .diseqc_mode = 2,/* 2/3 PWM */ 1182 .tun1_maddress = 0,/* 0x60 */ 1183 .tun1_adc = 0,/* 2 Vpp */ 1184 .path1_mode = 3, 1185 .tun1_type = 3, 1186 .set_lock_led = dw210x_led_ctrl, 1187 }; 1188 1189 static struct ds3000_config su3000_ds3000_config = { 1190 .demod_address = 0x68, 1191 .ci_mode = 1, 1192 .set_lock_led = dw210x_led_ctrl, 1193 }; 1194 1195 static struct cxd2820r_config cxd2820r_config = { 1196 .i2c_address = 0x6c, /* (0xd8 >> 1) */ 1197 .ts_mode = 0x38, 1198 .ts_clock_inv = 1, 1199 }; 1200 1201 static struct tda18271_config tda18271_config = { 1202 .output_opt = TDA18271_OUTPUT_LT_OFF, 1203 .gate = TDA18271_GATE_DIGITAL, 1204 }; 1205 1206 static u8 m88rs2000_inittab[] = { 1207 DEMOD_WRITE, 0x9a, 0x30, 1208 DEMOD_WRITE, 0x00, 0x01, 1209 WRITE_DELAY, 0x19, 0x00, 1210 DEMOD_WRITE, 0x00, 0x00, 1211 DEMOD_WRITE, 0x9a, 0xb0, 1212 DEMOD_WRITE, 0x81, 0xc1, 1213 DEMOD_WRITE, 0x81, 0x81, 1214 DEMOD_WRITE, 0x86, 0xc6, 1215 DEMOD_WRITE, 0x9a, 0x30, 1216 DEMOD_WRITE, 0xf0, 0x80, 1217 DEMOD_WRITE, 0xf1, 0xbf, 1218 DEMOD_WRITE, 0xb0, 0x45, 1219 DEMOD_WRITE, 0xb2, 0x01, 1220 DEMOD_WRITE, 0x9a, 0xb0, 1221 0xff, 0xaa, 0xff 1222 }; 1223 1224 static struct m88rs2000_config s421_m88rs2000_config = { 1225 .demod_addr = 0x68, 1226 .inittab = m88rs2000_inittab, 1227 }; 1228 1229 static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 1230 { 1231 struct dvb_tuner_ops *tuner_ops = NULL; 1232 1233 if (demod_probe & 4) { 1234 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config, 1235 &d->dev->i2c_adap, 0); 1236 if (d->fe_adap[0].fe != NULL) { 1237 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, 1238 &dw2104a_stb6100_config, 1239 &d->dev->i2c_adap)) { 1240 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; 1241 tuner_ops->set_frequency = stb6100_set_freq; 1242 tuner_ops->get_frequency = stb6100_get_freq; 1243 tuner_ops->set_bandwidth = stb6100_set_bandw; 1244 tuner_ops->get_bandwidth = stb6100_get_bandw; 1245 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1246 info("Attached STV0900+STB6100!"); 1247 return 0; 1248 } 1249 } 1250 } 1251 1252 if (demod_probe & 2) { 1253 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config, 1254 &d->dev->i2c_adap, 0); 1255 if (d->fe_adap[0].fe != NULL) { 1256 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, 1257 &dw2104_stv6110_config, 1258 &d->dev->i2c_adap)) { 1259 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1260 info("Attached STV0900+STV6110A!"); 1261 return 0; 1262 } 1263 } 1264 } 1265 1266 if (demod_probe & 1) { 1267 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, 1268 &d->dev->i2c_adap); 1269 if (d->fe_adap[0].fe != NULL) { 1270 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1271 info("Attached cx24116!"); 1272 return 0; 1273 } 1274 } 1275 1276 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, 1277 &d->dev->i2c_adap); 1278 if (d->fe_adap[0].fe != NULL) { 1279 dvb_attach(ts2020_attach, d->fe_adap[0].fe, 1280 &dw2104_ts2020_config, &d->dev->i2c_adap); 1281 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1282 info("Attached DS3000!"); 1283 return 0; 1284 } 1285 1286 return -EIO; 1287 } 1288 1289 static struct dvb_usb_device_properties dw2102_properties; 1290 static struct dvb_usb_device_properties dw2104_properties; 1291 static struct dvb_usb_device_properties s6x0_properties; 1292 1293 static int dw2102_frontend_attach(struct dvb_usb_adapter *d) 1294 { 1295 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { 1296 /*dw2102_properties.adapter->tuner_attach = NULL;*/ 1297 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, 1298 &d->dev->i2c_adap); 1299 if (d->fe_adap[0].fe != NULL) { 1300 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1301 info("Attached si21xx!"); 1302 return 0; 1303 } 1304 } 1305 1306 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { 1307 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1308 &d->dev->i2c_adap); 1309 if (d->fe_adap[0].fe != NULL) { 1310 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, 1311 &d->dev->i2c_adap)) { 1312 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1313 info("Attached stv0288!"); 1314 return 0; 1315 } 1316 } 1317 } 1318 1319 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { 1320 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ 1321 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, 1322 &d->dev->i2c_adap); 1323 if (d->fe_adap[0].fe != NULL) { 1324 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1325 info("Attached stv0299!"); 1326 return 0; 1327 } 1328 } 1329 return -EIO; 1330 } 1331 1332 static int dw3101_frontend_attach(struct dvb_usb_adapter *d) 1333 { 1334 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, 1335 &d->dev->i2c_adap, 0x48); 1336 if (d->fe_adap[0].fe != NULL) { 1337 info("Attached tda10023!"); 1338 return 0; 1339 } 1340 return -EIO; 1341 } 1342 1343 static int zl100313_frontend_attach(struct dvb_usb_adapter *d) 1344 { 1345 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, 1346 &d->dev->i2c_adap); 1347 if (d->fe_adap[0].fe != NULL) { 1348 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, 1349 &d->dev->i2c_adap)) { 1350 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1351 info("Attached zl100313+zl10039!"); 1352 return 0; 1353 } 1354 } 1355 1356 return -EIO; 1357 } 1358 1359 static int stv0288_frontend_attach(struct dvb_usb_adapter *d) 1360 { 1361 u8 obuf[] = {7, 1}; 1362 1363 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1364 &d->dev->i2c_adap); 1365 1366 if (d->fe_adap[0].fe == NULL) 1367 return -EIO; 1368 1369 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) 1370 return -EIO; 1371 1372 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1373 1374 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1375 1376 info("Attached stv0288+stb6000!"); 1377 1378 return 0; 1379 1380 } 1381 1382 static int ds3000_frontend_attach(struct dvb_usb_adapter *d) 1383 { 1384 struct dw2102_state *st = d->dev->priv; 1385 u8 obuf[] = {7, 1}; 1386 1387 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config, 1388 &d->dev->i2c_adap); 1389 1390 if (d->fe_adap[0].fe == NULL) 1391 return -EIO; 1392 1393 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &s660_ts2020_config, 1394 &d->dev->i2c_adap); 1395 1396 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; 1397 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; 1398 1399 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1400 1401 info("Attached ds3000+ts2020!"); 1402 1403 return 0; 1404 } 1405 1406 static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) 1407 { 1408 u8 obuf[] = {7, 1}; 1409 1410 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, 1411 &d->dev->i2c_adap, 0); 1412 if (d->fe_adap[0].fe == NULL) 1413 return -EIO; 1414 1415 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1416 1417 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1418 1419 info("Attached STV0900+STB6100A!"); 1420 1421 return 0; 1422 } 1423 1424 static int su3000_frontend_attach(struct dvb_usb_adapter *adap) 1425 { 1426 struct dvb_usb_device *d = adap->dev; 1427 struct dw2102_state *state = d->priv; 1428 1429 mutex_lock(&d->data_mutex); 1430 1431 state->data[0] = 0xe; 1432 state->data[1] = 0x80; 1433 state->data[2] = 0; 1434 1435 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1436 err("command 0x0e transfer failed."); 1437 1438 state->data[0] = 0xe; 1439 state->data[1] = 0x02; 1440 state->data[2] = 1; 1441 1442 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1443 err("command 0x0e transfer failed."); 1444 msleep(300); 1445 1446 state->data[0] = 0xe; 1447 state->data[1] = 0x83; 1448 state->data[2] = 0; 1449 1450 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1451 err("command 0x0e transfer failed."); 1452 1453 state->data[0] = 0xe; 1454 state->data[1] = 0x83; 1455 state->data[2] = 1; 1456 1457 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1458 err("command 0x0e transfer failed."); 1459 1460 state->data[0] = 0x51; 1461 1462 if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 1463 err("command 0x51 transfer failed."); 1464 1465 mutex_unlock(&d->data_mutex); 1466 1467 adap->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, 1468 &d->i2c_adap); 1469 if (adap->fe_adap[0].fe == NULL) 1470 return -EIO; 1471 1472 if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, 1473 &dw2104_ts2020_config, 1474 &d->i2c_adap)) { 1475 info("Attached DS3000/TS2020!"); 1476 return 0; 1477 } 1478 1479 info("Failed to attach DS3000/TS2020!"); 1480 return -EIO; 1481 } 1482 1483 static int t220_frontend_attach(struct dvb_usb_adapter *adap) 1484 { 1485 struct dvb_usb_device *d = adap->dev; 1486 struct dw2102_state *state = d->priv; 1487 1488 mutex_lock(&d->data_mutex); 1489 1490 state->data[0] = 0xe; 1491 state->data[1] = 0x87; 1492 state->data[2] = 0x0; 1493 1494 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1495 err("command 0x0e transfer failed."); 1496 1497 state->data[0] = 0xe; 1498 state->data[1] = 0x86; 1499 state->data[2] = 1; 1500 1501 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1502 err("command 0x0e transfer failed."); 1503 1504 state->data[0] = 0xe; 1505 state->data[1] = 0x80; 1506 state->data[2] = 0; 1507 1508 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1509 err("command 0x0e transfer failed."); 1510 1511 msleep(50); 1512 1513 state->data[0] = 0xe; 1514 state->data[1] = 0x80; 1515 state->data[2] = 1; 1516 1517 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1518 err("command 0x0e transfer failed."); 1519 1520 state->data[0] = 0x51; 1521 1522 if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 1523 err("command 0x51 transfer failed."); 1524 1525 mutex_unlock(&d->data_mutex); 1526 1527 adap->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config, 1528 &d->i2c_adap, NULL); 1529 if (adap->fe_adap[0].fe != NULL) { 1530 if (dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0x60, 1531 &d->i2c_adap, &tda18271_config)) { 1532 info("Attached TDA18271HD/CXD2820R!"); 1533 return 0; 1534 } 1535 } 1536 1537 info("Failed to attach TDA18271HD/CXD2820R!"); 1538 return -EIO; 1539 } 1540 1541 static int m88rs2000_frontend_attach(struct dvb_usb_adapter *adap) 1542 { 1543 struct dvb_usb_device *d = adap->dev; 1544 struct dw2102_state *state = d->priv; 1545 1546 mutex_lock(&d->data_mutex); 1547 1548 state->data[0] = 0x51; 1549 1550 if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 1551 err("command 0x51 transfer failed."); 1552 1553 mutex_unlock(&d->data_mutex); 1554 1555 adap->fe_adap[0].fe = dvb_attach(m88rs2000_attach, 1556 &s421_m88rs2000_config, 1557 &d->i2c_adap); 1558 1559 if (adap->fe_adap[0].fe == NULL) 1560 return -EIO; 1561 1562 if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe, 1563 &dw2104_ts2020_config, 1564 &d->i2c_adap)) { 1565 info("Attached RS2000/TS2020!"); 1566 return 0; 1567 } 1568 1569 info("Failed to attach RS2000/TS2020!"); 1570 return -EIO; 1571 } 1572 1573 static int tt_s2_4600_frontend_attach_probe_demod(struct dvb_usb_device *d, 1574 const int probe_addr) 1575 { 1576 struct dw2102_state *state = d->priv; 1577 1578 state->data[0] = 0x9; 1579 state->data[1] = 0x1; 1580 state->data[2] = 0x1; 1581 state->data[3] = probe_addr; 1582 state->data[4] = 0x0; 1583 1584 if (dvb_usb_generic_rw(d, state->data, 5, state->data, 2, 0) < 0) { 1585 err("i2c probe for address 0x%x failed.", probe_addr); 1586 return 0; 1587 } 1588 1589 if (state->data[0] != 8) /* fail(7) or error, no device at address */ 1590 return 0; 1591 1592 /* probing successful */ 1593 return 1; 1594 } 1595 1596 static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap) 1597 { 1598 struct dvb_usb_device *d = adap->dev; 1599 struct dw2102_state *state = d->priv; 1600 struct i2c_adapter *i2c_adapter; 1601 struct i2c_client *client; 1602 struct i2c_board_info board_info; 1603 struct m88ds3103_platform_data m88ds3103_pdata = {}; 1604 struct ts2020_config ts2020_config = {}; 1605 int demod_addr; 1606 1607 mutex_lock(&d->data_mutex); 1608 1609 state->data[0] = 0xe; 1610 state->data[1] = 0x80; 1611 state->data[2] = 0x0; 1612 1613 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1614 err("command 0x0e transfer failed."); 1615 1616 state->data[0] = 0xe; 1617 state->data[1] = 0x02; 1618 state->data[2] = 1; 1619 1620 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1621 err("command 0x0e transfer failed."); 1622 msleep(300); 1623 1624 state->data[0] = 0xe; 1625 state->data[1] = 0x83; 1626 state->data[2] = 0; 1627 1628 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1629 err("command 0x0e transfer failed."); 1630 1631 state->data[0] = 0xe; 1632 state->data[1] = 0x83; 1633 state->data[2] = 1; 1634 1635 if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0) 1636 err("command 0x0e transfer failed."); 1637 1638 state->data[0] = 0x51; 1639 1640 if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0) 1641 err("command 0x51 transfer failed."); 1642 1643 /* probe for demodulator i2c address */ 1644 demod_addr = -1; 1645 if (tt_s2_4600_frontend_attach_probe_demod(d, 0x68)) 1646 demod_addr = 0x68; 1647 else if (tt_s2_4600_frontend_attach_probe_demod(d, 0x69)) 1648 demod_addr = 0x69; 1649 else if (tt_s2_4600_frontend_attach_probe_demod(d, 0x6a)) 1650 demod_addr = 0x6a; 1651 1652 mutex_unlock(&d->data_mutex); 1653 1654 if (demod_addr < 0) { 1655 err("probing for demodulator failed. Is the external power switched on?"); 1656 return -ENODEV; 1657 } 1658 1659 /* attach demod */ 1660 m88ds3103_pdata.clk = 27000000; 1661 m88ds3103_pdata.i2c_wr_max = 33; 1662 m88ds3103_pdata.ts_mode = M88DS3103_TS_CI; 1663 m88ds3103_pdata.ts_clk = 16000; 1664 m88ds3103_pdata.ts_clk_pol = 0; 1665 m88ds3103_pdata.spec_inv = 0; 1666 m88ds3103_pdata.agc = 0x99; 1667 m88ds3103_pdata.agc_inv = 0; 1668 m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_ENABLED; 1669 m88ds3103_pdata.envelope_mode = 0; 1670 m88ds3103_pdata.lnb_hv_pol = 1; 1671 m88ds3103_pdata.lnb_en_pol = 0; 1672 memset(&board_info, 0, sizeof(board_info)); 1673 if (demod_addr == 0x6a) 1674 strscpy(board_info.type, "m88ds3103b", I2C_NAME_SIZE); 1675 else 1676 strscpy(board_info.type, "m88ds3103", I2C_NAME_SIZE); 1677 board_info.addr = demod_addr; 1678 board_info.platform_data = &m88ds3103_pdata; 1679 request_module("m88ds3103"); 1680 client = i2c_new_client_device(&d->i2c_adap, &board_info); 1681 if (!i2c_client_has_driver(client)) 1682 return -ENODEV; 1683 if (!try_module_get(client->dev.driver->owner)) { 1684 i2c_unregister_device(client); 1685 return -ENODEV; 1686 } 1687 adap->fe_adap[0].fe = m88ds3103_pdata.get_dvb_frontend(client); 1688 i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client); 1689 1690 state->i2c_client_demod = client; 1691 1692 /* attach tuner */ 1693 ts2020_config.fe = adap->fe_adap[0].fe; 1694 memset(&board_info, 0, sizeof(board_info)); 1695 strscpy(board_info.type, "ts2022", I2C_NAME_SIZE); 1696 board_info.addr = 0x60; 1697 board_info.platform_data = &ts2020_config; 1698 request_module("ts2020"); 1699 client = i2c_new_client_device(i2c_adapter, &board_info); 1700 1701 if (!i2c_client_has_driver(client)) { 1702 dvb_frontend_detach(adap->fe_adap[0].fe); 1703 return -ENODEV; 1704 } 1705 1706 if (!try_module_get(client->dev.driver->owner)) { 1707 i2c_unregister_device(client); 1708 dvb_frontend_detach(adap->fe_adap[0].fe); 1709 return -ENODEV; 1710 } 1711 1712 /* delegate signal strength measurement to tuner */ 1713 adap->fe_adap[0].fe->ops.read_signal_strength = 1714 adap->fe_adap[0].fe->ops.tuner_ops.get_rf_strength; 1715 1716 state->i2c_client_tuner = client; 1717 1718 /* hook fe: need to resync the slave fifo when signal locks */ 1719 state->fe_read_status = adap->fe_adap[0].fe->ops.read_status; 1720 adap->fe_adap[0].fe->ops.read_status = tt_s2_4600_read_status; 1721 1722 state->last_lock = 0; 1723 1724 return 0; 1725 } 1726 1727 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) 1728 { 1729 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1730 &adap->dev->i2c_adap, DVB_PLL_OPERA1); 1731 return 0; 1732 } 1733 1734 static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) 1735 { 1736 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1737 &adap->dev->i2c_adap, DVB_PLL_TUA6034); 1738 1739 return 0; 1740 } 1741 1742 static int dw2102_rc_query(struct dvb_usb_device *d) 1743 { 1744 u8 key[2]; 1745 struct i2c_msg msg = { 1746 .addr = DW2102_RC_QUERY, 1747 .flags = I2C_M_RD, 1748 .buf = key, 1749 .len = 2 1750 }; 1751 1752 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1753 if (msg.buf[0] != 0xff) { 1754 deb_rc("%s: rc code: %x, %x\n", 1755 __func__, key[0], key[1]); 1756 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0], 0); 1757 } 1758 } 1759 1760 return 0; 1761 } 1762 1763 static int prof_rc_query(struct dvb_usb_device *d) 1764 { 1765 u8 key[2]; 1766 struct i2c_msg msg = { 1767 .addr = DW2102_RC_QUERY, 1768 .flags = I2C_M_RD, 1769 .buf = key, 1770 .len = 2 1771 }; 1772 1773 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1774 if (msg.buf[0] != 0xff) { 1775 deb_rc("%s: rc code: %x, %x\n", 1776 __func__, key[0], key[1]); 1777 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0] ^ 0xff, 1778 0); 1779 } 1780 } 1781 1782 return 0; 1783 } 1784 1785 static int su3000_rc_query(struct dvb_usb_device *d) 1786 { 1787 u8 key[2]; 1788 struct i2c_msg msg = { 1789 .addr = DW2102_RC_QUERY, 1790 .flags = I2C_M_RD, 1791 .buf = key, 1792 .len = 2 1793 }; 1794 1795 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1796 if (msg.buf[0] != 0xff) { 1797 deb_rc("%s: rc code: %x, %x\n", 1798 __func__, key[0], key[1]); 1799 rc_keydown(d->rc_dev, RC_PROTO_RC5, 1800 RC_SCANCODE_RC5(key[1], key[0]), 0); 1801 } 1802 } 1803 1804 return 0; 1805 } 1806 1807 enum dw2102_table_entry { 1808 CYPRESS_DW2102, 1809 CYPRESS_DW2101, 1810 CYPRESS_DW2104, 1811 TEVII_S650, 1812 TERRATEC_CINERGY_S, 1813 CYPRESS_DW3101, 1814 TEVII_S630, 1815 PROF_1100, 1816 TEVII_S660, 1817 PROF_7500, 1818 GENIATECH_SU3000, 1819 HAUPPAUGE_MAX_S2, 1820 TERRATEC_CINERGY_S2_R1, 1821 TEVII_S480_1, 1822 TEVII_S480_2, 1823 GENIATECH_X3M_SPC1400HD, 1824 TEVII_S421, 1825 TEVII_S632, 1826 TERRATEC_CINERGY_S2_R2, 1827 TERRATEC_CINERGY_S2_R3, 1828 TERRATEC_CINERGY_S2_R4, 1829 TERRATEC_CINERGY_S2_1, 1830 TERRATEC_CINERGY_S2_2, 1831 GOTVIEW_SAT_HD, 1832 GENIATECH_T220, 1833 TECHNOTREND_CONNECT_S2_4600, 1834 TEVII_S482_1, 1835 TEVII_S482_2, 1836 TERRATEC_CINERGY_S2_BOX, 1837 TEVII_S662 1838 }; 1839 1840 static struct usb_device_id dw2102_table[] = { 1841 DVB_USB_DEV(CYPRESS, CYPRESS_DW2102), 1842 DVB_USB_DEV(CYPRESS, CYPRESS_DW2101), 1843 DVB_USB_DEV(CYPRESS, CYPRESS_DW2104), 1844 DVB_USB_DEV(TEVII, TEVII_S650), 1845 DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S), 1846 DVB_USB_DEV(CYPRESS, CYPRESS_DW3101), 1847 DVB_USB_DEV(TEVII, TEVII_S630), 1848 DVB_USB_DEV(PROF_1, PROF_1100), 1849 DVB_USB_DEV(TEVII, TEVII_S660), 1850 DVB_USB_DEV(PROF_2, PROF_7500), 1851 DVB_USB_DEV(GTEK, GENIATECH_SU3000), 1852 DVB_USB_DEV(HAUPPAUGE, HAUPPAUGE_MAX_S2), 1853 DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R1), 1854 DVB_USB_DEV(TEVII, TEVII_S480_1), 1855 DVB_USB_DEV(TEVII, TEVII_S480_2), 1856 DVB_USB_DEV(GTEK, GENIATECH_X3M_SPC1400HD), 1857 DVB_USB_DEV(TEVII, TEVII_S421), 1858 DVB_USB_DEV(TEVII, TEVII_S632), 1859 DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R2), 1860 DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R3), 1861 DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_R4), 1862 DVB_USB_DEV(TERRATEC_2, TERRATEC_CINERGY_S2_1), 1863 DVB_USB_DEV(TERRATEC_2, TERRATEC_CINERGY_S2_2), 1864 DVB_USB_DEV(GOTVIEW, GOTVIEW_SAT_HD), 1865 DVB_USB_DEV(GTEK, GENIATECH_T220), 1866 DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_S2_4600), 1867 DVB_USB_DEV(TEVII, TEVII_S482_1), 1868 DVB_USB_DEV(TEVII, TEVII_S482_2), 1869 DVB_USB_DEV(TERRATEC, TERRATEC_CINERGY_S2_BOX), 1870 DVB_USB_DEV(TEVII, TEVII_S662), 1871 { } 1872 }; 1873 1874 MODULE_DEVICE_TABLE(usb, dw2102_table); 1875 1876 static int dw2102_load_firmware(struct usb_device *dev, 1877 const struct firmware *frmwr) 1878 { 1879 u8 *b, *p; 1880 int ret = 0, i; 1881 u8 reset; 1882 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; 1883 const struct firmware *fw; 1884 1885 switch (le16_to_cpu(dev->descriptor.idProduct)) { 1886 case 0x2101: 1887 ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); 1888 if (ret != 0) { 1889 err(err_str, DW2101_FIRMWARE); 1890 return ret; 1891 } 1892 break; 1893 default: 1894 fw = frmwr; 1895 break; 1896 } 1897 info("start downloading DW210X firmware"); 1898 p = kmalloc(fw->size, GFP_KERNEL); 1899 reset = 1; 1900 /*stop the CPU*/ 1901 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); 1902 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG); 1903 1904 if (p != NULL) { 1905 memcpy(p, fw->data, fw->size); 1906 for (i = 0; i < fw->size; i += 0x40) { 1907 b = (u8 *) p + i; 1908 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, 1909 DW210X_WRITE_MSG) != 0x40) { 1910 err("error while transferring firmware"); 1911 ret = -EINVAL; 1912 break; 1913 } 1914 } 1915 /* restart the CPU */ 1916 reset = 0; 1917 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, 1918 DW210X_WRITE_MSG) != 1) { 1919 err("could not restart the USB controller CPU."); 1920 ret = -EINVAL; 1921 } 1922 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, 1923 DW210X_WRITE_MSG) != 1) { 1924 err("could not restart the USB controller CPU."); 1925 ret = -EINVAL; 1926 } 1927 /* init registers */ 1928 switch (le16_to_cpu(dev->descriptor.idProduct)) { 1929 case USB_PID_TEVII_S650: 1930 dw2104_properties.rc.core.rc_codes = RC_MAP_TEVII_NEC; 1931 fallthrough; 1932 case USB_PID_CYPRESS_DW2104: 1933 reset = 1; 1934 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, 1935 DW210X_WRITE_MSG); 1936 fallthrough; 1937 case USB_PID_CYPRESS_DW3101: 1938 reset = 0; 1939 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1940 DW210X_WRITE_MSG); 1941 break; 1942 case USB_PID_TERRATEC_CINERGY_S: 1943 case USB_PID_CYPRESS_DW2102: 1944 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1945 DW210X_WRITE_MSG); 1946 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1947 DW210X_READ_MSG); 1948 /* check STV0299 frontend */ 1949 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, 1950 DW210X_READ_MSG); 1951 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { 1952 dw2102_properties.i2c_algo = &dw2102_i2c_algo; 1953 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; 1954 break; 1955 } else { 1956 /* check STV0288 frontend */ 1957 reset16[0] = 0xd0; 1958 reset16[1] = 1; 1959 reset16[2] = 0; 1960 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, 1961 DW210X_WRITE_MSG); 1962 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, 1963 DW210X_READ_MSG); 1964 if (reset16[2] == 0x11) { 1965 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; 1966 break; 1967 } 1968 } 1969 fallthrough; 1970 case 0x2101: 1971 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, 1972 DW210X_READ_MSG); 1973 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1974 DW210X_READ_MSG); 1975 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1976 DW210X_READ_MSG); 1977 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1978 DW210X_READ_MSG); 1979 break; 1980 } 1981 1982 msleep(100); 1983 kfree(p); 1984 } 1985 1986 if (le16_to_cpu(dev->descriptor.idProduct) == 0x2101) 1987 release_firmware(fw); 1988 return ret; 1989 } 1990 1991 static struct dvb_usb_device_properties dw2102_properties = { 1992 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1993 .usb_ctrl = DEVICE_SPECIFIC, 1994 .firmware = DW2102_FIRMWARE, 1995 .no_reconnect = 1, 1996 1997 .i2c_algo = &dw2102_serit_i2c_algo, 1998 1999 .rc.core = { 2000 .rc_interval = 150, 2001 .rc_codes = RC_MAP_DM1105_NEC, 2002 .module_name = "dw2102", 2003 .allowed_protos = RC_PROTO_BIT_NEC, 2004 .rc_query = dw2102_rc_query, 2005 }, 2006 2007 .generic_bulk_ctrl_endpoint = 0x81, 2008 /* parameter for the MPEG2-data transfer */ 2009 .num_adapters = 1, 2010 .download_firmware = dw2102_load_firmware, 2011 .read_mac_address = dw210x_read_mac_address, 2012 .adapter = { 2013 { 2014 .num_frontends = 1, 2015 .fe = {{ 2016 .frontend_attach = dw2102_frontend_attach, 2017 .stream = { 2018 .type = USB_BULK, 2019 .count = 8, 2020 .endpoint = 0x82, 2021 .u = { 2022 .bulk = { 2023 .buffersize = 4096, 2024 } 2025 } 2026 }, 2027 }}, 2028 } 2029 }, 2030 .num_device_descs = 3, 2031 .devices = { 2032 {"DVBWorld DVB-S 2102 USB2.0", 2033 {&dw2102_table[CYPRESS_DW2102], NULL}, 2034 {NULL}, 2035 }, 2036 {"DVBWorld DVB-S 2101 USB2.0", 2037 {&dw2102_table[CYPRESS_DW2101], NULL}, 2038 {NULL}, 2039 }, 2040 {"TerraTec Cinergy S USB", 2041 {&dw2102_table[TERRATEC_CINERGY_S], NULL}, 2042 {NULL}, 2043 }, 2044 } 2045 }; 2046 2047 static struct dvb_usb_device_properties dw2104_properties = { 2048 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2049 .usb_ctrl = DEVICE_SPECIFIC, 2050 .firmware = DW2104_FIRMWARE, 2051 .no_reconnect = 1, 2052 2053 .i2c_algo = &dw2104_i2c_algo, 2054 .rc.core = { 2055 .rc_interval = 150, 2056 .rc_codes = RC_MAP_DM1105_NEC, 2057 .module_name = "dw2102", 2058 .allowed_protos = RC_PROTO_BIT_NEC, 2059 .rc_query = dw2102_rc_query, 2060 }, 2061 2062 .generic_bulk_ctrl_endpoint = 0x81, 2063 /* parameter for the MPEG2-data transfer */ 2064 .num_adapters = 1, 2065 .download_firmware = dw2102_load_firmware, 2066 .read_mac_address = dw210x_read_mac_address, 2067 .adapter = { 2068 { 2069 .num_frontends = 1, 2070 .fe = {{ 2071 .frontend_attach = dw2104_frontend_attach, 2072 .stream = { 2073 .type = USB_BULK, 2074 .count = 8, 2075 .endpoint = 0x82, 2076 .u = { 2077 .bulk = { 2078 .buffersize = 4096, 2079 } 2080 } 2081 }, 2082 }}, 2083 } 2084 }, 2085 .num_device_descs = 2, 2086 .devices = { 2087 { "DVBWorld DW2104 USB2.0", 2088 {&dw2102_table[CYPRESS_DW2104], NULL}, 2089 {NULL}, 2090 }, 2091 { "TeVii S650 USB2.0", 2092 {&dw2102_table[TEVII_S650], NULL}, 2093 {NULL}, 2094 }, 2095 } 2096 }; 2097 2098 static struct dvb_usb_device_properties dw3101_properties = { 2099 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2100 .usb_ctrl = DEVICE_SPECIFIC, 2101 .firmware = DW3101_FIRMWARE, 2102 .no_reconnect = 1, 2103 2104 .i2c_algo = &dw3101_i2c_algo, 2105 .rc.core = { 2106 .rc_interval = 150, 2107 .rc_codes = RC_MAP_DM1105_NEC, 2108 .module_name = "dw2102", 2109 .allowed_protos = RC_PROTO_BIT_NEC, 2110 .rc_query = dw2102_rc_query, 2111 }, 2112 2113 .generic_bulk_ctrl_endpoint = 0x81, 2114 /* parameter for the MPEG2-data transfer */ 2115 .num_adapters = 1, 2116 .download_firmware = dw2102_load_firmware, 2117 .read_mac_address = dw210x_read_mac_address, 2118 .adapter = { 2119 { 2120 .num_frontends = 1, 2121 .fe = {{ 2122 .frontend_attach = dw3101_frontend_attach, 2123 .tuner_attach = dw3101_tuner_attach, 2124 .stream = { 2125 .type = USB_BULK, 2126 .count = 8, 2127 .endpoint = 0x82, 2128 .u = { 2129 .bulk = { 2130 .buffersize = 4096, 2131 } 2132 } 2133 }, 2134 }}, 2135 } 2136 }, 2137 .num_device_descs = 1, 2138 .devices = { 2139 { "DVBWorld DVB-C 3101 USB2.0", 2140 {&dw2102_table[CYPRESS_DW3101], NULL}, 2141 {NULL}, 2142 }, 2143 } 2144 }; 2145 2146 static struct dvb_usb_device_properties s6x0_properties = { 2147 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2148 .usb_ctrl = DEVICE_SPECIFIC, 2149 .size_of_priv = sizeof(struct dw2102_state), 2150 .firmware = S630_FIRMWARE, 2151 .no_reconnect = 1, 2152 2153 .i2c_algo = &s6x0_i2c_algo, 2154 .rc.core = { 2155 .rc_interval = 150, 2156 .rc_codes = RC_MAP_TEVII_NEC, 2157 .module_name = "dw2102", 2158 .allowed_protos = RC_PROTO_BIT_NEC, 2159 .rc_query = dw2102_rc_query, 2160 }, 2161 2162 .generic_bulk_ctrl_endpoint = 0x81, 2163 .num_adapters = 1, 2164 .download_firmware = dw2102_load_firmware, 2165 .read_mac_address = s6x0_read_mac_address, 2166 .adapter = { 2167 { 2168 .num_frontends = 1, 2169 .fe = {{ 2170 .frontend_attach = zl100313_frontend_attach, 2171 .stream = { 2172 .type = USB_BULK, 2173 .count = 8, 2174 .endpoint = 0x82, 2175 .u = { 2176 .bulk = { 2177 .buffersize = 4096, 2178 } 2179 } 2180 }, 2181 }}, 2182 } 2183 }, 2184 .num_device_descs = 1, 2185 .devices = { 2186 {"TeVii S630 USB", 2187 {&dw2102_table[TEVII_S630], NULL}, 2188 {NULL}, 2189 }, 2190 } 2191 }; 2192 2193 static struct dvb_usb_device_properties p1100_properties = { 2194 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2195 .usb_ctrl = DEVICE_SPECIFIC, 2196 .size_of_priv = sizeof(struct dw2102_state), 2197 .firmware = P1100_FIRMWARE, 2198 .no_reconnect = 1, 2199 2200 .i2c_algo = &s6x0_i2c_algo, 2201 .rc.core = { 2202 .rc_interval = 150, 2203 .rc_codes = RC_MAP_TBS_NEC, 2204 .module_name = "dw2102", 2205 .allowed_protos = RC_PROTO_BIT_NEC, 2206 .rc_query = prof_rc_query, 2207 }, 2208 2209 .generic_bulk_ctrl_endpoint = 0x81, 2210 .num_adapters = 1, 2211 .download_firmware = dw2102_load_firmware, 2212 .read_mac_address = s6x0_read_mac_address, 2213 .adapter = { 2214 { 2215 .num_frontends = 1, 2216 .fe = {{ 2217 .frontend_attach = stv0288_frontend_attach, 2218 .stream = { 2219 .type = USB_BULK, 2220 .count = 8, 2221 .endpoint = 0x82, 2222 .u = { 2223 .bulk = { 2224 .buffersize = 4096, 2225 } 2226 } 2227 }, 2228 } }, 2229 } 2230 }, 2231 .num_device_descs = 1, 2232 .devices = { 2233 {"Prof 1100 USB ", 2234 {&dw2102_table[PROF_1100], NULL}, 2235 {NULL}, 2236 }, 2237 } 2238 }; 2239 2240 static struct dvb_usb_device_properties s660_properties = { 2241 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2242 .usb_ctrl = DEVICE_SPECIFIC, 2243 .size_of_priv = sizeof(struct dw2102_state), 2244 .firmware = S660_FIRMWARE, 2245 .no_reconnect = 1, 2246 2247 .i2c_algo = &s6x0_i2c_algo, 2248 .rc.core = { 2249 .rc_interval = 150, 2250 .rc_codes = RC_MAP_TEVII_NEC, 2251 .module_name = "dw2102", 2252 .allowed_protos = RC_PROTO_BIT_NEC, 2253 .rc_query = dw2102_rc_query, 2254 }, 2255 2256 .generic_bulk_ctrl_endpoint = 0x81, 2257 .num_adapters = 1, 2258 .download_firmware = dw2102_load_firmware, 2259 .read_mac_address = s6x0_read_mac_address, 2260 .adapter = { 2261 { 2262 .num_frontends = 1, 2263 .fe = {{ 2264 .frontend_attach = ds3000_frontend_attach, 2265 .stream = { 2266 .type = USB_BULK, 2267 .count = 8, 2268 .endpoint = 0x82, 2269 .u = { 2270 .bulk = { 2271 .buffersize = 4096, 2272 } 2273 } 2274 }, 2275 } }, 2276 } 2277 }, 2278 .num_device_descs = 3, 2279 .devices = { 2280 {"TeVii S660 USB", 2281 {&dw2102_table[TEVII_S660], NULL}, 2282 {NULL}, 2283 }, 2284 {"TeVii S480.1 USB", 2285 {&dw2102_table[TEVII_S480_1], NULL}, 2286 {NULL}, 2287 }, 2288 {"TeVii S480.2 USB", 2289 {&dw2102_table[TEVII_S480_2], NULL}, 2290 {NULL}, 2291 }, 2292 } 2293 }; 2294 2295 static struct dvb_usb_device_properties p7500_properties = { 2296 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2297 .usb_ctrl = DEVICE_SPECIFIC, 2298 .size_of_priv = sizeof(struct dw2102_state), 2299 .firmware = P7500_FIRMWARE, 2300 .no_reconnect = 1, 2301 2302 .i2c_algo = &s6x0_i2c_algo, 2303 .rc.core = { 2304 .rc_interval = 150, 2305 .rc_codes = RC_MAP_TBS_NEC, 2306 .module_name = "dw2102", 2307 .allowed_protos = RC_PROTO_BIT_NEC, 2308 .rc_query = prof_rc_query, 2309 }, 2310 2311 .generic_bulk_ctrl_endpoint = 0x81, 2312 .num_adapters = 1, 2313 .download_firmware = dw2102_load_firmware, 2314 .read_mac_address = s6x0_read_mac_address, 2315 .adapter = { 2316 { 2317 .num_frontends = 1, 2318 .fe = {{ 2319 .frontend_attach = prof_7500_frontend_attach, 2320 .stream = { 2321 .type = USB_BULK, 2322 .count = 8, 2323 .endpoint = 0x82, 2324 .u = { 2325 .bulk = { 2326 .buffersize = 4096, 2327 } 2328 } 2329 }, 2330 } }, 2331 } 2332 }, 2333 .num_device_descs = 1, 2334 .devices = { 2335 {"Prof 7500 USB DVB-S2", 2336 {&dw2102_table[PROF_7500], NULL}, 2337 {NULL}, 2338 }, 2339 } 2340 }; 2341 2342 static struct dvb_usb_device_properties su3000_properties = { 2343 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2344 .usb_ctrl = DEVICE_SPECIFIC, 2345 .size_of_priv = sizeof(struct dw2102_state), 2346 .power_ctrl = su3000_power_ctrl, 2347 .num_adapters = 1, 2348 .identify_state = su3000_identify_state, 2349 .i2c_algo = &su3000_i2c_algo, 2350 2351 .rc.core = { 2352 .rc_interval = 150, 2353 .rc_codes = RC_MAP_SU3000, 2354 .module_name = "dw2102", 2355 .allowed_protos = RC_PROTO_BIT_RC5, 2356 .rc_query = su3000_rc_query, 2357 }, 2358 2359 .read_mac_address = su3000_read_mac_address, 2360 2361 .generic_bulk_ctrl_endpoint = 0x01, 2362 2363 .adapter = { 2364 { 2365 .num_frontends = 1, 2366 .fe = {{ 2367 .streaming_ctrl = su3000_streaming_ctrl, 2368 .frontend_attach = su3000_frontend_attach, 2369 .stream = { 2370 .type = USB_BULK, 2371 .count = 8, 2372 .endpoint = 0x82, 2373 .u = { 2374 .bulk = { 2375 .buffersize = 4096, 2376 } 2377 } 2378 } 2379 }}, 2380 } 2381 }, 2382 .num_device_descs = 9, 2383 .devices = { 2384 { "SU3000HD DVB-S USB2.0", 2385 { &dw2102_table[GENIATECH_SU3000], NULL }, 2386 { NULL }, 2387 }, 2388 { "Hauppauge MAX S2 or WinTV NOVA HD USB2.0", 2389 { &dw2102_table[HAUPPAUGE_MAX_S2], NULL }, 2390 { NULL }, 2391 }, 2392 { "Terratec Cinergy S2 USB HD", 2393 { &dw2102_table[TERRATEC_CINERGY_S2_R1], NULL }, 2394 { NULL }, 2395 }, 2396 { "X3M TV SPC1400HD PCI", 2397 { &dw2102_table[GENIATECH_X3M_SPC1400HD], NULL }, 2398 { NULL }, 2399 }, 2400 { "Terratec Cinergy S2 USB HD Rev.2", 2401 { &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL }, 2402 { NULL }, 2403 }, 2404 { "Terratec Cinergy S2 USB HD Rev.3", 2405 { &dw2102_table[TERRATEC_CINERGY_S2_R3], NULL }, 2406 { NULL }, 2407 }, 2408 { "Terratec Cinergy S2 PCIe Dual Port 1", 2409 { &dw2102_table[TERRATEC_CINERGY_S2_1], NULL }, 2410 { NULL }, 2411 }, 2412 { "Terratec Cinergy S2 PCIe Dual Port 2", 2413 { &dw2102_table[TERRATEC_CINERGY_S2_2], NULL }, 2414 { NULL }, 2415 }, 2416 { "GOTVIEW Satellite HD", 2417 { &dw2102_table[GOTVIEW_SAT_HD], NULL }, 2418 { NULL }, 2419 }, 2420 } 2421 }; 2422 2423 static struct dvb_usb_device_properties s421_properties = { 2424 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2425 .usb_ctrl = DEVICE_SPECIFIC, 2426 .size_of_priv = sizeof(struct dw2102_state), 2427 .power_ctrl = su3000_power_ctrl, 2428 .num_adapters = 1, 2429 .identify_state = su3000_identify_state, 2430 .i2c_algo = &su3000_i2c_algo, 2431 2432 .rc.core = { 2433 .rc_interval = 150, 2434 .rc_codes = RC_MAP_SU3000, 2435 .module_name = "dw2102", 2436 .allowed_protos = RC_PROTO_BIT_RC5, 2437 .rc_query = su3000_rc_query, 2438 }, 2439 2440 .read_mac_address = su3000_read_mac_address, 2441 2442 .generic_bulk_ctrl_endpoint = 0x01, 2443 2444 .adapter = { 2445 { 2446 .num_frontends = 1, 2447 .fe = {{ 2448 .streaming_ctrl = su3000_streaming_ctrl, 2449 .frontend_attach = m88rs2000_frontend_attach, 2450 .stream = { 2451 .type = USB_BULK, 2452 .count = 8, 2453 .endpoint = 0x82, 2454 .u = { 2455 .bulk = { 2456 .buffersize = 4096, 2457 } 2458 } 2459 } 2460 } }, 2461 } 2462 }, 2463 .num_device_descs = 2, 2464 .devices = { 2465 { "TeVii S421 PCI", 2466 { &dw2102_table[TEVII_S421], NULL }, 2467 { NULL }, 2468 }, 2469 { "TeVii S632 USB", 2470 { &dw2102_table[TEVII_S632], NULL }, 2471 { NULL }, 2472 }, 2473 } 2474 }; 2475 2476 static struct dvb_usb_device_properties t220_properties = { 2477 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2478 .usb_ctrl = DEVICE_SPECIFIC, 2479 .size_of_priv = sizeof(struct dw2102_state), 2480 .power_ctrl = su3000_power_ctrl, 2481 .num_adapters = 1, 2482 .identify_state = su3000_identify_state, 2483 .i2c_algo = &su3000_i2c_algo, 2484 2485 .rc.core = { 2486 .rc_interval = 150, 2487 .rc_codes = RC_MAP_SU3000, 2488 .module_name = "dw2102", 2489 .allowed_protos = RC_PROTO_BIT_RC5, 2490 .rc_query = su3000_rc_query, 2491 }, 2492 2493 .read_mac_address = su3000_read_mac_address, 2494 2495 .generic_bulk_ctrl_endpoint = 0x01, 2496 2497 .adapter = { 2498 { 2499 .num_frontends = 1, 2500 .fe = { { 2501 .streaming_ctrl = su3000_streaming_ctrl, 2502 .frontend_attach = t220_frontend_attach, 2503 .stream = { 2504 .type = USB_BULK, 2505 .count = 8, 2506 .endpoint = 0x82, 2507 .u = { 2508 .bulk = { 2509 .buffersize = 4096, 2510 } 2511 } 2512 } 2513 } }, 2514 } 2515 }, 2516 .num_device_descs = 1, 2517 .devices = { 2518 { "Geniatech T220 DVB-T/T2 USB2.0", 2519 { &dw2102_table[GENIATECH_T220], NULL }, 2520 { NULL }, 2521 }, 2522 } 2523 }; 2524 2525 static struct dvb_usb_device_properties tt_s2_4600_properties = { 2526 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 2527 .usb_ctrl = DEVICE_SPECIFIC, 2528 .size_of_priv = sizeof(struct dw2102_state), 2529 .power_ctrl = su3000_power_ctrl, 2530 .num_adapters = 1, 2531 .identify_state = su3000_identify_state, 2532 .i2c_algo = &su3000_i2c_algo, 2533 2534 .rc.core = { 2535 .rc_interval = 250, 2536 .rc_codes = RC_MAP_TT_1500, 2537 .module_name = "dw2102", 2538 .allowed_protos = RC_PROTO_BIT_RC5, 2539 .rc_query = su3000_rc_query, 2540 }, 2541 2542 .read_mac_address = su3000_read_mac_address, 2543 2544 .generic_bulk_ctrl_endpoint = 0x01, 2545 2546 .adapter = { 2547 { 2548 .num_frontends = 1, 2549 .fe = {{ 2550 .streaming_ctrl = su3000_streaming_ctrl, 2551 .frontend_attach = tt_s2_4600_frontend_attach, 2552 .stream = { 2553 .type = USB_BULK, 2554 .count = 8, 2555 .endpoint = 0x82, 2556 .u = { 2557 .bulk = { 2558 .buffersize = 4096, 2559 } 2560 } 2561 } 2562 } }, 2563 } 2564 }, 2565 .num_device_descs = 5, 2566 .devices = { 2567 { "TechnoTrend TT-connect S2-4600", 2568 { &dw2102_table[TECHNOTREND_CONNECT_S2_4600], NULL }, 2569 { NULL }, 2570 }, 2571 { "TeVii S482 (tuner 1)", 2572 { &dw2102_table[TEVII_S482_1], NULL }, 2573 { NULL }, 2574 }, 2575 { "TeVii S482 (tuner 2)", 2576 { &dw2102_table[TEVII_S482_2], NULL }, 2577 { NULL }, 2578 }, 2579 { "Terratec Cinergy S2 USB BOX", 2580 { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL }, 2581 { NULL }, 2582 }, 2583 { "TeVii S662", 2584 { &dw2102_table[TEVII_S662], NULL }, 2585 { NULL }, 2586 }, 2587 } 2588 }; 2589 2590 static int dw2102_probe(struct usb_interface *intf, 2591 const struct usb_device_id *id) 2592 { 2593 if (!(dvb_usb_device_init(intf, &dw2102_properties, 2594 THIS_MODULE, NULL, adapter_nr) && 2595 dvb_usb_device_init(intf, &dw2104_properties, 2596 THIS_MODULE, NULL, adapter_nr) && 2597 dvb_usb_device_init(intf, &dw3101_properties, 2598 THIS_MODULE, NULL, adapter_nr) && 2599 dvb_usb_device_init(intf, &s6x0_properties, 2600 THIS_MODULE, NULL, adapter_nr) && 2601 dvb_usb_device_init(intf, &p1100_properties, 2602 THIS_MODULE, NULL, adapter_nr) && 2603 dvb_usb_device_init(intf, &s660_properties, 2604 THIS_MODULE, NULL, adapter_nr) && 2605 dvb_usb_device_init(intf, &p7500_properties, 2606 THIS_MODULE, NULL, adapter_nr) && 2607 dvb_usb_device_init(intf, &s421_properties, 2608 THIS_MODULE, NULL, adapter_nr) && 2609 dvb_usb_device_init(intf, &su3000_properties, 2610 THIS_MODULE, NULL, adapter_nr) && 2611 dvb_usb_device_init(intf, &t220_properties, 2612 THIS_MODULE, NULL, adapter_nr) && 2613 dvb_usb_device_init(intf, &tt_s2_4600_properties, 2614 THIS_MODULE, NULL, adapter_nr))) { 2615 2616 return 0; 2617 } 2618 2619 return -ENODEV; 2620 } 2621 2622 static void dw2102_disconnect(struct usb_interface *intf) 2623 { 2624 struct dvb_usb_device *d = usb_get_intfdata(intf); 2625 struct dw2102_state *st = d->priv; 2626 struct i2c_client *client; 2627 2628 /* remove I2C client for tuner */ 2629 client = st->i2c_client_tuner; 2630 if (client) { 2631 module_put(client->dev.driver->owner); 2632 i2c_unregister_device(client); 2633 } 2634 2635 /* remove I2C client for demodulator */ 2636 client = st->i2c_client_demod; 2637 if (client) { 2638 module_put(client->dev.driver->owner); 2639 i2c_unregister_device(client); 2640 } 2641 2642 dvb_usb_device_exit(intf); 2643 } 2644 2645 static struct usb_driver dw2102_driver = { 2646 .name = "dw2102", 2647 .probe = dw2102_probe, 2648 .disconnect = dw2102_disconnect, 2649 .id_table = dw2102_table, 2650 }; 2651 2652 module_usb_driver(dw2102_driver); 2653 2654 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 2655 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101 USB2.0, TeVii S421, S480, S482, S600, S630, S632, S650, TeVii S660, S662, Prof 1100, 7500 USB2.0, Geniatech SU3000, T220, TechnoTrend S2-4600, Terratec Cinergy S2 devices"); 2656 MODULE_VERSION("0.1"); 2657 MODULE_LICENSE("GPL"); 2658 MODULE_FIRMWARE(DW2101_FIRMWARE); 2659 MODULE_FIRMWARE(DW2102_FIRMWARE); 2660 MODULE_FIRMWARE(DW2104_FIRMWARE); 2661 MODULE_FIRMWARE(DW3101_FIRMWARE); 2662 MODULE_FIRMWARE(S630_FIRMWARE); 2663 MODULE_FIRMWARE(S660_FIRMWARE); 2664 MODULE_FIRMWARE(P1100_FIRMWARE); 2665 MODULE_FIRMWARE(P7500_FIRMWARE); 2666