1 /* DVB USB framework compliant Linux driver for the 2 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 3 * TeVii S600, S630, S650, S660, S480, 4 * Prof 1100, 7500, 5 * Geniatech SU3000 Cards 6 * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by) 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License as published by the 10 * Free Software Foundation, version 2. 11 * 12 * see Documentation/dvb/README.dvb-usb for more information 13 */ 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 32 #ifndef USB_PID_DW2102 33 #define USB_PID_DW2102 0x2102 34 #endif 35 36 #ifndef USB_PID_DW2104 37 #define USB_PID_DW2104 0x2104 38 #endif 39 40 #ifndef USB_PID_DW3101 41 #define USB_PID_DW3101 0x3101 42 #endif 43 44 #ifndef USB_PID_CINERGY_S 45 #define USB_PID_CINERGY_S 0x0064 46 #endif 47 48 #ifndef USB_PID_TEVII_S630 49 #define USB_PID_TEVII_S630 0xd630 50 #endif 51 52 #ifndef USB_PID_TEVII_S650 53 #define USB_PID_TEVII_S650 0xd650 54 #endif 55 56 #ifndef USB_PID_TEVII_S660 57 #define USB_PID_TEVII_S660 0xd660 58 #endif 59 60 #ifndef USB_PID_TEVII_S480_1 61 #define USB_PID_TEVII_S480_1 0xd481 62 #endif 63 64 #ifndef USB_PID_TEVII_S480_2 65 #define USB_PID_TEVII_S480_2 0xd482 66 #endif 67 68 #ifndef USB_PID_PROF_1100 69 #define USB_PID_PROF_1100 0xb012 70 #endif 71 72 #define DW210X_READ_MSG 0 73 #define DW210X_WRITE_MSG 1 74 75 #define REG_1F_SYMBOLRATE_BYTE0 0x1f 76 #define REG_20_SYMBOLRATE_BYTE1 0x20 77 #define REG_21_SYMBOLRATE_BYTE2 0x21 78 /* on my own*/ 79 #define DW2102_VOLTAGE_CTRL (0x1800) 80 #define SU3000_STREAM_CTRL (0x1900) 81 #define DW2102_RC_QUERY (0x1a00) 82 #define DW2102_LED_CTRL (0x1b00) 83 84 #define DW2101_FIRMWARE "dvb-usb-dw2101.fw" 85 #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" 86 #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" 87 #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" 88 #define S630_FIRMWARE "dvb-usb-s630.fw" 89 #define S660_FIRMWARE "dvb-usb-s660.fw" 90 #define P1100_FIRMWARE "dvb-usb-p1100.fw" 91 #define P7500_FIRMWARE "dvb-usb-p7500.fw" 92 93 #define err_str "did not find the firmware file. (%s) " \ 94 "Please see linux/Documentation/dvb/ for more details " \ 95 "on firmware-problems." 96 97 struct rc_map_dvb_usb_table_table { 98 struct rc_map_table *rc_keys; 99 int rc_keys_size; 100 }; 101 102 struct su3000_state { 103 u8 initialized; 104 }; 105 106 struct s6x0_state { 107 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v); 108 }; 109 110 /* debug */ 111 static int dvb_usb_dw2102_debug; 112 module_param_named(debug, dvb_usb_dw2102_debug, int, 0644); 113 MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))." 114 DVB_USB_DEBUG_STATUS); 115 116 /* keymaps */ 117 static int ir_keymap; 118 module_param_named(keymap, ir_keymap, int, 0644); 119 MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..." 120 " 256=none"); 121 122 /* demod probe */ 123 static int demod_probe = 1; 124 module_param_named(demod, demod_probe, int, 0644); 125 MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 " 126 "4=stv0903+stb6100(or-able))."); 127 128 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 129 130 static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, 131 u16 index, u8 * data, u16 len, int flags) 132 { 133 int ret; 134 u8 *u8buf; 135 unsigned int pipe = (flags == DW210X_READ_MSG) ? 136 usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0); 137 u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT; 138 139 u8buf = kmalloc(len, GFP_KERNEL); 140 if (!u8buf) 141 return -ENOMEM; 142 143 144 if (flags == DW210X_WRITE_MSG) 145 memcpy(u8buf, data, len); 146 ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, 147 value, index , u8buf, len, 2000); 148 149 if (flags == DW210X_READ_MSG) 150 memcpy(data, u8buf, len); 151 152 kfree(u8buf); 153 return ret; 154 } 155 156 /* I2C */ 157 static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 158 int num) 159 { 160 struct dvb_usb_device *d = i2c_get_adapdata(adap); 161 int i = 0; 162 u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0}; 163 u16 value; 164 165 if (!d) 166 return -ENODEV; 167 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 168 return -EAGAIN; 169 170 switch (num) { 171 case 2: 172 /* read stv0299 register */ 173 value = msg[0].buf[0];/* register */ 174 for (i = 0; i < msg[1].len; i++) { 175 dw210x_op_rw(d->udev, 0xb5, value + i, 0, 176 buf6, 2, DW210X_READ_MSG); 177 msg[1].buf[i] = buf6[0]; 178 } 179 break; 180 case 1: 181 switch (msg[0].addr) { 182 case 0x68: 183 /* write to stv0299 register */ 184 buf6[0] = 0x2a; 185 buf6[1] = msg[0].buf[0]; 186 buf6[2] = msg[0].buf[1]; 187 dw210x_op_rw(d->udev, 0xb2, 0, 0, 188 buf6, 3, DW210X_WRITE_MSG); 189 break; 190 case 0x60: 191 if (msg[0].flags == 0) { 192 /* write to tuner pll */ 193 buf6[0] = 0x2c; 194 buf6[1] = 5; 195 buf6[2] = 0xc0; 196 buf6[3] = msg[0].buf[0]; 197 buf6[4] = msg[0].buf[1]; 198 buf6[5] = msg[0].buf[2]; 199 buf6[6] = msg[0].buf[3]; 200 dw210x_op_rw(d->udev, 0xb2, 0, 0, 201 buf6, 7, DW210X_WRITE_MSG); 202 } else { 203 /* read from tuner */ 204 dw210x_op_rw(d->udev, 0xb5, 0, 0, 205 buf6, 1, DW210X_READ_MSG); 206 msg[0].buf[0] = buf6[0]; 207 } 208 break; 209 case (DW2102_RC_QUERY): 210 dw210x_op_rw(d->udev, 0xb8, 0, 0, 211 buf6, 2, DW210X_READ_MSG); 212 msg[0].buf[0] = buf6[0]; 213 msg[0].buf[1] = buf6[1]; 214 break; 215 case (DW2102_VOLTAGE_CTRL): 216 buf6[0] = 0x30; 217 buf6[1] = msg[0].buf[0]; 218 dw210x_op_rw(d->udev, 0xb2, 0, 0, 219 buf6, 2, DW210X_WRITE_MSG); 220 break; 221 } 222 223 break; 224 } 225 226 mutex_unlock(&d->i2c_mutex); 227 return num; 228 } 229 230 static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, 231 struct i2c_msg msg[], int num) 232 { 233 struct dvb_usb_device *d = i2c_get_adapdata(adap); 234 u8 buf6[] = {0, 0, 0, 0, 0, 0, 0}; 235 236 if (!d) 237 return -ENODEV; 238 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 239 return -EAGAIN; 240 241 switch (num) { 242 case 2: 243 /* read si2109 register by number */ 244 buf6[0] = msg[0].addr << 1; 245 buf6[1] = msg[0].len; 246 buf6[2] = msg[0].buf[0]; 247 dw210x_op_rw(d->udev, 0xc2, 0, 0, 248 buf6, msg[0].len + 2, DW210X_WRITE_MSG); 249 /* read si2109 register */ 250 dw210x_op_rw(d->udev, 0xc3, 0xd0, 0, 251 buf6, msg[1].len + 2, DW210X_READ_MSG); 252 memcpy(msg[1].buf, buf6 + 2, msg[1].len); 253 254 break; 255 case 1: 256 switch (msg[0].addr) { 257 case 0x68: 258 /* write to si2109 register */ 259 buf6[0] = msg[0].addr << 1; 260 buf6[1] = msg[0].len; 261 memcpy(buf6 + 2, msg[0].buf, msg[0].len); 262 dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6, 263 msg[0].len + 2, DW210X_WRITE_MSG); 264 break; 265 case(DW2102_RC_QUERY): 266 dw210x_op_rw(d->udev, 0xb8, 0, 0, 267 buf6, 2, DW210X_READ_MSG); 268 msg[0].buf[0] = buf6[0]; 269 msg[0].buf[1] = buf6[1]; 270 break; 271 case(DW2102_VOLTAGE_CTRL): 272 buf6[0] = 0x30; 273 buf6[1] = msg[0].buf[0]; 274 dw210x_op_rw(d->udev, 0xb2, 0, 0, 275 buf6, 2, DW210X_WRITE_MSG); 276 break; 277 } 278 break; 279 } 280 281 mutex_unlock(&d->i2c_mutex); 282 return num; 283 } 284 285 static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 286 { 287 struct dvb_usb_device *d = i2c_get_adapdata(adap); 288 289 if (!d) 290 return -ENODEV; 291 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 292 return -EAGAIN; 293 294 switch (num) { 295 case 2: { 296 /* read */ 297 /* first write first register number */ 298 u8 ibuf[msg[1].len + 2], obuf[3]; 299 obuf[0] = msg[0].addr << 1; 300 obuf[1] = msg[0].len; 301 obuf[2] = msg[0].buf[0]; 302 dw210x_op_rw(d->udev, 0xc2, 0, 0, 303 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 304 /* second read registers */ 305 dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, 306 ibuf, msg[1].len + 2, DW210X_READ_MSG); 307 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 308 309 break; 310 } 311 case 1: 312 switch (msg[0].addr) { 313 case 0x68: { 314 /* write to register */ 315 u8 obuf[msg[0].len + 2]; 316 obuf[0] = msg[0].addr << 1; 317 obuf[1] = msg[0].len; 318 memcpy(obuf + 2, msg[0].buf, msg[0].len); 319 dw210x_op_rw(d->udev, 0xc2, 0, 0, 320 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 321 break; 322 } 323 case 0x61: { 324 /* write to tuner */ 325 u8 obuf[msg[0].len + 2]; 326 obuf[0] = msg[0].addr << 1; 327 obuf[1] = msg[0].len; 328 memcpy(obuf + 2, msg[0].buf, msg[0].len); 329 dw210x_op_rw(d->udev, 0xc2, 0, 0, 330 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 331 break; 332 } 333 case(DW2102_RC_QUERY): { 334 u8 ibuf[2]; 335 dw210x_op_rw(d->udev, 0xb8, 0, 0, 336 ibuf, 2, DW210X_READ_MSG); 337 memcpy(msg[0].buf, ibuf , 2); 338 break; 339 } 340 case(DW2102_VOLTAGE_CTRL): { 341 u8 obuf[2]; 342 obuf[0] = 0x30; 343 obuf[1] = msg[0].buf[0]; 344 dw210x_op_rw(d->udev, 0xb2, 0, 0, 345 obuf, 2, DW210X_WRITE_MSG); 346 break; 347 } 348 } 349 350 break; 351 } 352 353 mutex_unlock(&d->i2c_mutex); 354 return num; 355 } 356 357 static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) 358 { 359 struct dvb_usb_device *d = i2c_get_adapdata(adap); 360 int len, i, j; 361 362 if (!d) 363 return -ENODEV; 364 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 365 return -EAGAIN; 366 367 for (j = 0; j < num; j++) { 368 switch (msg[j].addr) { 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[j].buf, ibuf , 2); 374 break; 375 } 376 case(DW2102_VOLTAGE_CTRL): { 377 u8 obuf[2]; 378 obuf[0] = 0x30; 379 obuf[1] = msg[j].buf[0]; 380 dw210x_op_rw(d->udev, 0xb2, 0, 0, 381 obuf, 2, DW210X_WRITE_MSG); 382 break; 383 } 384 /*case 0x55: cx24116 385 case 0x6a: stv0903 386 case 0x68: ds3000, stv0903 387 case 0x60: ts2020, stv6110, stb6100 */ 388 default: { 389 if (msg[j].flags == I2C_M_RD) { 390 /* read registers */ 391 u8 ibuf[msg[j].len + 2]; 392 dw210x_op_rw(d->udev, 0xc3, 393 (msg[j].addr << 1) + 1, 0, 394 ibuf, msg[j].len + 2, 395 DW210X_READ_MSG); 396 memcpy(msg[j].buf, ibuf + 2, msg[j].len); 397 mdelay(10); 398 } else if (((msg[j].buf[0] == 0xb0) && 399 (msg[j].addr == 0x68)) || 400 ((msg[j].buf[0] == 0xf7) && 401 (msg[j].addr == 0x55))) { 402 /* write firmware */ 403 u8 obuf[19]; 404 obuf[0] = msg[j].addr << 1; 405 obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); 406 obuf[2] = msg[j].buf[0]; 407 len = msg[j].len - 1; 408 i = 1; 409 do { 410 memcpy(obuf + 3, msg[j].buf + i, 411 (len > 16 ? 16 : len)); 412 dw210x_op_rw(d->udev, 0xc2, 0, 0, 413 obuf, (len > 16 ? 16 : len) + 3, 414 DW210X_WRITE_MSG); 415 i += 16; 416 len -= 16; 417 } while (len > 0); 418 } else { 419 /* write registers */ 420 u8 obuf[msg[j].len + 2]; 421 obuf[0] = msg[j].addr << 1; 422 obuf[1] = msg[j].len; 423 memcpy(obuf + 2, msg[j].buf, msg[j].len); 424 dw210x_op_rw(d->udev, 0xc2, 0, 0, 425 obuf, msg[j].len + 2, 426 DW210X_WRITE_MSG); 427 } 428 break; 429 } 430 } 431 432 } 433 434 mutex_unlock(&d->i2c_mutex); 435 return num; 436 } 437 438 static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 439 int num) 440 { 441 struct dvb_usb_device *d = i2c_get_adapdata(adap); 442 int i; 443 444 if (!d) 445 return -ENODEV; 446 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 447 return -EAGAIN; 448 449 switch (num) { 450 case 2: { 451 /* read */ 452 /* first write first register number */ 453 u8 ibuf[msg[1].len + 2], obuf[3]; 454 obuf[0] = msg[0].addr << 1; 455 obuf[1] = msg[0].len; 456 obuf[2] = msg[0].buf[0]; 457 dw210x_op_rw(d->udev, 0xc2, 0, 0, 458 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 459 /* second read registers */ 460 dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, 461 ibuf, msg[1].len + 2, DW210X_READ_MSG); 462 memcpy(msg[1].buf, ibuf + 2, msg[1].len); 463 464 break; 465 } 466 case 1: 467 switch (msg[0].addr) { 468 case 0x60: 469 case 0x0c: { 470 /* write to register */ 471 u8 obuf[msg[0].len + 2]; 472 obuf[0] = msg[0].addr << 1; 473 obuf[1] = msg[0].len; 474 memcpy(obuf + 2, msg[0].buf, msg[0].len); 475 dw210x_op_rw(d->udev, 0xc2, 0, 0, 476 obuf, msg[0].len + 2, DW210X_WRITE_MSG); 477 break; 478 } 479 case(DW2102_RC_QUERY): { 480 u8 ibuf[2]; 481 dw210x_op_rw(d->udev, 0xb8, 0, 0, 482 ibuf, 2, DW210X_READ_MSG); 483 memcpy(msg[0].buf, ibuf , 2); 484 break; 485 } 486 } 487 488 break; 489 } 490 491 for (i = 0; i < num; i++) { 492 deb_xfer("%02x:%02x: %s ", i, msg[i].addr, 493 msg[i].flags == 0 ? ">>>" : "<<<"); 494 debug_dump(msg[i].buf, msg[i].len, deb_xfer); 495 } 496 497 mutex_unlock(&d->i2c_mutex); 498 return num; 499 } 500 501 static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 502 int num) 503 { 504 struct dvb_usb_device *d = i2c_get_adapdata(adap); 505 struct usb_device *udev; 506 int len, i, j; 507 508 if (!d) 509 return -ENODEV; 510 udev = d->udev; 511 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 512 return -EAGAIN; 513 514 for (j = 0; j < num; j++) { 515 switch (msg[j].addr) { 516 case (DW2102_RC_QUERY): { 517 u8 ibuf[5]; 518 dw210x_op_rw(d->udev, 0xb8, 0, 0, 519 ibuf, 5, DW210X_READ_MSG); 520 memcpy(msg[j].buf, ibuf + 3, 2); 521 break; 522 } 523 case (DW2102_VOLTAGE_CTRL): { 524 u8 obuf[2]; 525 526 obuf[0] = 1; 527 obuf[1] = msg[j].buf[1];/* off-on */ 528 dw210x_op_rw(d->udev, 0x8a, 0, 0, 529 obuf, 2, DW210X_WRITE_MSG); 530 obuf[0] = 3; 531 obuf[1] = msg[j].buf[0];/* 13v-18v */ 532 dw210x_op_rw(d->udev, 0x8a, 0, 0, 533 obuf, 2, DW210X_WRITE_MSG); 534 break; 535 } 536 case (DW2102_LED_CTRL): { 537 u8 obuf[2]; 538 539 obuf[0] = 5; 540 obuf[1] = msg[j].buf[0]; 541 dw210x_op_rw(d->udev, 0x8a, 0, 0, 542 obuf, 2, DW210X_WRITE_MSG); 543 break; 544 } 545 /*case 0x55: cx24116 546 case 0x6a: stv0903 547 case 0x68: ds3000, stv0903 548 case 0x60: ts2020, stv6110, stb6100 549 case 0xa0: eeprom */ 550 default: { 551 if (msg[j].flags == I2C_M_RD) { 552 /* read registers */ 553 u8 ibuf[msg[j].len]; 554 dw210x_op_rw(d->udev, 0x91, 0, 0, 555 ibuf, msg[j].len, 556 DW210X_READ_MSG); 557 memcpy(msg[j].buf, ibuf, msg[j].len); 558 break; 559 } else if ((msg[j].buf[0] == 0xb0) && 560 (msg[j].addr == 0x68)) { 561 /* write firmware */ 562 u8 obuf[19]; 563 obuf[0] = (msg[j].len > 16 ? 564 18 : msg[j].len + 1); 565 obuf[1] = msg[j].addr << 1; 566 obuf[2] = msg[j].buf[0]; 567 len = msg[j].len - 1; 568 i = 1; 569 do { 570 memcpy(obuf + 3, msg[j].buf + i, 571 (len > 16 ? 16 : len)); 572 dw210x_op_rw(d->udev, 0x80, 0, 0, 573 obuf, (len > 16 ? 16 : len) + 3, 574 DW210X_WRITE_MSG); 575 i += 16; 576 len -= 16; 577 } while (len > 0); 578 } else if (j < (num - 1)) { 579 /* write register addr before read */ 580 u8 obuf[msg[j].len + 2]; 581 obuf[0] = msg[j + 1].len; 582 obuf[1] = (msg[j].addr << 1); 583 memcpy(obuf + 2, msg[j].buf, msg[j].len); 584 dw210x_op_rw(d->udev, 585 udev->descriptor.idProduct == 586 0x7500 ? 0x92 : 0x90, 0, 0, 587 obuf, msg[j].len + 2, 588 DW210X_WRITE_MSG); 589 break; 590 } else { 591 /* write registers */ 592 u8 obuf[msg[j].len + 2]; 593 obuf[0] = msg[j].len + 1; 594 obuf[1] = (msg[j].addr << 1); 595 memcpy(obuf + 2, msg[j].buf, msg[j].len); 596 dw210x_op_rw(d->udev, 0x80, 0, 0, 597 obuf, msg[j].len + 2, 598 DW210X_WRITE_MSG); 599 break; 600 } 601 break; 602 } 603 } 604 } 605 606 mutex_unlock(&d->i2c_mutex); 607 return num; 608 } 609 610 static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 611 int num) 612 { 613 struct dvb_usb_device *d = i2c_get_adapdata(adap); 614 u8 obuf[0x40], ibuf[0x40]; 615 616 if (!d) 617 return -ENODEV; 618 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 619 return -EAGAIN; 620 621 switch (num) { 622 case 1: 623 switch (msg[0].addr) { 624 case SU3000_STREAM_CTRL: 625 obuf[0] = msg[0].buf[0] + 0x36; 626 obuf[1] = 3; 627 obuf[2] = 0; 628 if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0) 629 err("i2c transfer failed."); 630 break; 631 case DW2102_RC_QUERY: 632 obuf[0] = 0x10; 633 if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0) 634 err("i2c transfer failed."); 635 msg[0].buf[1] = ibuf[0]; 636 msg[0].buf[0] = ibuf[1]; 637 break; 638 default: 639 /* always i2c write*/ 640 obuf[0] = 0x08; 641 obuf[1] = msg[0].addr; 642 obuf[2] = msg[0].len; 643 644 memcpy(&obuf[3], msg[0].buf, msg[0].len); 645 646 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3, 647 ibuf, 1, 0) < 0) 648 err("i2c transfer failed."); 649 650 } 651 break; 652 case 2: 653 /* always i2c read */ 654 obuf[0] = 0x09; 655 obuf[1] = msg[0].len; 656 obuf[2] = msg[1].len; 657 obuf[3] = msg[0].addr; 658 memcpy(&obuf[4], msg[0].buf, msg[0].len); 659 660 if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4, 661 ibuf, msg[1].len + 1, 0) < 0) 662 err("i2c transfer failed."); 663 664 memcpy(msg[1].buf, &ibuf[1], msg[1].len); 665 break; 666 default: 667 warn("more than 2 i2c messages at a time is not handled yet."); 668 break; 669 } 670 mutex_unlock(&d->i2c_mutex); 671 return num; 672 } 673 674 static u32 dw210x_i2c_func(struct i2c_adapter *adapter) 675 { 676 return I2C_FUNC_I2C; 677 } 678 679 static struct i2c_algorithm dw2102_i2c_algo = { 680 .master_xfer = dw2102_i2c_transfer, 681 .functionality = dw210x_i2c_func, 682 }; 683 684 static struct i2c_algorithm dw2102_serit_i2c_algo = { 685 .master_xfer = dw2102_serit_i2c_transfer, 686 .functionality = dw210x_i2c_func, 687 }; 688 689 static struct i2c_algorithm dw2102_earda_i2c_algo = { 690 .master_xfer = dw2102_earda_i2c_transfer, 691 .functionality = dw210x_i2c_func, 692 }; 693 694 static struct i2c_algorithm dw2104_i2c_algo = { 695 .master_xfer = dw2104_i2c_transfer, 696 .functionality = dw210x_i2c_func, 697 }; 698 699 static struct i2c_algorithm dw3101_i2c_algo = { 700 .master_xfer = dw3101_i2c_transfer, 701 .functionality = dw210x_i2c_func, 702 }; 703 704 static struct i2c_algorithm s6x0_i2c_algo = { 705 .master_xfer = s6x0_i2c_transfer, 706 .functionality = dw210x_i2c_func, 707 }; 708 709 static struct i2c_algorithm su3000_i2c_algo = { 710 .master_xfer = su3000_i2c_transfer, 711 .functionality = dw210x_i2c_func, 712 }; 713 714 static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 715 { 716 int i; 717 u8 ibuf[] = {0, 0}; 718 u8 eeprom[256], eepromline[16]; 719 720 for (i = 0; i < 256; i++) { 721 if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { 722 err("read eeprom failed."); 723 return -1; 724 } else { 725 eepromline[i%16] = ibuf[0]; 726 eeprom[i] = ibuf[0]; 727 } 728 if ((i % 16) == 15) { 729 deb_xfer("%02x: ", i - 15); 730 debug_dump(eepromline, 16, deb_xfer); 731 } 732 } 733 734 memcpy(mac, eeprom + 8, 6); 735 return 0; 736 }; 737 738 static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 739 { 740 int i, ret; 741 u8 ibuf[] = { 0 }, obuf[] = { 0 }; 742 u8 eeprom[256], eepromline[16]; 743 struct i2c_msg msg[] = { 744 { 745 .addr = 0xa0 >> 1, 746 .flags = 0, 747 .buf = obuf, 748 .len = 1, 749 }, { 750 .addr = 0xa0 >> 1, 751 .flags = I2C_M_RD, 752 .buf = ibuf, 753 .len = 1, 754 } 755 }; 756 757 for (i = 0; i < 256; i++) { 758 obuf[0] = i; 759 ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2); 760 if (ret != 2) { 761 err("read eeprom failed."); 762 return -1; 763 } else { 764 eepromline[i % 16] = ibuf[0]; 765 eeprom[i] = ibuf[0]; 766 } 767 768 if ((i % 16) == 15) { 769 deb_xfer("%02x: ", i - 15); 770 debug_dump(eepromline, 16, deb_xfer); 771 } 772 } 773 774 memcpy(mac, eeprom + 16, 6); 775 return 0; 776 }; 777 778 static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) 779 { 780 static u8 command_start[] = {0x00}; 781 static u8 command_stop[] = {0x01}; 782 struct i2c_msg msg = { 783 .addr = SU3000_STREAM_CTRL, 784 .flags = 0, 785 .buf = onoff ? command_start : command_stop, 786 .len = 1 787 }; 788 789 i2c_transfer(&adap->dev->i2c_adap, &msg, 1); 790 791 return 0; 792 } 793 794 static int su3000_power_ctrl(struct dvb_usb_device *d, int i) 795 { 796 struct su3000_state *state = (struct su3000_state *)d->priv; 797 u8 obuf[] = {0xde, 0}; 798 799 info("%s: %d, initialized %d\n", __func__, i, state->initialized); 800 801 if (i && !state->initialized) { 802 state->initialized = 1; 803 /* reset board */ 804 dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0); 805 } 806 807 return 0; 808 } 809 810 static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 811 { 812 int i; 813 u8 obuf[] = { 0x1f, 0xf0 }; 814 u8 ibuf[] = { 0 }; 815 struct i2c_msg msg[] = { 816 { 817 .addr = 0x51, 818 .flags = 0, 819 .buf = obuf, 820 .len = 2, 821 }, { 822 .addr = 0x51, 823 .flags = I2C_M_RD, 824 .buf = ibuf, 825 .len = 1, 826 827 } 828 }; 829 830 for (i = 0; i < 6; i++) { 831 obuf[1] = 0xf0 + i; 832 if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) 833 break; 834 else 835 mac[i] = ibuf[0]; 836 837 debug_dump(mac, 6, printk); 838 } 839 840 return 0; 841 } 842 843 static int su3000_identify_state(struct usb_device *udev, 844 struct dvb_usb_device_properties *props, 845 struct dvb_usb_device_description **desc, 846 int *cold) 847 { 848 info("%s\n", __func__); 849 850 *cold = 0; 851 return 0; 852 } 853 854 static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 855 { 856 static u8 command_13v[] = {0x00, 0x01}; 857 static u8 command_18v[] = {0x01, 0x01}; 858 static u8 command_off[] = {0x00, 0x00}; 859 struct i2c_msg msg = { 860 .addr = DW2102_VOLTAGE_CTRL, 861 .flags = 0, 862 .buf = command_off, 863 .len = 2, 864 }; 865 866 struct dvb_usb_adapter *udev_adap = 867 (struct dvb_usb_adapter *)(fe->dvb->priv); 868 if (voltage == SEC_VOLTAGE_18) 869 msg.buf = command_18v; 870 else if (voltage == SEC_VOLTAGE_13) 871 msg.buf = command_13v; 872 873 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 874 875 return 0; 876 } 877 878 static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 879 { 880 struct dvb_usb_adapter *d = 881 (struct dvb_usb_adapter *)(fe->dvb->priv); 882 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; 883 884 dw210x_set_voltage(fe, voltage); 885 if (st->old_set_voltage) 886 st->old_set_voltage(fe, voltage); 887 888 return 0; 889 } 890 891 static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon) 892 { 893 static u8 led_off[] = { 0 }; 894 static u8 led_on[] = { 1 }; 895 struct i2c_msg msg = { 896 .addr = DW2102_LED_CTRL, 897 .flags = 0, 898 .buf = led_off, 899 .len = 1 900 }; 901 struct dvb_usb_adapter *udev_adap = 902 (struct dvb_usb_adapter *)(fe->dvb->priv); 903 904 if (offon) 905 msg.buf = led_on; 906 i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 907 } 908 909 static struct stv0299_config sharp_z0194a_config = { 910 .demod_address = 0x68, 911 .inittab = sharp_z0194a_inittab, 912 .mclk = 88000000UL, 913 .invert = 1, 914 .skip_reinit = 0, 915 .lock_output = STV0299_LOCKOUTPUT_1, 916 .volt13_op0_op1 = STV0299_VOLT13_OP1, 917 .min_delay_ms = 100, 918 .set_symbol_rate = sharp_z0194a_set_symbol_rate, 919 }; 920 921 static struct cx24116_config dw2104_config = { 922 .demod_address = 0x55, 923 .mpg_clk_pos_pol = 0x01, 924 }; 925 926 static struct si21xx_config serit_sp1511lhb_config = { 927 .demod_address = 0x68, 928 .min_delay_ms = 100, 929 930 }; 931 932 static struct tda10023_config dw3101_tda10023_config = { 933 .demod_address = 0x0c, 934 .invert = 1, 935 }; 936 937 static struct mt312_config zl313_config = { 938 .demod_address = 0x0e, 939 }; 940 941 static struct ds3000_config dw2104_ds3000_config = { 942 .demod_address = 0x68, 943 }; 944 945 static struct ts2020_config dw2104_ts2020_config = { 946 .tuner_address = 0x60, 947 }; 948 949 static struct stv0900_config dw2104a_stv0900_config = { 950 .demod_address = 0x6a, 951 .demod_mode = 0, 952 .xtal = 27000000, 953 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 954 .diseqc_mode = 2,/* 2/3 PWM */ 955 .tun1_maddress = 0,/* 0x60 */ 956 .tun1_adc = 0,/* 2 Vpp */ 957 .path1_mode = 3, 958 }; 959 960 static struct stb6100_config dw2104a_stb6100_config = { 961 .tuner_address = 0x60, 962 .refclock = 27000000, 963 }; 964 965 static struct stv0900_config dw2104_stv0900_config = { 966 .demod_address = 0x68, 967 .demod_mode = 0, 968 .xtal = 8000000, 969 .clkmode = 3, 970 .diseqc_mode = 2, 971 .tun1_maddress = 0, 972 .tun1_adc = 1,/* 1 Vpp */ 973 .path1_mode = 3, 974 }; 975 976 static struct stv6110_config dw2104_stv6110_config = { 977 .i2c_address = 0x60, 978 .mclk = 16000000, 979 .clk_div = 1, 980 }; 981 982 static struct stv0900_config prof_7500_stv0900_config = { 983 .demod_address = 0x6a, 984 .demod_mode = 0, 985 .xtal = 27000000, 986 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 987 .diseqc_mode = 2,/* 2/3 PWM */ 988 .tun1_maddress = 0,/* 0x60 */ 989 .tun1_adc = 0,/* 2 Vpp */ 990 .path1_mode = 3, 991 .tun1_type = 3, 992 .set_lock_led = dw210x_led_ctrl, 993 }; 994 995 static struct ds3000_config su3000_ds3000_config = { 996 .demod_address = 0x68, 997 .ci_mode = 1, 998 }; 999 1000 static struct ts2020_config su3000_ts2020_config = { 1001 .tuner_address = 0x60, 1002 }; 1003 1004 static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 1005 { 1006 struct dvb_tuner_ops *tuner_ops = NULL; 1007 1008 if (demod_probe & 4) { 1009 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config, 1010 &d->dev->i2c_adap, 0); 1011 if (d->fe_adap[0].fe != NULL) { 1012 if (dvb_attach(stb6100_attach, d->fe_adap[0].fe, 1013 &dw2104a_stb6100_config, 1014 &d->dev->i2c_adap)) { 1015 tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops; 1016 tuner_ops->set_frequency = stb6100_set_freq; 1017 tuner_ops->get_frequency = stb6100_get_freq; 1018 tuner_ops->set_bandwidth = stb6100_set_bandw; 1019 tuner_ops->get_bandwidth = stb6100_get_bandw; 1020 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1021 info("Attached STV0900+STB6100!\n"); 1022 return 0; 1023 } 1024 } 1025 } 1026 1027 if (demod_probe & 2) { 1028 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config, 1029 &d->dev->i2c_adap, 0); 1030 if (d->fe_adap[0].fe != NULL) { 1031 if (dvb_attach(stv6110_attach, d->fe_adap[0].fe, 1032 &dw2104_stv6110_config, 1033 &d->dev->i2c_adap)) { 1034 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1035 info("Attached STV0900+STV6110A!\n"); 1036 return 0; 1037 } 1038 } 1039 } 1040 1041 if (demod_probe & 1) { 1042 d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config, 1043 &d->dev->i2c_adap); 1044 if (d->fe_adap[0].fe != NULL) { 1045 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1046 info("Attached cx24116!\n"); 1047 return 0; 1048 } 1049 } 1050 1051 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, 1052 &d->dev->i2c_adap); 1053 if (d->fe_adap[0].fe != NULL) { 1054 dvb_attach(ts2020_attach, d->fe_adap[0].fe, 1055 &dw2104_ts2020_config, &d->dev->i2c_adap); 1056 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1057 info("Attached DS3000!\n"); 1058 return 0; 1059 } 1060 1061 return -EIO; 1062 } 1063 1064 static struct dvb_usb_device_properties dw2102_properties; 1065 static struct dvb_usb_device_properties dw2104_properties; 1066 static struct dvb_usb_device_properties s6x0_properties; 1067 1068 static int dw2102_frontend_attach(struct dvb_usb_adapter *d) 1069 { 1070 if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) { 1071 /*dw2102_properties.adapter->tuner_attach = NULL;*/ 1072 d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config, 1073 &d->dev->i2c_adap); 1074 if (d->fe_adap[0].fe != NULL) { 1075 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1076 info("Attached si21xx!\n"); 1077 return 0; 1078 } 1079 } 1080 1081 if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) { 1082 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1083 &d->dev->i2c_adap); 1084 if (d->fe_adap[0].fe != NULL) { 1085 if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, 1086 &d->dev->i2c_adap)) { 1087 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1088 info("Attached stv0288!\n"); 1089 return 0; 1090 } 1091 } 1092 } 1093 1094 if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) { 1095 /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/ 1096 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config, 1097 &d->dev->i2c_adap); 1098 if (d->fe_adap[0].fe != NULL) { 1099 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1100 info("Attached stv0299!\n"); 1101 return 0; 1102 } 1103 } 1104 return -EIO; 1105 } 1106 1107 static int dw3101_frontend_attach(struct dvb_usb_adapter *d) 1108 { 1109 d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config, 1110 &d->dev->i2c_adap, 0x48); 1111 if (d->fe_adap[0].fe != NULL) { 1112 info("Attached tda10023!\n"); 1113 return 0; 1114 } 1115 return -EIO; 1116 } 1117 1118 static int zl100313_frontend_attach(struct dvb_usb_adapter *d) 1119 { 1120 d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config, 1121 &d->dev->i2c_adap); 1122 if (d->fe_adap[0].fe != NULL) { 1123 if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60, 1124 &d->dev->i2c_adap)) { 1125 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1126 info("Attached zl100313+zl10039!\n"); 1127 return 0; 1128 } 1129 } 1130 1131 return -EIO; 1132 } 1133 1134 static int stv0288_frontend_attach(struct dvb_usb_adapter *d) 1135 { 1136 u8 obuf[] = {7, 1}; 1137 1138 d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config, 1139 &d->dev->i2c_adap); 1140 1141 if (d->fe_adap[0].fe == NULL) 1142 return -EIO; 1143 1144 if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) 1145 return -EIO; 1146 1147 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1148 1149 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1150 1151 info("Attached stv0288+stb6000!\n"); 1152 1153 return 0; 1154 1155 } 1156 1157 static int ds3000_frontend_attach(struct dvb_usb_adapter *d) 1158 { 1159 struct s6x0_state *st = (struct s6x0_state *)d->dev->priv; 1160 u8 obuf[] = {7, 1}; 1161 1162 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config, 1163 &d->dev->i2c_adap); 1164 1165 if (d->fe_adap[0].fe == NULL) 1166 return -EIO; 1167 1168 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &dw2104_ts2020_config, 1169 &d->dev->i2c_adap); 1170 1171 st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage; 1172 d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage; 1173 1174 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1175 1176 info("Attached ds3000+ds2020!\n"); 1177 1178 return 0; 1179 } 1180 1181 static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) 1182 { 1183 u8 obuf[] = {7, 1}; 1184 1185 d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, 1186 &d->dev->i2c_adap, 0); 1187 if (d->fe_adap[0].fe == NULL) 1188 return -EIO; 1189 1190 d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; 1191 1192 dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG); 1193 1194 info("Attached STV0900+STB6100A!\n"); 1195 1196 return 0; 1197 } 1198 1199 static int su3000_frontend_attach(struct dvb_usb_adapter *d) 1200 { 1201 u8 obuf[3] = { 0xe, 0x80, 0 }; 1202 u8 ibuf[] = { 0 }; 1203 1204 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1205 err("command 0x0e transfer failed."); 1206 1207 obuf[0] = 0xe; 1208 obuf[1] = 0x83; 1209 obuf[2] = 0; 1210 1211 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1212 err("command 0x0e transfer failed."); 1213 1214 obuf[0] = 0xe; 1215 obuf[1] = 0x83; 1216 obuf[2] = 1; 1217 1218 if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0) 1219 err("command 0x0e transfer failed."); 1220 1221 obuf[0] = 0x51; 1222 1223 if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0) 1224 err("command 0x51 transfer failed."); 1225 1226 d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config, 1227 &d->dev->i2c_adap); 1228 if (d->fe_adap[0].fe == NULL) 1229 return -EIO; 1230 1231 dvb_attach(ts2020_attach, d->fe_adap[0].fe, &su3000_ts2020_config, 1232 &d->dev->i2c_adap); 1233 1234 info("Attached DS3000!\n"); 1235 1236 return 0; 1237 } 1238 1239 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) 1240 { 1241 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1242 &adap->dev->i2c_adap, DVB_PLL_OPERA1); 1243 return 0; 1244 } 1245 1246 static int dw3101_tuner_attach(struct dvb_usb_adapter *adap) 1247 { 1248 dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, 1249 &adap->dev->i2c_adap, DVB_PLL_TUA6034); 1250 1251 return 0; 1252 } 1253 1254 static struct rc_map_table rc_map_dw210x_table[] = { 1255 { 0xf80a, KEY_POWER2 }, /*power*/ 1256 { 0xf80c, KEY_MUTE }, /*mute*/ 1257 { 0xf811, KEY_1 }, 1258 { 0xf812, KEY_2 }, 1259 { 0xf813, KEY_3 }, 1260 { 0xf814, KEY_4 }, 1261 { 0xf815, KEY_5 }, 1262 { 0xf816, KEY_6 }, 1263 { 0xf817, KEY_7 }, 1264 { 0xf818, KEY_8 }, 1265 { 0xf819, KEY_9 }, 1266 { 0xf810, KEY_0 }, 1267 { 0xf81c, KEY_CHANNELUP }, /*ch+*/ 1268 { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/ 1269 { 0xf81a, KEY_VOLUMEUP }, /*vol+*/ 1270 { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/ 1271 { 0xf804, KEY_RECORD }, /*rec*/ 1272 { 0xf809, KEY_FAVORITES }, /*fav*/ 1273 { 0xf808, KEY_REWIND }, /*rewind*/ 1274 { 0xf807, KEY_FASTFORWARD }, /*fast*/ 1275 { 0xf80b, KEY_PAUSE }, /*pause*/ 1276 { 0xf802, KEY_ESC }, /*cancel*/ 1277 { 0xf803, KEY_TAB }, /*tab*/ 1278 { 0xf800, KEY_UP }, /*up*/ 1279 { 0xf81f, KEY_OK }, /*ok*/ 1280 { 0xf801, KEY_DOWN }, /*down*/ 1281 { 0xf805, KEY_CAMERA }, /*cap*/ 1282 { 0xf806, KEY_STOP }, /*stop*/ 1283 { 0xf840, KEY_ZOOM }, /*full*/ 1284 { 0xf81e, KEY_TV }, /*tvmode*/ 1285 { 0xf81b, KEY_LAST }, /*recall*/ 1286 }; 1287 1288 static struct rc_map_table rc_map_tevii_table[] = { 1289 { 0xf80a, KEY_POWER }, 1290 { 0xf80c, KEY_MUTE }, 1291 { 0xf811, KEY_1 }, 1292 { 0xf812, KEY_2 }, 1293 { 0xf813, KEY_3 }, 1294 { 0xf814, KEY_4 }, 1295 { 0xf815, KEY_5 }, 1296 { 0xf816, KEY_6 }, 1297 { 0xf817, KEY_7 }, 1298 { 0xf818, KEY_8 }, 1299 { 0xf819, KEY_9 }, 1300 { 0xf810, KEY_0 }, 1301 { 0xf81c, KEY_MENU }, 1302 { 0xf80f, KEY_VOLUMEDOWN }, 1303 { 0xf81a, KEY_LAST }, 1304 { 0xf80e, KEY_OPEN }, 1305 { 0xf804, KEY_RECORD }, 1306 { 0xf809, KEY_VOLUMEUP }, 1307 { 0xf808, KEY_CHANNELUP }, 1308 { 0xf807, KEY_PVR }, 1309 { 0xf80b, KEY_TIME }, 1310 { 0xf802, KEY_RIGHT }, 1311 { 0xf803, KEY_LEFT }, 1312 { 0xf800, KEY_UP }, 1313 { 0xf81f, KEY_OK }, 1314 { 0xf801, KEY_DOWN }, 1315 { 0xf805, KEY_TUNER }, 1316 { 0xf806, KEY_CHANNELDOWN }, 1317 { 0xf840, KEY_PLAYPAUSE }, 1318 { 0xf81e, KEY_REWIND }, 1319 { 0xf81b, KEY_FAVORITES }, 1320 { 0xf81d, KEY_BACK }, 1321 { 0xf84d, KEY_FASTFORWARD }, 1322 { 0xf844, KEY_EPG }, 1323 { 0xf84c, KEY_INFO }, 1324 { 0xf841, KEY_AB }, 1325 { 0xf843, KEY_AUDIO }, 1326 { 0xf845, KEY_SUBTITLE }, 1327 { 0xf84a, KEY_LIST }, 1328 { 0xf846, KEY_F1 }, 1329 { 0xf847, KEY_F2 }, 1330 { 0xf85e, KEY_F3 }, 1331 { 0xf85c, KEY_F4 }, 1332 { 0xf852, KEY_F5 }, 1333 { 0xf85a, KEY_F6 }, 1334 { 0xf856, KEY_MODE }, 1335 { 0xf858, KEY_SWITCHVIDEOMODE }, 1336 }; 1337 1338 static struct rc_map_table rc_map_tbs_table[] = { 1339 { 0xf884, KEY_POWER }, 1340 { 0xf894, KEY_MUTE }, 1341 { 0xf887, KEY_1 }, 1342 { 0xf886, KEY_2 }, 1343 { 0xf885, KEY_3 }, 1344 { 0xf88b, KEY_4 }, 1345 { 0xf88a, KEY_5 }, 1346 { 0xf889, KEY_6 }, 1347 { 0xf88f, KEY_7 }, 1348 { 0xf88e, KEY_8 }, 1349 { 0xf88d, KEY_9 }, 1350 { 0xf892, KEY_0 }, 1351 { 0xf896, KEY_CHANNELUP }, 1352 { 0xf891, KEY_CHANNELDOWN }, 1353 { 0xf893, KEY_VOLUMEUP }, 1354 { 0xf88c, KEY_VOLUMEDOWN }, 1355 { 0xf883, KEY_RECORD }, 1356 { 0xf898, KEY_PAUSE }, 1357 { 0xf899, KEY_OK }, 1358 { 0xf89a, KEY_SHUFFLE }, 1359 { 0xf881, KEY_UP }, 1360 { 0xf890, KEY_LEFT }, 1361 { 0xf882, KEY_RIGHT }, 1362 { 0xf888, KEY_DOWN }, 1363 { 0xf895, KEY_FAVORITES }, 1364 { 0xf897, KEY_SUBTITLE }, 1365 { 0xf89d, KEY_ZOOM }, 1366 { 0xf89f, KEY_EXIT }, 1367 { 0xf89e, KEY_MENU }, 1368 { 0xf89c, KEY_EPG }, 1369 { 0xf880, KEY_PREVIOUS }, 1370 { 0xf89b, KEY_MODE } 1371 }; 1372 1373 static struct rc_map_table rc_map_su3000_table[] = { 1374 { 0x25, KEY_POWER }, /* right-bottom Red */ 1375 { 0x0a, KEY_MUTE }, /* -/-- */ 1376 { 0x01, KEY_1 }, 1377 { 0x02, KEY_2 }, 1378 { 0x03, KEY_3 }, 1379 { 0x04, KEY_4 }, 1380 { 0x05, KEY_5 }, 1381 { 0x06, KEY_6 }, 1382 { 0x07, KEY_7 }, 1383 { 0x08, KEY_8 }, 1384 { 0x09, KEY_9 }, 1385 { 0x00, KEY_0 }, 1386 { 0x20, KEY_UP }, /* CH+ */ 1387 { 0x21, KEY_DOWN }, /* CH+ */ 1388 { 0x12, KEY_VOLUMEUP }, /* Brightness Up */ 1389 { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */ 1390 { 0x1f, KEY_RECORD }, 1391 { 0x17, KEY_PLAY }, 1392 { 0x16, KEY_PAUSE }, 1393 { 0x0b, KEY_STOP }, 1394 { 0x27, KEY_FASTFORWARD },/* >> */ 1395 { 0x26, KEY_REWIND }, /* << */ 1396 { 0x0d, KEY_OK }, /* Mute */ 1397 { 0x11, KEY_LEFT }, /* VOL- */ 1398 { 0x10, KEY_RIGHT }, /* VOL+ */ 1399 { 0x29, KEY_BACK }, /* button under 9 */ 1400 { 0x2c, KEY_MENU }, /* TTX */ 1401 { 0x2b, KEY_EPG }, /* EPG */ 1402 { 0x1e, KEY_RED }, /* OSD */ 1403 { 0x0e, KEY_GREEN }, /* Window */ 1404 { 0x2d, KEY_YELLOW }, /* button under << */ 1405 { 0x0f, KEY_BLUE }, /* bottom yellow button */ 1406 { 0x14, KEY_AUDIO }, /* Snapshot */ 1407 { 0x38, KEY_TV }, /* TV/Radio */ 1408 { 0x0c, KEY_ESC } /* upper Red button */ 1409 }; 1410 1411 static struct rc_map_dvb_usb_table_table keys_tables[] = { 1412 { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) }, 1413 { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) }, 1414 { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) }, 1415 { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) }, 1416 }; 1417 1418 static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 1419 { 1420 struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; 1421 int keymap_size = d->props.rc.legacy.rc_map_size; 1422 u8 key[2]; 1423 struct i2c_msg msg = { 1424 .addr = DW2102_RC_QUERY, 1425 .flags = I2C_M_RD, 1426 .buf = key, 1427 .len = 2 1428 }; 1429 int i; 1430 /* override keymap */ 1431 if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) { 1432 keymap = keys_tables[ir_keymap - 1].rc_keys ; 1433 keymap_size = keys_tables[ir_keymap - 1].rc_keys_size; 1434 } else if (ir_keymap > ARRAY_SIZE(keys_tables)) 1435 return 0; /* none */ 1436 1437 *state = REMOTE_NO_KEY_PRESSED; 1438 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) { 1439 for (i = 0; i < keymap_size ; i++) { 1440 if (rc5_data(&keymap[i]) == msg.buf[0]) { 1441 *state = REMOTE_KEY_PRESSED; 1442 *event = keymap[i].keycode; 1443 break; 1444 } 1445 1446 } 1447 1448 if ((*state) == REMOTE_KEY_PRESSED) 1449 deb_rc("%s: found rc key: %x, %x, event: %x\n", 1450 __func__, key[0], key[1], (*event)); 1451 else if (key[0] != 0xff) 1452 deb_rc("%s: unknown rc key: %x, %x\n", 1453 __func__, key[0], key[1]); 1454 1455 } 1456 1457 return 0; 1458 } 1459 1460 enum dw2102_table_entry { 1461 CYPRESS_DW2102, 1462 CYPRESS_DW2101, 1463 CYPRESS_DW2104, 1464 TEVII_S650, 1465 TERRATEC_CINERGY_S, 1466 CYPRESS_DW3101, 1467 TEVII_S630, 1468 PROF_1100, 1469 TEVII_S660, 1470 PROF_7500, 1471 GENIATECH_SU3000, 1472 TERRATEC_CINERGY_S2, 1473 TEVII_S480_1, 1474 TEVII_S480_2, 1475 X3M_SPC1400HD, 1476 }; 1477 1478 static struct usb_device_id dw2102_table[] = { 1479 [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)}, 1480 [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)}, 1481 [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)}, 1482 [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, 1483 [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)}, 1484 [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, 1485 [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, 1486 [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, 1487 [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, 1488 [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)}, 1489 [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)}, 1490 [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)}, 1491 [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)}, 1492 [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)}, 1493 [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)}, 1494 { } 1495 }; 1496 1497 MODULE_DEVICE_TABLE(usb, dw2102_table); 1498 1499 static int dw2102_load_firmware(struct usb_device *dev, 1500 const struct firmware *frmwr) 1501 { 1502 u8 *b, *p; 1503 int ret = 0, i; 1504 u8 reset; 1505 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; 1506 const struct firmware *fw; 1507 1508 switch (dev->descriptor.idProduct) { 1509 case 0x2101: 1510 ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev); 1511 if (ret != 0) { 1512 err(err_str, DW2101_FIRMWARE); 1513 return ret; 1514 } 1515 break; 1516 default: 1517 fw = frmwr; 1518 break; 1519 } 1520 info("start downloading DW210X firmware"); 1521 p = kmalloc(fw->size, GFP_KERNEL); 1522 reset = 1; 1523 /*stop the CPU*/ 1524 dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG); 1525 dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG); 1526 1527 if (p != NULL) { 1528 memcpy(p, fw->data, fw->size); 1529 for (i = 0; i < fw->size; i += 0x40) { 1530 b = (u8 *) p + i; 1531 if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, 1532 DW210X_WRITE_MSG) != 0x40) { 1533 err("error while transferring firmware"); 1534 ret = -EINVAL; 1535 break; 1536 } 1537 } 1538 /* restart the CPU */ 1539 reset = 0; 1540 if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, 1541 DW210X_WRITE_MSG) != 1) { 1542 err("could not restart the USB controller CPU."); 1543 ret = -EINVAL; 1544 } 1545 if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, 1546 DW210X_WRITE_MSG) != 1) { 1547 err("could not restart the USB controller CPU."); 1548 ret = -EINVAL; 1549 } 1550 /* init registers */ 1551 switch (dev->descriptor.idProduct) { 1552 case USB_PID_TEVII_S650: 1553 dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table; 1554 dw2104_properties.rc.legacy.rc_map_size = 1555 ARRAY_SIZE(rc_map_tevii_table); 1556 case USB_PID_DW2104: 1557 reset = 1; 1558 dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1, 1559 DW210X_WRITE_MSG); 1560 /* break omitted intentionally */ 1561 case USB_PID_DW3101: 1562 reset = 0; 1563 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1564 DW210X_WRITE_MSG); 1565 break; 1566 case USB_PID_CINERGY_S: 1567 case USB_PID_DW2102: 1568 dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0, 1569 DW210X_WRITE_MSG); 1570 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1571 DW210X_READ_MSG); 1572 /* check STV0299 frontend */ 1573 dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2, 1574 DW210X_READ_MSG); 1575 if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) { 1576 dw2102_properties.i2c_algo = &dw2102_i2c_algo; 1577 dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; 1578 break; 1579 } else { 1580 /* check STV0288 frontend */ 1581 reset16[0] = 0xd0; 1582 reset16[1] = 1; 1583 reset16[2] = 0; 1584 dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, 1585 DW210X_WRITE_MSG); 1586 dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, 1587 DW210X_READ_MSG); 1588 if (reset16[2] == 0x11) { 1589 dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; 1590 break; 1591 } 1592 } 1593 case 0x2101: 1594 dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2, 1595 DW210X_READ_MSG); 1596 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1597 DW210X_READ_MSG); 1598 dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7, 1599 DW210X_READ_MSG); 1600 dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2, 1601 DW210X_READ_MSG); 1602 break; 1603 } 1604 1605 msleep(100); 1606 kfree(p); 1607 } 1608 return ret; 1609 } 1610 1611 static struct dvb_usb_device_properties dw2102_properties = { 1612 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1613 .usb_ctrl = DEVICE_SPECIFIC, 1614 .firmware = DW2102_FIRMWARE, 1615 .no_reconnect = 1, 1616 1617 .i2c_algo = &dw2102_serit_i2c_algo, 1618 1619 .rc.legacy = { 1620 .rc_map_table = rc_map_dw210x_table, 1621 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), 1622 .rc_interval = 150, 1623 .rc_query = dw2102_rc_query, 1624 }, 1625 1626 .generic_bulk_ctrl_endpoint = 0x81, 1627 /* parameter for the MPEG2-data transfer */ 1628 .num_adapters = 1, 1629 .download_firmware = dw2102_load_firmware, 1630 .read_mac_address = dw210x_read_mac_address, 1631 .adapter = { 1632 { 1633 .num_frontends = 1, 1634 .fe = {{ 1635 .frontend_attach = dw2102_frontend_attach, 1636 .stream = { 1637 .type = USB_BULK, 1638 .count = 8, 1639 .endpoint = 0x82, 1640 .u = { 1641 .bulk = { 1642 .buffersize = 4096, 1643 } 1644 } 1645 }, 1646 }}, 1647 } 1648 }, 1649 .num_device_descs = 3, 1650 .devices = { 1651 {"DVBWorld DVB-S 2102 USB2.0", 1652 {&dw2102_table[CYPRESS_DW2102], NULL}, 1653 {NULL}, 1654 }, 1655 {"DVBWorld DVB-S 2101 USB2.0", 1656 {&dw2102_table[CYPRESS_DW2101], NULL}, 1657 {NULL}, 1658 }, 1659 {"TerraTec Cinergy S USB", 1660 {&dw2102_table[TERRATEC_CINERGY_S], NULL}, 1661 {NULL}, 1662 }, 1663 } 1664 }; 1665 1666 static struct dvb_usb_device_properties dw2104_properties = { 1667 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1668 .usb_ctrl = DEVICE_SPECIFIC, 1669 .firmware = DW2104_FIRMWARE, 1670 .no_reconnect = 1, 1671 1672 .i2c_algo = &dw2104_i2c_algo, 1673 .rc.legacy = { 1674 .rc_map_table = rc_map_dw210x_table, 1675 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), 1676 .rc_interval = 150, 1677 .rc_query = dw2102_rc_query, 1678 }, 1679 1680 .generic_bulk_ctrl_endpoint = 0x81, 1681 /* parameter for the MPEG2-data transfer */ 1682 .num_adapters = 1, 1683 .download_firmware = dw2102_load_firmware, 1684 .read_mac_address = dw210x_read_mac_address, 1685 .adapter = { 1686 { 1687 .num_frontends = 1, 1688 .fe = {{ 1689 .frontend_attach = dw2104_frontend_attach, 1690 .stream = { 1691 .type = USB_BULK, 1692 .count = 8, 1693 .endpoint = 0x82, 1694 .u = { 1695 .bulk = { 1696 .buffersize = 4096, 1697 } 1698 } 1699 }, 1700 }}, 1701 } 1702 }, 1703 .num_device_descs = 2, 1704 .devices = { 1705 { "DVBWorld DW2104 USB2.0", 1706 {&dw2102_table[CYPRESS_DW2104], NULL}, 1707 {NULL}, 1708 }, 1709 { "TeVii S650 USB2.0", 1710 {&dw2102_table[TEVII_S650], NULL}, 1711 {NULL}, 1712 }, 1713 } 1714 }; 1715 1716 static struct dvb_usb_device_properties dw3101_properties = { 1717 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1718 .usb_ctrl = DEVICE_SPECIFIC, 1719 .firmware = DW3101_FIRMWARE, 1720 .no_reconnect = 1, 1721 1722 .i2c_algo = &dw3101_i2c_algo, 1723 .rc.legacy = { 1724 .rc_map_table = rc_map_dw210x_table, 1725 .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table), 1726 .rc_interval = 150, 1727 .rc_query = dw2102_rc_query, 1728 }, 1729 1730 .generic_bulk_ctrl_endpoint = 0x81, 1731 /* parameter for the MPEG2-data transfer */ 1732 .num_adapters = 1, 1733 .download_firmware = dw2102_load_firmware, 1734 .read_mac_address = dw210x_read_mac_address, 1735 .adapter = { 1736 { 1737 .num_frontends = 1, 1738 .fe = {{ 1739 .frontend_attach = dw3101_frontend_attach, 1740 .tuner_attach = dw3101_tuner_attach, 1741 .stream = { 1742 .type = USB_BULK, 1743 .count = 8, 1744 .endpoint = 0x82, 1745 .u = { 1746 .bulk = { 1747 .buffersize = 4096, 1748 } 1749 } 1750 }, 1751 }}, 1752 } 1753 }, 1754 .num_device_descs = 1, 1755 .devices = { 1756 { "DVBWorld DVB-C 3101 USB2.0", 1757 {&dw2102_table[CYPRESS_DW3101], NULL}, 1758 {NULL}, 1759 }, 1760 } 1761 }; 1762 1763 static struct dvb_usb_device_properties s6x0_properties = { 1764 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1765 .usb_ctrl = DEVICE_SPECIFIC, 1766 .size_of_priv = sizeof(struct s6x0_state), 1767 .firmware = S630_FIRMWARE, 1768 .no_reconnect = 1, 1769 1770 .i2c_algo = &s6x0_i2c_algo, 1771 .rc.legacy = { 1772 .rc_map_table = rc_map_tevii_table, 1773 .rc_map_size = ARRAY_SIZE(rc_map_tevii_table), 1774 .rc_interval = 150, 1775 .rc_query = dw2102_rc_query, 1776 }, 1777 1778 .generic_bulk_ctrl_endpoint = 0x81, 1779 .num_adapters = 1, 1780 .download_firmware = dw2102_load_firmware, 1781 .read_mac_address = s6x0_read_mac_address, 1782 .adapter = { 1783 { 1784 .num_frontends = 1, 1785 .fe = {{ 1786 .frontend_attach = zl100313_frontend_attach, 1787 .stream = { 1788 .type = USB_BULK, 1789 .count = 8, 1790 .endpoint = 0x82, 1791 .u = { 1792 .bulk = { 1793 .buffersize = 4096, 1794 } 1795 } 1796 }, 1797 }}, 1798 } 1799 }, 1800 .num_device_descs = 1, 1801 .devices = { 1802 {"TeVii S630 USB", 1803 {&dw2102_table[TEVII_S630], NULL}, 1804 {NULL}, 1805 }, 1806 } 1807 }; 1808 1809 struct dvb_usb_device_properties *p1100; 1810 static struct dvb_usb_device_description d1100 = { 1811 "Prof 1100 USB ", 1812 {&dw2102_table[PROF_1100], NULL}, 1813 {NULL}, 1814 }; 1815 1816 struct dvb_usb_device_properties *s660; 1817 static struct dvb_usb_device_description d660 = { 1818 "TeVii S660 USB", 1819 {&dw2102_table[TEVII_S660], NULL}, 1820 {NULL}, 1821 }; 1822 1823 static struct dvb_usb_device_description d480_1 = { 1824 "TeVii S480.1 USB", 1825 {&dw2102_table[TEVII_S480_1], NULL}, 1826 {NULL}, 1827 }; 1828 1829 static struct dvb_usb_device_description d480_2 = { 1830 "TeVii S480.2 USB", 1831 {&dw2102_table[TEVII_S480_2], NULL}, 1832 {NULL}, 1833 }; 1834 1835 struct dvb_usb_device_properties *p7500; 1836 static struct dvb_usb_device_description d7500 = { 1837 "Prof 7500 USB DVB-S2", 1838 {&dw2102_table[PROF_7500], NULL}, 1839 {NULL}, 1840 }; 1841 1842 static struct dvb_usb_device_properties su3000_properties = { 1843 .caps = DVB_USB_IS_AN_I2C_ADAPTER, 1844 .usb_ctrl = DEVICE_SPECIFIC, 1845 .size_of_priv = sizeof(struct su3000_state), 1846 .power_ctrl = su3000_power_ctrl, 1847 .num_adapters = 1, 1848 .identify_state = su3000_identify_state, 1849 .i2c_algo = &su3000_i2c_algo, 1850 1851 .rc.legacy = { 1852 .rc_map_table = rc_map_su3000_table, 1853 .rc_map_size = ARRAY_SIZE(rc_map_su3000_table), 1854 .rc_interval = 150, 1855 .rc_query = dw2102_rc_query, 1856 }, 1857 1858 .read_mac_address = su3000_read_mac_address, 1859 1860 .generic_bulk_ctrl_endpoint = 0x01, 1861 1862 .adapter = { 1863 { 1864 .num_frontends = 1, 1865 .fe = {{ 1866 .streaming_ctrl = su3000_streaming_ctrl, 1867 .frontend_attach = su3000_frontend_attach, 1868 .stream = { 1869 .type = USB_BULK, 1870 .count = 8, 1871 .endpoint = 0x82, 1872 .u = { 1873 .bulk = { 1874 .buffersize = 4096, 1875 } 1876 } 1877 } 1878 }}, 1879 } 1880 }, 1881 .num_device_descs = 3, 1882 .devices = { 1883 { "SU3000HD DVB-S USB2.0", 1884 { &dw2102_table[GENIATECH_SU3000], NULL }, 1885 { NULL }, 1886 }, 1887 { "Terratec Cinergy S2 USB HD", 1888 { &dw2102_table[TERRATEC_CINERGY_S2], NULL }, 1889 { NULL }, 1890 }, 1891 { "X3M TV SPC1400HD PCI", 1892 { &dw2102_table[X3M_SPC1400HD], NULL }, 1893 { NULL }, 1894 }, 1895 } 1896 }; 1897 1898 static int dw2102_probe(struct usb_interface *intf, 1899 const struct usb_device_id *id) 1900 { 1901 p1100 = kmemdup(&s6x0_properties, 1902 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1903 if (!p1100) 1904 return -ENOMEM; 1905 /* copy default structure */ 1906 /* fill only different fields */ 1907 p1100->firmware = P1100_FIRMWARE; 1908 p1100->devices[0] = d1100; 1909 p1100->rc.legacy.rc_map_table = rc_map_tbs_table; 1910 p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); 1911 p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach; 1912 1913 s660 = kmemdup(&s6x0_properties, 1914 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1915 if (!s660) { 1916 kfree(p1100); 1917 return -ENOMEM; 1918 } 1919 s660->firmware = S660_FIRMWARE; 1920 s660->num_device_descs = 3; 1921 s660->devices[0] = d660; 1922 s660->devices[1] = d480_1; 1923 s660->devices[2] = d480_2; 1924 s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach; 1925 1926 p7500 = kmemdup(&s6x0_properties, 1927 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1928 if (!p7500) { 1929 kfree(p1100); 1930 kfree(s660); 1931 return -ENOMEM; 1932 } 1933 p7500->firmware = P7500_FIRMWARE; 1934 p7500->devices[0] = d7500; 1935 p7500->rc.legacy.rc_map_table = rc_map_tbs_table; 1936 p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table); 1937 p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach; 1938 1939 if (0 == dvb_usb_device_init(intf, &dw2102_properties, 1940 THIS_MODULE, NULL, adapter_nr) || 1941 0 == dvb_usb_device_init(intf, &dw2104_properties, 1942 THIS_MODULE, NULL, adapter_nr) || 1943 0 == dvb_usb_device_init(intf, &dw3101_properties, 1944 THIS_MODULE, NULL, adapter_nr) || 1945 0 == dvb_usb_device_init(intf, &s6x0_properties, 1946 THIS_MODULE, NULL, adapter_nr) || 1947 0 == dvb_usb_device_init(intf, p1100, 1948 THIS_MODULE, NULL, adapter_nr) || 1949 0 == dvb_usb_device_init(intf, s660, 1950 THIS_MODULE, NULL, adapter_nr) || 1951 0 == dvb_usb_device_init(intf, p7500, 1952 THIS_MODULE, NULL, adapter_nr) || 1953 0 == dvb_usb_device_init(intf, &su3000_properties, 1954 THIS_MODULE, NULL, adapter_nr)) 1955 return 0; 1956 1957 return -ENODEV; 1958 } 1959 1960 static struct usb_driver dw2102_driver = { 1961 .name = "dw2102", 1962 .probe = dw2102_probe, 1963 .disconnect = dvb_usb_device_exit, 1964 .id_table = dw2102_table, 1965 }; 1966 1967 module_usb_driver(dw2102_driver); 1968 1969 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 1970 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 1971 " DVB-C 3101 USB2.0," 1972 " TeVii S600, S630, S650, S660, S480," 1973 " Prof 1100, 7500 USB2.0," 1974 " Geniatech SU3000 devices"); 1975 MODULE_VERSION("0.1"); 1976 MODULE_LICENSE("GPL"); 1977 MODULE_FIRMWARE(DW2101_FIRMWARE); 1978 MODULE_FIRMWARE(DW2102_FIRMWARE); 1979 MODULE_FIRMWARE(DW2104_FIRMWARE); 1980 MODULE_FIRMWARE(DW3101_FIRMWARE); 1981 MODULE_FIRMWARE(S630_FIRMWARE); 1982 MODULE_FIRMWARE(S660_FIRMWARE); 1983 MODULE_FIRMWARE(P1100_FIRMWARE); 1984 MODULE_FIRMWARE(P7500_FIRMWARE); 1985