1 /* Linux driver for devices based on the DiBcom DiB0700 USB bridge 2 * 3 * This program is free software; you can redistribute it and/or modify it 4 * under the terms of the GNU General Public License as published by the Free 5 * Software Foundation, version 2. 6 * 7 * Copyright (C) 2005-9 DiBcom, SA et al 8 */ 9 #include "dib0700.h" 10 11 #include "dib3000mc.h" 12 #include "dib7000m.h" 13 #include "dib7000p.h" 14 #include "dib8000.h" 15 #include "dib9000.h" 16 #include "mt2060.h" 17 #include "mt2266.h" 18 #include "tuner-xc2028.h" 19 #include "xc5000.h" 20 #include "xc4000.h" 21 #include "s5h1411.h" 22 #include "dib0070.h" 23 #include "dib0090.h" 24 #include "lgdt3305.h" 25 #include "mxl5007t.h" 26 #include "mn88472.h" 27 #include "tda18250.h" 28 29 30 static int force_lna_activation; 31 module_param(force_lna_activation, int, 0644); 32 MODULE_PARM_DESC(force_lna_activation, "force the activation of Low-Noise-Amplifyer(s) (LNA), if applicable for the device (default: 0=automatic/off)."); 33 34 struct dib0700_adapter_state { 35 int (*set_param_save) (struct dvb_frontend *); 36 const struct firmware *frontend_firmware; 37 struct dib7000p_ops dib7000p_ops; 38 struct dib8000_ops dib8000_ops; 39 }; 40 41 /* Hauppauge Nova-T 500 (aka Bristol) 42 * has a LNA on GPIO0 which is enabled by setting 1 */ 43 static struct mt2060_config bristol_mt2060_config[2] = { 44 { 45 .i2c_address = 0x60, 46 .clock_out = 3, 47 }, { 48 .i2c_address = 0x61, 49 } 50 }; 51 52 53 static struct dibx000_agc_config bristol_dib3000p_mt2060_agc_config = { 54 .band_caps = BAND_VHF | BAND_UHF, 55 .setup = (1 << 8) | (5 << 5) | (0 << 4) | (0 << 3) | (0 << 2) | (2 << 0), 56 57 .agc1_max = 42598, 58 .agc1_min = 17694, 59 .agc2_max = 45875, 60 .agc2_min = 0, 61 62 .agc1_pt1 = 0, 63 .agc1_pt2 = 59, 64 65 .agc1_slope1 = 0, 66 .agc1_slope2 = 69, 67 68 .agc2_pt1 = 0, 69 .agc2_pt2 = 59, 70 71 .agc2_slope1 = 111, 72 .agc2_slope2 = 28, 73 }; 74 75 static struct dib3000mc_config bristol_dib3000mc_config[2] = { 76 { .agc = &bristol_dib3000p_mt2060_agc_config, 77 .max_time = 0x196, 78 .ln_adc_level = 0x1cc7, 79 .output_mpeg2_in_188_bytes = 1, 80 }, 81 { .agc = &bristol_dib3000p_mt2060_agc_config, 82 .max_time = 0x196, 83 .ln_adc_level = 0x1cc7, 84 .output_mpeg2_in_188_bytes = 1, 85 } 86 }; 87 88 static int bristol_frontend_attach(struct dvb_usb_adapter *adap) 89 { 90 struct dib0700_state *st = adap->dev->priv; 91 if (adap->id == 0) { 92 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10); 93 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10); 94 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10); 95 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(10); 96 97 if (force_lna_activation) 98 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 99 else 100 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0); 101 102 if (dib3000mc_i2c_enumeration(&adap->dev->i2c_adap, 2, DEFAULT_DIB3000P_I2C_ADDRESS, bristol_dib3000mc_config) != 0) { 103 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(10); 104 return -ENODEV; 105 } 106 } 107 st->mt2060_if1[adap->id] = 1220; 108 return (adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap, 109 (10 + adap->id) << 1, &bristol_dib3000mc_config[adap->id])) == NULL ? -ENODEV : 0; 110 } 111 112 static int eeprom_read(struct i2c_adapter *adap,u8 adrs,u8 *pval) 113 { 114 struct i2c_msg msg[2] = { 115 { .addr = 0x50, .flags = 0, .buf = &adrs, .len = 1 }, 116 { .addr = 0x50, .flags = I2C_M_RD, .buf = pval, .len = 1 }, 117 }; 118 if (i2c_transfer(adap, msg, 2) != 2) return -EREMOTEIO; 119 return 0; 120 } 121 122 static int bristol_tuner_attach(struct dvb_usb_adapter *adap) 123 { 124 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap; 125 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1); 126 s8 a; 127 int if1=1220; 128 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) && 129 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) { 130 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a; 131 } 132 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, 133 &bristol_mt2060_config[adap->id], if1) == NULL ? 134 -ENODEV : 0; 135 } 136 137 /* STK7700D: Pinnacle/Terratec/Hauppauge Dual DVB-T Diversity */ 138 139 /* MT226x */ 140 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = { 141 { 142 BAND_UHF, 143 144 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1, 145 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */ 146 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) 147 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 148 149 1130, 150 21, 151 152 0, 153 118, 154 155 0, 156 3530, 157 1, 158 0, 159 160 65535, 161 33770, 162 65535, 163 23592, 164 165 0, 166 62, 167 255, 168 64, 169 64, 170 132, 171 192, 172 80, 173 80, 174 175 17, 176 27, 177 23, 178 51, 179 180 1, 181 }, { 182 BAND_VHF | BAND_LBAND, 183 184 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1, 185 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */ 186 (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) 187 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), 188 189 2372, 190 21, 191 192 0, 193 118, 194 195 0, 196 3530, 197 1, 198 0, 199 200 65535, 201 0, 202 65535, 203 23592, 204 205 0, 206 128, 207 128, 208 128, 209 0, 210 128, 211 253, 212 81, 213 0, 214 215 17, 216 27, 217 23, 218 51, 219 220 1, 221 } 222 }; 223 224 static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = { 225 .internal = 60000, 226 .sampling = 30000, 227 .pll_prediv = 1, 228 .pll_ratio = 8, 229 .pll_range = 3, 230 .pll_reset = 1, 231 .pll_bypass = 0, 232 .enable_refdiv = 0, 233 .bypclk_div = 0, 234 .IO_CLK_en_core = 1, 235 .ADClkSrc = 1, 236 .modulo = 2, 237 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 238 .ifreq = 0, 239 .timf = 20452225, 240 }; 241 242 static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = { 243 { .output_mpeg2_in_188_bytes = 1, 244 .hostbus_diversity = 1, 245 .tuner_is_baseband = 1, 246 247 .agc_config_count = 2, 248 .agc = stk7700d_7000p_mt2266_agc_config, 249 .bw = &stk7700d_mt2266_pll_config, 250 251 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 252 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 253 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 254 }, 255 { .output_mpeg2_in_188_bytes = 1, 256 .hostbus_diversity = 1, 257 .tuner_is_baseband = 1, 258 259 .agc_config_count = 2, 260 .agc = stk7700d_7000p_mt2266_agc_config, 261 .bw = &stk7700d_mt2266_pll_config, 262 263 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 264 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 265 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 266 } 267 }; 268 269 static struct mt2266_config stk7700d_mt2266_config[2] = { 270 { .i2c_address = 0x60 271 }, 272 { .i2c_address = 0x60 273 } 274 }; 275 276 static int stk7700P2_frontend_attach(struct dvb_usb_adapter *adap) 277 { 278 struct dib0700_adapter_state *state = adap->priv; 279 280 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 281 return -ENODEV; 282 283 if (adap->id == 0) { 284 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 285 msleep(10); 286 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 287 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 288 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 289 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 290 msleep(10); 291 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 292 msleep(10); 293 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 294 stk7700d_dib7000p_mt2266_config) 295 != 0) { 296 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__); 297 dvb_detach(state->dib7000p_ops.set_wbd_ref); 298 return -ENODEV; 299 } 300 } 301 302 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 303 0x80 + (adap->id << 1), 304 &stk7700d_dib7000p_mt2266_config[adap->id]); 305 306 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 307 } 308 309 static int stk7700d_frontend_attach(struct dvb_usb_adapter *adap) 310 { 311 struct dib0700_adapter_state *state = adap->priv; 312 313 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 314 return -ENODEV; 315 316 if (adap->id == 0) { 317 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 318 msleep(10); 319 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 320 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 321 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 322 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 323 msleep(10); 324 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 325 msleep(10); 326 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 327 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 328 stk7700d_dib7000p_mt2266_config) 329 != 0) { 330 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__); 331 dvb_detach(state->dib7000p_ops.set_wbd_ref); 332 return -ENODEV; 333 } 334 } 335 336 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 337 0x80 + (adap->id << 1), 338 &stk7700d_dib7000p_mt2266_config[adap->id]); 339 340 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 341 } 342 343 static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap) 344 { 345 struct i2c_adapter *tun_i2c; 346 struct dib0700_adapter_state *state = adap->priv; 347 348 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, 349 DIBX000_I2C_INTERFACE_TUNER, 1); 350 return dvb_attach(mt2266_attach, adap->fe_adap[0].fe, tun_i2c, 351 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0; 352 } 353 354 /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */ 355 static struct dibx000_agc_config xc3028_agc_config = { 356 .band_caps = BAND_VHF | BAND_UHF, 357 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, 358 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 359 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */ 360 .setup = (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), 361 .inv_gain = 712, 362 .time_stabiliz = 21, 363 .alpha_level = 0, 364 .thlock = 118, 365 .wbd_inv = 0, 366 .wbd_ref = 2867, 367 .wbd_sel = 0, 368 .wbd_alpha = 2, 369 .agc1_max = 0, 370 .agc1_min = 0, 371 .agc2_max = 39718, 372 .agc2_min = 9930, 373 .agc1_pt1 = 0, 374 .agc1_pt2 = 0, 375 .agc1_pt3 = 0, 376 .agc1_slope1 = 0, 377 .agc1_slope2 = 0, 378 .agc2_pt1 = 0, 379 .agc2_pt2 = 128, 380 .agc2_slope1 = 29, 381 .agc2_slope2 = 29, 382 .alpha_mant = 17, 383 .alpha_exp = 27, 384 .beta_mant = 23, 385 .beta_exp = 51, 386 .perform_agc_softsplit = 1, 387 }; 388 389 /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */ 390 static struct dibx000_bandwidth_config xc3028_bw_config = { 391 .internal = 60000, 392 .sampling = 30000, 393 .pll_prediv = 1, 394 .pll_ratio = 8, 395 .pll_range = 3, 396 .pll_reset = 1, 397 .pll_bypass = 0, 398 .enable_refdiv = 0, 399 .bypclk_div = 0, 400 .IO_CLK_en_core = 1, 401 .ADClkSrc = 1, 402 .modulo = 0, 403 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ 404 .ifreq = (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ 405 .timf = 20452225, 406 .xtal_hz = 30000000, 407 }; 408 409 static struct dib7000p_config stk7700ph_dib7700_xc3028_config = { 410 .output_mpeg2_in_188_bytes = 1, 411 .tuner_is_baseband = 1, 412 413 .agc_config_count = 1, 414 .agc = &xc3028_agc_config, 415 .bw = &xc3028_bw_config, 416 417 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 418 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 419 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 420 }; 421 422 static int stk7700ph_xc3028_callback(void *ptr, int component, 423 int command, int arg) 424 { 425 struct dvb_usb_adapter *adap = ptr; 426 struct dib0700_adapter_state *state = adap->priv; 427 428 switch (command) { 429 case XC2028_TUNER_RESET: 430 /* Send the tuner in then out of reset */ 431 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0); 432 msleep(10); 433 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 434 break; 435 case XC2028_RESET_CLK: 436 case XC2028_I2C_FLUSH: 437 break; 438 default: 439 err("%s: unknown command %d, arg %d\n", __func__, 440 command, arg); 441 return -EINVAL; 442 } 443 return 0; 444 } 445 446 static struct xc2028_ctrl stk7700ph_xc3028_ctrl = { 447 .fname = XC2028_DEFAULT_FIRMWARE, 448 .max_len = 64, 449 .demod = XC3028_FE_DIBCOM52, 450 }; 451 452 static struct xc2028_config stk7700ph_xc3028_config = { 453 .i2c_addr = 0x61, 454 .ctrl = &stk7700ph_xc3028_ctrl, 455 }; 456 457 static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap) 458 { 459 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor; 460 struct dib0700_adapter_state *state = adap->priv; 461 462 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 463 return -ENODEV; 464 465 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) && 466 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX)) 467 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 468 else 469 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 470 msleep(20); 471 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 472 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 473 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 474 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 475 msleep(10); 476 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 477 msleep(20); 478 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 479 msleep(10); 480 481 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 482 &stk7700ph_dib7700_xc3028_config) != 0) { 483 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", 484 __func__); 485 dvb_detach(state->dib7000p_ops.set_wbd_ref); 486 return -ENODEV; 487 } 488 489 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, 490 &stk7700ph_dib7700_xc3028_config); 491 492 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 493 } 494 495 static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap) 496 { 497 struct i2c_adapter *tun_i2c; 498 struct dib0700_adapter_state *state = adap->priv; 499 500 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, 501 DIBX000_I2C_INTERFACE_TUNER, 1); 502 503 stk7700ph_xc3028_config.i2c_adap = tun_i2c; 504 505 /* FIXME: generalize & move to common area */ 506 adap->fe_adap[0].fe->callback = stk7700ph_xc3028_callback; 507 508 return dvb_attach(xc2028_attach, adap->fe_adap[0].fe, &stk7700ph_xc3028_config) 509 == NULL ? -ENODEV : 0; 510 } 511 512 #define DEFAULT_RC_INTERVAL 50 513 514 /* 515 * This function is used only when firmware is < 1.20 version. Newer 516 * firmwares use bulk mode, with functions implemented at dib0700_core, 517 * at dib0700_rc_urb_completion() 518 */ 519 static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d) 520 { 521 enum rc_proto protocol; 522 u32 scancode; 523 u8 toggle; 524 int i; 525 struct dib0700_state *st = d->priv; 526 527 if (st->fw_version >= 0x10200) { 528 /* For 1.20 firmware , We need to keep the RC polling 529 callback so we can reuse the input device setup in 530 dvb-usb-remote.c. However, the actual work is being done 531 in the bulk URB completion handler. */ 532 return 0; 533 } 534 535 st->buf[0] = REQUEST_POLL_RC; 536 st->buf[1] = 0; 537 538 i = dib0700_ctrl_rd(d, st->buf, 2, st->buf, 4); 539 if (i <= 0) { 540 err("RC Query Failed"); 541 return -EIO; 542 } 543 544 /* losing half of KEY_0 events from Philipps rc5 remotes.. */ 545 if (st->buf[0] == 0 && st->buf[1] == 0 546 && st->buf[2] == 0 && st->buf[3] == 0) 547 return 0; 548 549 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)st->buf[3 - 2],(int)st->buf[3 - 3],(int)st->buf[3 - 1],(int)st->buf[3]); */ 550 551 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */ 552 553 switch (d->props.rc.core.protocol) { 554 case RC_PROTO_BIT_NEC: 555 /* NEC protocol sends repeat code as 0 0 0 FF */ 556 if ((st->buf[3 - 2] == 0x00) && (st->buf[3 - 3] == 0x00) && 557 (st->buf[3] == 0xff)) { 558 rc_repeat(d->rc_dev); 559 return 0; 560 } 561 562 protocol = RC_PROTO_NEC; 563 scancode = RC_SCANCODE_NEC(st->buf[3 - 2], st->buf[3 - 3]); 564 toggle = 0; 565 break; 566 567 default: 568 /* RC-5 protocol changes toggle bit on new keypress */ 569 protocol = RC_PROTO_RC5; 570 scancode = RC_SCANCODE_RC5(st->buf[3 - 2], st->buf[3 - 3]); 571 toggle = st->buf[3 - 1]; 572 break; 573 } 574 575 rc_keydown(d->rc_dev, protocol, scancode, toggle); 576 return 0; 577 } 578 579 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */ 580 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = { 581 BAND_UHF | BAND_VHF, 582 583 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 584 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */ 585 (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) 586 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), 587 588 712, 589 41, 590 591 0, 592 118, 593 594 0, 595 4095, 596 0, 597 0, 598 599 42598, 600 17694, 601 45875, 602 2621, 603 0, 604 76, 605 139, 606 52, 607 59, 608 107, 609 172, 610 57, 611 70, 612 613 21, 614 25, 615 28, 616 48, 617 618 1, 619 { 0, 620 107, 621 51800, 622 24700 623 }, 624 }; 625 626 static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = { 627 .band_caps = BAND_UHF | BAND_VHF, 628 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 629 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */ 630 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), 631 .inv_gain = 712, 632 .time_stabiliz = 41, 633 .alpha_level = 0, 634 .thlock = 118, 635 .wbd_inv = 0, 636 .wbd_ref = 4095, 637 .wbd_sel = 0, 638 .wbd_alpha = 0, 639 .agc1_max = 42598, 640 .agc1_min = 16384, 641 .agc2_max = 42598, 642 .agc2_min = 0, 643 .agc1_pt1 = 0, 644 .agc1_pt2 = 137, 645 .agc1_pt3 = 255, 646 .agc1_slope1 = 0, 647 .agc1_slope2 = 255, 648 .agc2_pt1 = 0, 649 .agc2_pt2 = 0, 650 .agc2_slope1 = 0, 651 .agc2_slope2 = 41, 652 .alpha_mant = 15, 653 .alpha_exp = 25, 654 .beta_mant = 28, 655 .beta_exp = 48, 656 .perform_agc_softsplit = 0, 657 }; 658 659 static struct dibx000_bandwidth_config stk7700p_pll_config = { 660 .internal = 60000, 661 .sampling = 30000, 662 .pll_prediv = 1, 663 .pll_ratio = 8, 664 .pll_range = 3, 665 .pll_reset = 1, 666 .pll_bypass = 0, 667 .enable_refdiv = 0, 668 .bypclk_div = 0, 669 .IO_CLK_en_core = 1, 670 .ADClkSrc = 1, 671 .modulo = 0, 672 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 673 .ifreq = 60258167, 674 .timf = 20452225, 675 .xtal_hz = 30000000, 676 }; 677 678 static struct dib7000m_config stk7700p_dib7000m_config = { 679 .dvbt_mode = 1, 680 .output_mpeg2_in_188_bytes = 1, 681 .quartz_direct = 1, 682 683 .agc_config_count = 1, 684 .agc = &stk7700p_7000m_mt2060_agc_config, 685 .bw = &stk7700p_pll_config, 686 687 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS, 688 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES, 689 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS, 690 }; 691 692 static struct dib7000p_config stk7700p_dib7000p_config = { 693 .output_mpeg2_in_188_bytes = 1, 694 695 .agc_config_count = 1, 696 .agc = &stk7700p_7000p_mt2060_agc_config, 697 .bw = &stk7700p_pll_config, 698 699 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS, 700 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES, 701 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS, 702 }; 703 704 static int stk7700p_frontend_attach(struct dvb_usb_adapter *adap) 705 { 706 struct dib0700_state *st = adap->dev->priv; 707 struct dib0700_adapter_state *state = adap->priv; 708 709 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 710 return -ENODEV; 711 712 /* unless there is no real power management in DVB - we leave the device on GPIO6 */ 713 714 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 715 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); msleep(50); 716 717 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); msleep(10); 718 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 719 720 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); msleep(10); 721 dib0700_ctrl_clock(adap->dev, 72, 1); 722 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); msleep(100); 723 724 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 725 726 st->mt2060_if1[0] = 1220; 727 728 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap)) { 729 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 18, &stk7700p_dib7000p_config); 730 st->is_dib7000pc = 1; 731 } else { 732 memset(&state->dib7000p_ops, 0, sizeof(state->dib7000p_ops)); 733 adap->fe_adap[0].fe = dvb_attach(dib7000m_attach, &adap->dev->i2c_adap, 18, &stk7700p_dib7000m_config); 734 } 735 736 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 737 } 738 739 static struct mt2060_config stk7700p_mt2060_config = { 740 0x60 741 }; 742 743 static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap) 744 { 745 struct i2c_adapter *prim_i2c = &adap->dev->i2c_adap; 746 struct dib0700_state *st = adap->dev->priv; 747 struct i2c_adapter *tun_i2c; 748 struct dib0700_adapter_state *state = adap->priv; 749 s8 a; 750 int if1=1220; 751 752 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) && 753 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) { 754 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a; 755 } 756 if (st->is_dib7000pc) 757 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); 758 else 759 tun_i2c = dib7000m_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); 760 761 return dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk7700p_mt2060_config, 762 if1) == NULL ? -ENODEV : 0; 763 } 764 765 /* DIB7070 generic */ 766 static struct dibx000_agc_config dib7070_agc_config = { 767 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, 768 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 769 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ 770 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 771 .inv_gain = 600, 772 .time_stabiliz = 10, 773 .alpha_level = 0, 774 .thlock = 118, 775 .wbd_inv = 0, 776 .wbd_ref = 3530, 777 .wbd_sel = 1, 778 .wbd_alpha = 5, 779 .agc1_max = 65535, 780 .agc1_min = 0, 781 .agc2_max = 65535, 782 .agc2_min = 0, 783 .agc1_pt1 = 0, 784 .agc1_pt2 = 40, 785 .agc1_pt3 = 183, 786 .agc1_slope1 = 206, 787 .agc1_slope2 = 255, 788 .agc2_pt1 = 72, 789 .agc2_pt2 = 152, 790 .agc2_slope1 = 88, 791 .agc2_slope2 = 90, 792 .alpha_mant = 17, 793 .alpha_exp = 27, 794 .beta_mant = 23, 795 .beta_exp = 51, 796 .perform_agc_softsplit = 0, 797 }; 798 799 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff) 800 { 801 struct dvb_usb_adapter *adap = fe->dvb->priv; 802 struct dib0700_adapter_state *state = adap->priv; 803 804 deb_info("reset: %d", onoff); 805 return state->dib7000p_ops.set_gpio(fe, 8, 0, !onoff); 806 } 807 808 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff) 809 { 810 struct dvb_usb_adapter *adap = fe->dvb->priv; 811 struct dib0700_adapter_state *state = adap->priv; 812 813 deb_info("sleep: %d", onoff); 814 return state->dib7000p_ops.set_gpio(fe, 9, 0, onoff); 815 } 816 817 static struct dib0070_config dib7070p_dib0070_config[2] = { 818 { 819 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 820 .reset = dib7070_tuner_reset, 821 .sleep = dib7070_tuner_sleep, 822 .clock_khz = 12000, 823 .clock_pad_drive = 4, 824 .charge_pump = 2, 825 }, { 826 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 827 .reset = dib7070_tuner_reset, 828 .sleep = dib7070_tuner_sleep, 829 .clock_khz = 12000, 830 .charge_pump = 2, 831 } 832 }; 833 834 static struct dib0070_config dib7770p_dib0070_config = { 835 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 836 .reset = dib7070_tuner_reset, 837 .sleep = dib7070_tuner_sleep, 838 .clock_khz = 12000, 839 .clock_pad_drive = 0, 840 .flip_chip = 1, 841 .charge_pump = 2, 842 }; 843 844 static int dib7070_set_param_override(struct dvb_frontend *fe) 845 { 846 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 847 struct dvb_usb_adapter *adap = fe->dvb->priv; 848 struct dib0700_adapter_state *state = adap->priv; 849 850 u16 offset; 851 u8 band = BAND_OF_FREQUENCY(p->frequency/1000); 852 switch (band) { 853 case BAND_VHF: offset = 950; break; 854 case BAND_UHF: 855 default: offset = 550; break; 856 } 857 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe)); 858 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe)); 859 return state->set_param_save(fe); 860 } 861 862 static int dib7770_set_param_override(struct dvb_frontend *fe) 863 { 864 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 865 struct dvb_usb_adapter *adap = fe->dvb->priv; 866 struct dib0700_adapter_state *state = adap->priv; 867 868 u16 offset; 869 u8 band = BAND_OF_FREQUENCY(p->frequency/1000); 870 switch (band) { 871 case BAND_VHF: 872 state->dib7000p_ops.set_gpio(fe, 0, 0, 1); 873 offset = 850; 874 break; 875 case BAND_UHF: 876 default: 877 state->dib7000p_ops.set_gpio(fe, 0, 0, 0); 878 offset = 250; 879 break; 880 } 881 deb_info("WBD for DiB7000P: %d\n", offset + dib0070_wbd_offset(fe)); 882 state->dib7000p_ops.set_wbd_ref(fe, offset + dib0070_wbd_offset(fe)); 883 return state->set_param_save(fe); 884 } 885 886 static int dib7770p_tuner_attach(struct dvb_usb_adapter *adap) 887 { 888 struct dib0700_adapter_state *st = adap->priv; 889 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, 890 DIBX000_I2C_INTERFACE_TUNER, 1); 891 892 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, 893 &dib7770p_dib0070_config) == NULL) 894 return -ENODEV; 895 896 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 897 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7770_set_param_override; 898 return 0; 899 } 900 901 static int dib7070p_tuner_attach(struct dvb_usb_adapter *adap) 902 { 903 struct dib0700_adapter_state *st = adap->priv; 904 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); 905 906 if (adap->id == 0) { 907 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[0]) == NULL) 908 return -ENODEV; 909 } else { 910 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, &dib7070p_dib0070_config[1]) == NULL) 911 return -ENODEV; 912 } 913 914 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 915 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7070_set_param_override; 916 return 0; 917 } 918 919 static int stk7700p_pid_filter(struct dvb_usb_adapter *adapter, int index, 920 u16 pid, int onoff) 921 { 922 struct dib0700_adapter_state *state = adapter->priv; 923 struct dib0700_state *st = adapter->dev->priv; 924 925 if (st->is_dib7000pc) 926 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff); 927 return dib7000m_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff); 928 } 929 930 static int stk7700p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff) 931 { 932 struct dib0700_state *st = adapter->dev->priv; 933 struct dib0700_adapter_state *state = adapter->priv; 934 if (st->is_dib7000pc) 935 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff); 936 return dib7000m_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff); 937 } 938 939 static int stk70x0p_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff) 940 { 941 struct dib0700_adapter_state *state = adapter->priv; 942 return state->dib7000p_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff); 943 } 944 945 static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff) 946 { 947 struct dib0700_adapter_state *state = adapter->priv; 948 return state->dib7000p_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff); 949 } 950 951 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = { 952 .internal = 60000, 953 .sampling = 15000, 954 .pll_prediv = 1, 955 .pll_ratio = 20, 956 .pll_range = 3, 957 .pll_reset = 1, 958 .pll_bypass = 0, 959 .enable_refdiv = 0, 960 .bypclk_div = 0, 961 .IO_CLK_en_core = 1, 962 .ADClkSrc = 1, 963 .modulo = 2, 964 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 965 .ifreq = (0 << 25) | 0, 966 .timf = 20452225, 967 .xtal_hz = 12000000, 968 }; 969 970 static struct dib7000p_config dib7070p_dib7000p_config = { 971 .output_mpeg2_in_188_bytes = 1, 972 973 .agc_config_count = 1, 974 .agc = &dib7070_agc_config, 975 .bw = &dib7070_bw_config_12_mhz, 976 .tuner_is_baseband = 1, 977 .spur_protect = 1, 978 979 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 980 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 981 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 982 983 .hostbus_diversity = 1, 984 }; 985 986 /* STK7070P */ 987 static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) 988 { 989 struct usb_device_descriptor *p = &adap->dev->udev->descriptor; 990 struct dib0700_adapter_state *state = adap->priv; 991 992 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 993 return -ENODEV; 994 995 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) && 996 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E)) 997 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 998 else 999 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 1000 msleep(10); 1001 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1002 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1003 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 1004 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 1005 1006 dib0700_ctrl_clock(adap->dev, 72, 1); 1007 1008 msleep(10); 1009 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 1010 msleep(10); 1011 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 1012 1013 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 1014 &dib7070p_dib7000p_config) != 0) { 1015 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", 1016 __func__); 1017 dvb_detach(state->dib7000p_ops.set_wbd_ref); 1018 return -ENODEV; 1019 } 1020 1021 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, 1022 &dib7070p_dib7000p_config); 1023 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1024 } 1025 1026 /* STK7770P */ 1027 static struct dib7000p_config dib7770p_dib7000p_config = { 1028 .output_mpeg2_in_188_bytes = 1, 1029 1030 .agc_config_count = 1, 1031 .agc = &dib7070_agc_config, 1032 .bw = &dib7070_bw_config_12_mhz, 1033 .tuner_is_baseband = 1, 1034 .spur_protect = 1, 1035 1036 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 1037 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 1038 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 1039 1040 .hostbus_diversity = 1, 1041 .enable_current_mirror = 1, 1042 .disable_sample_and_hold = 0, 1043 }; 1044 1045 static int stk7770p_frontend_attach(struct dvb_usb_adapter *adap) 1046 { 1047 struct usb_device_descriptor *p = &adap->dev->udev->descriptor; 1048 struct dib0700_adapter_state *state = adap->priv; 1049 1050 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 1051 return -ENODEV; 1052 1053 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) && 1054 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E)) 1055 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 1056 else 1057 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 1058 msleep(10); 1059 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1060 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1061 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 1062 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 1063 1064 dib0700_ctrl_clock(adap->dev, 72, 1); 1065 1066 msleep(10); 1067 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 1068 msleep(10); 1069 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 1070 1071 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 1072 &dib7770p_dib7000p_config) != 0) { 1073 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", 1074 __func__); 1075 dvb_detach(state->dib7000p_ops.set_wbd_ref); 1076 return -ENODEV; 1077 } 1078 1079 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, 1080 &dib7770p_dib7000p_config); 1081 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1082 } 1083 1084 /* DIB807x generic */ 1085 static struct dibx000_agc_config dib807x_agc_config[2] = { 1086 { 1087 BAND_VHF, 1088 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, 1089 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, 1090 * P_agc_inv_pwm2=0,P_agc_inh_dc_rv_est=0, 1091 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, 1092 * P_agc_write=0 */ 1093 (0 << 15) | (0 << 14) | (7 << 11) | (0 << 10) | (0 << 9) | 1094 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | 1095 (0 << 0), /* setup*/ 1096 1097 600, /* inv_gain*/ 1098 10, /* time_stabiliz*/ 1099 1100 0, /* alpha_level*/ 1101 118, /* thlock*/ 1102 1103 0, /* wbd_inv*/ 1104 3530, /* wbd_ref*/ 1105 1, /* wbd_sel*/ 1106 5, /* wbd_alpha*/ 1107 1108 65535, /* agc1_max*/ 1109 0, /* agc1_min*/ 1110 1111 65535, /* agc2_max*/ 1112 0, /* agc2_min*/ 1113 1114 0, /* agc1_pt1*/ 1115 40, /* agc1_pt2*/ 1116 183, /* agc1_pt3*/ 1117 206, /* agc1_slope1*/ 1118 255, /* agc1_slope2*/ 1119 72, /* agc2_pt1*/ 1120 152, /* agc2_pt2*/ 1121 88, /* agc2_slope1*/ 1122 90, /* agc2_slope2*/ 1123 1124 17, /* alpha_mant*/ 1125 27, /* alpha_exp*/ 1126 23, /* beta_mant*/ 1127 51, /* beta_exp*/ 1128 1129 0, /* perform_agc_softsplit*/ 1130 }, { 1131 BAND_UHF, 1132 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, 1133 * P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, 1134 * P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 1135 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, 1136 * P_agc_write=0 */ 1137 (0 << 15) | (0 << 14) | (1 << 11) | (0 << 10) | (0 << 9) | 1138 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | 1139 (0 << 0), /* setup */ 1140 1141 600, /* inv_gain*/ 1142 10, /* time_stabiliz*/ 1143 1144 0, /* alpha_level*/ 1145 118, /* thlock*/ 1146 1147 0, /* wbd_inv*/ 1148 3530, /* wbd_ref*/ 1149 1, /* wbd_sel*/ 1150 5, /* wbd_alpha*/ 1151 1152 65535, /* agc1_max*/ 1153 0, /* agc1_min*/ 1154 1155 65535, /* agc2_max*/ 1156 0, /* agc2_min*/ 1157 1158 0, /* agc1_pt1*/ 1159 40, /* agc1_pt2*/ 1160 183, /* agc1_pt3*/ 1161 206, /* agc1_slope1*/ 1162 255, /* agc1_slope2*/ 1163 72, /* agc2_pt1*/ 1164 152, /* agc2_pt2*/ 1165 88, /* agc2_slope1*/ 1166 90, /* agc2_slope2*/ 1167 1168 17, /* alpha_mant*/ 1169 27, /* alpha_exp*/ 1170 23, /* beta_mant*/ 1171 51, /* beta_exp*/ 1172 1173 0, /* perform_agc_softsplit*/ 1174 } 1175 }; 1176 1177 static struct dibx000_bandwidth_config dib807x_bw_config_12_mhz = { 1178 .internal = 60000, 1179 .sampling = 15000, 1180 .pll_prediv = 1, 1181 .pll_ratio = 20, 1182 .pll_range = 3, 1183 .pll_reset = 1, 1184 .pll_bypass = 0, 1185 .enable_refdiv = 0, 1186 .bypclk_div = 0, 1187 .IO_CLK_en_core = 1, 1188 .ADClkSrc = 1, 1189 .modulo = 2, 1190 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0), /* sad_cfg: refsel, sel, freq_15k*/ 1191 .ifreq = (0 << 25) | 0, /* ifreq = 0.000000 MHz*/ 1192 .timf = 18179755, 1193 .xtal_hz = 12000000, 1194 }; 1195 1196 static struct dib8000_config dib807x_dib8000_config[2] = { 1197 { 1198 .output_mpeg2_in_188_bytes = 1, 1199 1200 .agc_config_count = 2, 1201 .agc = dib807x_agc_config, 1202 .pll = &dib807x_bw_config_12_mhz, 1203 .tuner_is_baseband = 1, 1204 1205 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, 1206 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, 1207 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, 1208 1209 .hostbus_diversity = 1, 1210 .div_cfg = 1, 1211 .agc_control = &dib0070_ctrl_agc_filter, 1212 .output_mode = OUTMODE_MPEG2_FIFO, 1213 .drives = 0x2d98, 1214 }, { 1215 .output_mpeg2_in_188_bytes = 1, 1216 1217 .agc_config_count = 2, 1218 .agc = dib807x_agc_config, 1219 .pll = &dib807x_bw_config_12_mhz, 1220 .tuner_is_baseband = 1, 1221 1222 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, 1223 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, 1224 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, 1225 1226 .hostbus_diversity = 1, 1227 .agc_control = &dib0070_ctrl_agc_filter, 1228 .output_mode = OUTMODE_MPEG2_FIFO, 1229 .drives = 0x2d98, 1230 } 1231 }; 1232 1233 static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff) 1234 { 1235 struct dvb_usb_adapter *adap = fe->dvb->priv; 1236 struct dib0700_adapter_state *state = adap->priv; 1237 1238 return state->dib8000_ops.set_gpio(fe, 5, 0, !onoff); 1239 } 1240 1241 static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff) 1242 { 1243 struct dvb_usb_adapter *adap = fe->dvb->priv; 1244 struct dib0700_adapter_state *state = adap->priv; 1245 1246 return state->dib8000_ops.set_gpio(fe, 0, 0, onoff); 1247 } 1248 1249 static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = { 1250 { 240, 7}, 1251 { 0xffff, 6}, 1252 }; 1253 1254 static struct dib0070_config dib807x_dib0070_config[2] = { 1255 { 1256 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 1257 .reset = dib80xx_tuner_reset, 1258 .sleep = dib80xx_tuner_sleep, 1259 .clock_khz = 12000, 1260 .clock_pad_drive = 4, 1261 .vga_filter = 1, 1262 .force_crystal_mode = 1, 1263 .enable_third_order_filter = 1, 1264 .charge_pump = 0, 1265 .wbd_gain = dib8070_wbd_gain_cfg, 1266 .osc_buffer_state = 0, 1267 .freq_offset_khz_uhf = -100, 1268 .freq_offset_khz_vhf = -100, 1269 }, { 1270 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 1271 .reset = dib80xx_tuner_reset, 1272 .sleep = dib80xx_tuner_sleep, 1273 .clock_khz = 12000, 1274 .clock_pad_drive = 2, 1275 .vga_filter = 1, 1276 .force_crystal_mode = 1, 1277 .enable_third_order_filter = 1, 1278 .charge_pump = 0, 1279 .wbd_gain = dib8070_wbd_gain_cfg, 1280 .osc_buffer_state = 0, 1281 .freq_offset_khz_uhf = -25, 1282 .freq_offset_khz_vhf = -25, 1283 } 1284 }; 1285 1286 static int dib807x_set_param_override(struct dvb_frontend *fe) 1287 { 1288 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 1289 struct dvb_usb_adapter *adap = fe->dvb->priv; 1290 struct dib0700_adapter_state *state = adap->priv; 1291 1292 u16 offset = dib0070_wbd_offset(fe); 1293 u8 band = BAND_OF_FREQUENCY(p->frequency/1000); 1294 switch (band) { 1295 case BAND_VHF: 1296 offset += 750; 1297 break; 1298 case BAND_UHF: /* fall-thru wanted */ 1299 default: 1300 offset += 250; break; 1301 } 1302 deb_info("WBD for DiB8000: %d\n", offset); 1303 state->dib8000_ops.set_wbd_ref(fe, offset); 1304 1305 return state->set_param_save(fe); 1306 } 1307 1308 static int dib807x_tuner_attach(struct dvb_usb_adapter *adap) 1309 { 1310 struct dib0700_adapter_state *st = adap->priv; 1311 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, 1312 DIBX000_I2C_INTERFACE_TUNER, 1); 1313 1314 if (adap->id == 0) { 1315 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, 1316 &dib807x_dib0070_config[0]) == NULL) 1317 return -ENODEV; 1318 } else { 1319 if (dvb_attach(dib0070_attach, adap->fe_adap[0].fe, tun_i2c, 1320 &dib807x_dib0070_config[1]) == NULL) 1321 return -ENODEV; 1322 } 1323 1324 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 1325 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib807x_set_param_override; 1326 return 0; 1327 } 1328 1329 static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index, 1330 u16 pid, int onoff) 1331 { 1332 struct dib0700_adapter_state *state = adapter->priv; 1333 1334 return state->dib8000_ops.pid_filter(adapter->fe_adap[0].fe, index, pid, onoff); 1335 } 1336 1337 static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter, 1338 int onoff) 1339 { 1340 struct dib0700_adapter_state *state = adapter->priv; 1341 1342 return state->dib8000_ops.pid_filter_ctrl(adapter->fe_adap[0].fe, onoff); 1343 } 1344 1345 /* STK807x */ 1346 static int stk807x_frontend_attach(struct dvb_usb_adapter *adap) 1347 { 1348 struct dib0700_adapter_state *state = adap->priv; 1349 1350 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1351 return -ENODEV; 1352 1353 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 1354 msleep(10); 1355 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1356 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1357 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 1358 1359 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 1360 1361 dib0700_ctrl_clock(adap->dev, 72, 1); 1362 1363 msleep(10); 1364 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 1365 msleep(10); 1366 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 1367 1368 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 1369 0x80, 0); 1370 1371 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, 1372 &dib807x_dib8000_config[0]); 1373 1374 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1375 } 1376 1377 /* STK807xPVR */ 1378 static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap) 1379 { 1380 struct dib0700_adapter_state *state = adap->priv; 1381 1382 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1383 return -ENODEV; 1384 1385 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 1386 msleep(30); 1387 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 1388 msleep(500); 1389 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1390 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1391 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 1392 1393 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 1394 1395 dib0700_ctrl_clock(adap->dev, 72, 1); 1396 1397 msleep(10); 1398 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 1399 msleep(10); 1400 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 1401 1402 /* initialize IC 0 */ 1403 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80, 0); 1404 1405 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, 1406 &dib807x_dib8000_config[0]); 1407 1408 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1409 } 1410 1411 static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap) 1412 { 1413 struct dib0700_adapter_state *state = adap->priv; 1414 1415 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1416 return -ENODEV; 1417 1418 /* initialize IC 1 */ 1419 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82, 0); 1420 1421 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, 1422 &dib807x_dib8000_config[1]); 1423 1424 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1425 } 1426 1427 /* STK8096GP */ 1428 static struct dibx000_agc_config dib8090_agc_config[2] = { 1429 { 1430 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, 1431 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, 1432 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 1433 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ 1434 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) 1435 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 1436 1437 .inv_gain = 787, 1438 .time_stabiliz = 10, 1439 1440 .alpha_level = 0, 1441 .thlock = 118, 1442 1443 .wbd_inv = 0, 1444 .wbd_ref = 3530, 1445 .wbd_sel = 1, 1446 .wbd_alpha = 5, 1447 1448 .agc1_max = 65535, 1449 .agc1_min = 0, 1450 1451 .agc2_max = 65535, 1452 .agc2_min = 0, 1453 1454 .agc1_pt1 = 0, 1455 .agc1_pt2 = 32, 1456 .agc1_pt3 = 114, 1457 .agc1_slope1 = 143, 1458 .agc1_slope2 = 144, 1459 .agc2_pt1 = 114, 1460 .agc2_pt2 = 227, 1461 .agc2_slope1 = 116, 1462 .agc2_slope2 = 117, 1463 1464 .alpha_mant = 28, 1465 .alpha_exp = 26, 1466 .beta_mant = 31, 1467 .beta_exp = 51, 1468 1469 .perform_agc_softsplit = 0, 1470 }, 1471 { 1472 .band_caps = BAND_CBAND, 1473 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, 1474 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 1475 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ 1476 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) 1477 | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 1478 1479 .inv_gain = 787, 1480 .time_stabiliz = 10, 1481 1482 .alpha_level = 0, 1483 .thlock = 118, 1484 1485 .wbd_inv = 0, 1486 .wbd_ref = 3530, 1487 .wbd_sel = 1, 1488 .wbd_alpha = 5, 1489 1490 .agc1_max = 0, 1491 .agc1_min = 0, 1492 1493 .agc2_max = 65535, 1494 .agc2_min = 0, 1495 1496 .agc1_pt1 = 0, 1497 .agc1_pt2 = 32, 1498 .agc1_pt3 = 114, 1499 .agc1_slope1 = 143, 1500 .agc1_slope2 = 144, 1501 .agc2_pt1 = 114, 1502 .agc2_pt2 = 227, 1503 .agc2_slope1 = 116, 1504 .agc2_slope2 = 117, 1505 1506 .alpha_mant = 28, 1507 .alpha_exp = 26, 1508 .beta_mant = 31, 1509 .beta_exp = 51, 1510 1511 .perform_agc_softsplit = 0, 1512 } 1513 }; 1514 1515 static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = { 1516 .internal = 54000, 1517 .sampling = 13500, 1518 1519 .pll_prediv = 1, 1520 .pll_ratio = 18, 1521 .pll_range = 3, 1522 .pll_reset = 1, 1523 .pll_bypass = 0, 1524 1525 .enable_refdiv = 0, 1526 .bypclk_div = 0, 1527 .IO_CLK_en_core = 1, 1528 .ADClkSrc = 1, 1529 .modulo = 2, 1530 1531 .sad_cfg = (3 << 14) | (1 << 12) | (599 << 0), 1532 1533 .ifreq = (0 << 25) | 0, 1534 .timf = 20199727, 1535 1536 .xtal_hz = 12000000, 1537 }; 1538 1539 static int dib8090_get_adc_power(struct dvb_frontend *fe) 1540 { 1541 struct dvb_usb_adapter *adap = fe->dvb->priv; 1542 struct dib0700_adapter_state *state = adap->priv; 1543 1544 return state->dib8000_ops.get_adc_power(fe, 1); 1545 } 1546 1547 static void dib8090_agc_control(struct dvb_frontend *fe, u8 restart) 1548 { 1549 deb_info("AGC control callback: %i\n", restart); 1550 dib0090_dcc_freq(fe, restart); 1551 1552 if (restart == 0) /* before AGC startup */ 1553 dib0090_set_dc_servo(fe, 1); 1554 } 1555 1556 static struct dib8000_config dib809x_dib8000_config[2] = { 1557 { 1558 .output_mpeg2_in_188_bytes = 1, 1559 1560 .agc_config_count = 2, 1561 .agc = dib8090_agc_config, 1562 .agc_control = dib8090_agc_control, 1563 .pll = &dib8090_pll_config_12mhz, 1564 .tuner_is_baseband = 1, 1565 1566 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, 1567 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, 1568 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, 1569 1570 .hostbus_diversity = 1, 1571 .div_cfg = 0x31, 1572 .output_mode = OUTMODE_MPEG2_FIFO, 1573 .drives = 0x2d98, 1574 .diversity_delay = 48, 1575 .refclksel = 3, 1576 }, { 1577 .output_mpeg2_in_188_bytes = 1, 1578 1579 .agc_config_count = 2, 1580 .agc = dib8090_agc_config, 1581 .agc_control = dib8090_agc_control, 1582 .pll = &dib8090_pll_config_12mhz, 1583 .tuner_is_baseband = 1, 1584 1585 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, 1586 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, 1587 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, 1588 1589 .hostbus_diversity = 1, 1590 .div_cfg = 0x31, 1591 .output_mode = OUTMODE_DIVERSITY, 1592 .drives = 0x2d08, 1593 .diversity_delay = 1, 1594 .refclksel = 3, 1595 } 1596 }; 1597 1598 static struct dib0090_wbd_slope dib8090_wbd_table[] = { 1599 /* max freq ; cold slope ; cold offset ; warm slope ; warm offset ; wbd gain */ 1600 { 120, 0, 500, 0, 500, 4 }, /* CBAND */ 1601 { 170, 0, 450, 0, 450, 4 }, /* CBAND */ 1602 { 380, 48, 373, 28, 259, 6 }, /* VHF */ 1603 { 860, 34, 700, 36, 616, 6 }, /* high UHF */ 1604 { 0xFFFF, 34, 700, 36, 616, 6 }, /* default */ 1605 }; 1606 1607 static struct dib0090_config dib809x_dib0090_config = { 1608 .io.pll_bypass = 1, 1609 .io.pll_range = 1, 1610 .io.pll_prediv = 1, 1611 .io.pll_loopdiv = 20, 1612 .io.adc_clock_ratio = 8, 1613 .io.pll_int_loop_filt = 0, 1614 .io.clock_khz = 12000, 1615 .reset = dib80xx_tuner_reset, 1616 .sleep = dib80xx_tuner_sleep, 1617 .clkouttobamse = 1, 1618 .analog_output = 1, 1619 .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS, 1620 .use_pwm_agc = 1, 1621 .clkoutdrive = 1, 1622 .get_adc_power = dib8090_get_adc_power, 1623 .freq_offset_khz_uhf = -63, 1624 .freq_offset_khz_vhf = -143, 1625 .wbd = dib8090_wbd_table, 1626 .fref_clock_ratio = 6, 1627 }; 1628 1629 static u8 dib8090_compute_pll_parameters(struct dvb_frontend *fe) 1630 { 1631 u8 optimal_pll_ratio = 20; 1632 u32 freq_adc, ratio, rest, max = 0; 1633 u8 pll_ratio; 1634 1635 for (pll_ratio = 17; pll_ratio <= 20; pll_ratio++) { 1636 freq_adc = 12 * pll_ratio * (1 << 8) / 16; 1637 ratio = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) / freq_adc; 1638 rest = ((fe->dtv_property_cache.frequency / 1000) * (1 << 8) / 1000) - ratio * freq_adc; 1639 1640 if (rest > freq_adc / 2) 1641 rest = freq_adc - rest; 1642 deb_info("PLL ratio=%i rest=%i\n", pll_ratio, rest); 1643 if ((rest > max) && (rest > 717)) { 1644 optimal_pll_ratio = pll_ratio; 1645 max = rest; 1646 } 1647 } 1648 deb_info("optimal PLL ratio=%i\n", optimal_pll_ratio); 1649 1650 return optimal_pll_ratio; 1651 } 1652 1653 static int dib8096_set_param_override(struct dvb_frontend *fe) 1654 { 1655 struct dvb_usb_adapter *adap = fe->dvb->priv; 1656 struct dib0700_adapter_state *state = adap->priv; 1657 u8 pll_ratio, band = BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000); 1658 u16 target, ltgain, rf_gain_limit; 1659 u32 timf; 1660 int ret = 0; 1661 enum frontend_tune_state tune_state = CT_SHUTDOWN; 1662 1663 switch (band) { 1664 default: 1665 deb_info("Warning : Rf frequency (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency); 1666 /* fall through */ 1667 case BAND_VHF: 1668 state->dib8000_ops.set_gpio(fe, 3, 0, 1); 1669 break; 1670 case BAND_UHF: 1671 state->dib8000_ops.set_gpio(fe, 3, 0, 0); 1672 break; 1673 } 1674 1675 ret = state->set_param_save(fe); 1676 if (ret < 0) 1677 return ret; 1678 1679 if (fe->dtv_property_cache.bandwidth_hz != 6000000) { 1680 deb_info("only 6MHz bandwidth is supported\n"); 1681 return -EINVAL; 1682 } 1683 1684 /* Update PLL if needed ratio */ 1685 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, 0); 1686 1687 /* Get optimize PLL ratio to remove spurious */ 1688 pll_ratio = dib8090_compute_pll_parameters(fe); 1689 if (pll_ratio == 17) 1690 timf = 21387946; 1691 else if (pll_ratio == 18) 1692 timf = 20199727; 1693 else if (pll_ratio == 19) 1694 timf = 19136583; 1695 else 1696 timf = 18179756; 1697 1698 /* Update ratio */ 1699 state->dib8000_ops.update_pll(fe, &dib8090_pll_config_12mhz, fe->dtv_property_cache.bandwidth_hz / 1000, pll_ratio); 1700 1701 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, timf); 1702 1703 if (band != BAND_CBAND) { 1704 /* dib0090_get_wbd_target is returning any possible temperature compensated wbd-target */ 1705 target = (dib0090_get_wbd_target(fe) * 8 * 18 / 33 + 1) / 2; 1706 state->dib8000_ops.set_wbd_ref(fe, target); 1707 } 1708 1709 if (band == BAND_CBAND) { 1710 deb_info("tuning in CBAND - soft-AGC startup\n"); 1711 dib0090_set_tune_state(fe, CT_AGC_START); 1712 1713 do { 1714 ret = dib0090_gain_control(fe); 1715 msleep(ret); 1716 tune_state = dib0090_get_tune_state(fe); 1717 if (tune_state == CT_AGC_STEP_0) 1718 state->dib8000_ops.set_gpio(fe, 6, 0, 1); 1719 else if (tune_state == CT_AGC_STEP_1) { 1720 dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, <gain); 1721 if (rf_gain_limit < 2000) /* activate the external attenuator in case of very high input power */ 1722 state->dib8000_ops.set_gpio(fe, 6, 0, 0); 1723 } 1724 } while (tune_state < CT_AGC_STOP); 1725 1726 deb_info("switching to PWM AGC\n"); 1727 dib0090_pwm_gain_reset(fe); 1728 state->dib8000_ops.pwm_agc_reset(fe); 1729 state->dib8000_ops.set_tune_state(fe, CT_DEMOD_START); 1730 } else { 1731 /* for everything else than CBAND we are using standard AGC */ 1732 deb_info("not tuning in CBAND - standard AGC startup\n"); 1733 dib0090_pwm_gain_reset(fe); 1734 } 1735 1736 return 0; 1737 } 1738 1739 static int dib809x_tuner_attach(struct dvb_usb_adapter *adap) 1740 { 1741 struct dib0700_adapter_state *st = adap->priv; 1742 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); 1743 1744 if (adap->id == 0) { 1745 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) 1746 return -ENODEV; 1747 } else { 1748 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) 1749 return -ENODEV; 1750 } 1751 1752 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 1753 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override; 1754 return 0; 1755 } 1756 1757 static int stk809x_frontend_attach(struct dvb_usb_adapter *adap) 1758 { 1759 struct dib0700_adapter_state *state = adap->priv; 1760 1761 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1762 return -ENODEV; 1763 1764 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 1765 msleep(10); 1766 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1767 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1768 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 1769 1770 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 1771 1772 dib0700_ctrl_clock(adap->dev, 72, 1); 1773 1774 msleep(10); 1775 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 1776 msleep(10); 1777 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 1778 1779 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80, 0); 1780 1781 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]); 1782 1783 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1784 } 1785 1786 static int stk809x_frontend1_attach(struct dvb_usb_adapter *adap) 1787 { 1788 struct dib0700_adapter_state *state = adap->priv; 1789 1790 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1791 return -ENODEV; 1792 1793 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x82, 0); 1794 1795 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]); 1796 1797 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 1798 } 1799 1800 static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap) 1801 { 1802 struct dib0700_adapter_state *st = adap->priv; 1803 struct i2c_adapter *tun_i2c; 1804 struct dvb_frontend *fe_slave = st->dib8000_ops.get_slave_frontend(adap->fe_adap[0].fe, 1); 1805 1806 if (fe_slave) { 1807 tun_i2c = st->dib8000_ops.get_i2c_master(fe_slave, DIBX000_I2C_INTERFACE_TUNER, 1); 1808 if (dvb_attach(dib0090_register, fe_slave, tun_i2c, &dib809x_dib0090_config) == NULL) 1809 return -ENODEV; 1810 fe_slave->dvb = adap->fe_adap[0].fe->dvb; 1811 fe_slave->ops.tuner_ops.set_params = dib8096_set_param_override; 1812 } 1813 tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); 1814 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) 1815 return -ENODEV; 1816 1817 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 1818 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override; 1819 1820 return 0; 1821 } 1822 1823 static int nim8096md_frontend_attach(struct dvb_usb_adapter *adap) 1824 { 1825 struct dvb_frontend *fe_slave; 1826 struct dib0700_adapter_state *state = adap->priv; 1827 1828 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1829 return -ENODEV; 1830 1831 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 1832 msleep(20); 1833 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 1834 msleep(1000); 1835 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1836 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1837 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 1838 1839 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 1840 1841 dib0700_ctrl_clock(adap->dev, 72, 1); 1842 1843 msleep(20); 1844 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 1845 msleep(20); 1846 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 1847 1848 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 0x80, 0); 1849 1850 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config[0]); 1851 if (adap->fe_adap[0].fe == NULL) 1852 return -ENODEV; 1853 1854 /* Needed to increment refcount */ 1855 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 1856 return -ENODEV; 1857 1858 fe_slave = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]); 1859 state->dib8000_ops.set_slave_frontend(adap->fe_adap[0].fe, fe_slave); 1860 1861 return fe_slave == NULL ? -ENODEV : 0; 1862 } 1863 1864 /* TFE8096P */ 1865 static struct dibx000_agc_config dib8096p_agc_config[2] = { 1866 { 1867 .band_caps = BAND_UHF, 1868 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, 1869 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, 1870 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 1871 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, 1872 P_agc_write=0 */ 1873 .setup = (0 << 15) | (0 << 14) | (5 << 11) 1874 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) 1875 | (0 << 4) | (5 << 1) | (0 << 0), 1876 1877 .inv_gain = 684, 1878 .time_stabiliz = 10, 1879 1880 .alpha_level = 0, 1881 .thlock = 118, 1882 1883 .wbd_inv = 0, 1884 .wbd_ref = 1200, 1885 .wbd_sel = 3, 1886 .wbd_alpha = 5, 1887 1888 .agc1_max = 65535, 1889 .agc1_min = 0, 1890 1891 .agc2_max = 32767, 1892 .agc2_min = 0, 1893 1894 .agc1_pt1 = 0, 1895 .agc1_pt2 = 0, 1896 .agc1_pt3 = 105, 1897 .agc1_slope1 = 0, 1898 .agc1_slope2 = 156, 1899 .agc2_pt1 = 105, 1900 .agc2_pt2 = 255, 1901 .agc2_slope1 = 54, 1902 .agc2_slope2 = 0, 1903 1904 .alpha_mant = 28, 1905 .alpha_exp = 26, 1906 .beta_mant = 31, 1907 .beta_exp = 51, 1908 1909 .perform_agc_softsplit = 0, 1910 } , { 1911 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND, 1912 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, 1913 P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, 1914 P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 1915 P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, 1916 P_agc_write=0 */ 1917 .setup = (0 << 15) | (0 << 14) | (5 << 11) 1918 | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) 1919 | (0 << 4) | (5 << 1) | (0 << 0), 1920 1921 .inv_gain = 732, 1922 .time_stabiliz = 10, 1923 1924 .alpha_level = 0, 1925 .thlock = 118, 1926 1927 .wbd_inv = 0, 1928 .wbd_ref = 1200, 1929 .wbd_sel = 3, 1930 .wbd_alpha = 5, 1931 1932 .agc1_max = 65535, 1933 .agc1_min = 0, 1934 1935 .agc2_max = 32767, 1936 .agc2_min = 0, 1937 1938 .agc1_pt1 = 0, 1939 .agc1_pt2 = 0, 1940 .agc1_pt3 = 98, 1941 .agc1_slope1 = 0, 1942 .agc1_slope2 = 167, 1943 .agc2_pt1 = 98, 1944 .agc2_pt2 = 255, 1945 .agc2_slope1 = 52, 1946 .agc2_slope2 = 0, 1947 1948 .alpha_mant = 28, 1949 .alpha_exp = 26, 1950 .beta_mant = 31, 1951 .beta_exp = 51, 1952 1953 .perform_agc_softsplit = 0, 1954 } 1955 }; 1956 1957 static struct dibx000_bandwidth_config dib8096p_clock_config_12_mhz = { 1958 .internal = 108000, 1959 .sampling = 13500, 1960 .pll_prediv = 1, 1961 .pll_ratio = 9, 1962 .pll_range = 1, 1963 .pll_reset = 0, 1964 .pll_bypass = 0, 1965 .enable_refdiv = 0, 1966 .bypclk_div = 0, 1967 .IO_CLK_en_core = 0, 1968 .ADClkSrc = 0, 1969 .modulo = 2, 1970 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 1971 .ifreq = (0 << 25) | 0, 1972 .timf = 20199729, 1973 .xtal_hz = 12000000, 1974 }; 1975 1976 static struct dib8000_config tfe8096p_dib8000_config = { 1977 .output_mpeg2_in_188_bytes = 1, 1978 .hostbus_diversity = 1, 1979 .update_lna = NULL, 1980 1981 .agc_config_count = 2, 1982 .agc = dib8096p_agc_config, 1983 .pll = &dib8096p_clock_config_12_mhz, 1984 1985 .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS, 1986 .gpio_val = DIB8000_GPIO_DEFAULT_VALUES, 1987 .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS, 1988 1989 .agc_control = NULL, 1990 .diversity_delay = 48, 1991 .output_mode = OUTMODE_MPEG2_FIFO, 1992 .enMpegOutput = 1, 1993 }; 1994 1995 static struct dib0090_wbd_slope dib8096p_wbd_table[] = { 1996 { 380, 81, 850, 64, 540, 4}, 1997 { 860, 51, 866, 21, 375, 4}, 1998 {1700, 0, 250, 0, 100, 6}, 1999 {2600, 0, 250, 0, 100, 6}, 2000 { 0xFFFF, 0, 0, 0, 0, 0}, 2001 }; 2002 2003 static struct dib0090_config tfe8096p_dib0090_config = { 2004 .io.clock_khz = 12000, 2005 .io.pll_bypass = 0, 2006 .io.pll_range = 0, 2007 .io.pll_prediv = 3, 2008 .io.pll_loopdiv = 6, 2009 .io.adc_clock_ratio = 0, 2010 .io.pll_int_loop_filt = 0, 2011 2012 .freq_offset_khz_uhf = -143, 2013 .freq_offset_khz_vhf = -143, 2014 2015 .get_adc_power = dib8090_get_adc_power, 2016 2017 .clkouttobamse = 1, 2018 .analog_output = 0, 2019 2020 .wbd_vhf_offset = 0, 2021 .wbd_cband_offset = 0, 2022 .use_pwm_agc = 1, 2023 .clkoutdrive = 0, 2024 2025 .fref_clock_ratio = 1, 2026 2027 .ls_cfg_pad_drv = 0, 2028 .data_tx_drv = 0, 2029 .low_if = NULL, 2030 .in_soc = 1, 2031 .force_cband_input = 0, 2032 }; 2033 2034 struct dibx090p_adc { 2035 u32 freq; /* RF freq MHz */ 2036 u32 timf; /* New Timf */ 2037 u32 pll_loopdiv; /* New prediv */ 2038 u32 pll_prediv; /* New loopdiv */ 2039 }; 2040 2041 struct dibx090p_best_adc { 2042 u32 timf; 2043 u32 pll_loopdiv; 2044 u32 pll_prediv; 2045 }; 2046 2047 static int dib8096p_get_best_sampling(struct dvb_frontend *fe, struct dibx090p_best_adc *adc) 2048 { 2049 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1; 2050 u16 xtal = 12000; 2051 u16 fcp_min = 1900; /* PLL, Minimum Frequency of phase comparator (KHz) */ 2052 u16 fcp_max = 20000; /* PLL, Maximum Frequency of phase comparator (KHz) */ 2053 u32 fmem_max = 140000; /* 140MHz max SDRAM freq */ 2054 u32 fdem_min = 66000; 2055 u32 fcp = 0, fs = 0, fdem = 0, fmem = 0; 2056 u32 harmonic_id = 0; 2057 2058 adc->timf = 0; 2059 adc->pll_loopdiv = loopdiv; 2060 adc->pll_prediv = prediv; 2061 2062 deb_info("bandwidth = %d", fe->dtv_property_cache.bandwidth_hz); 2063 2064 /* Find Min and Max prediv */ 2065 while ((xtal / max_prediv) >= fcp_min) 2066 max_prediv++; 2067 2068 max_prediv--; 2069 min_prediv = max_prediv; 2070 while ((xtal / min_prediv) <= fcp_max) { 2071 min_prediv--; 2072 if (min_prediv == 1) 2073 break; 2074 } 2075 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv); 2076 2077 min_prediv = 1; 2078 2079 for (prediv = min_prediv; prediv < max_prediv; prediv++) { 2080 fcp = xtal / prediv; 2081 if (fcp > fcp_min && fcp < fcp_max) { 2082 for (loopdiv = 1; loopdiv < 64; loopdiv++) { 2083 fmem = ((xtal/prediv) * loopdiv); 2084 fdem = fmem / 2; 2085 fs = fdem / 4; 2086 2087 /* test min/max system restrictions */ 2088 if ((fdem >= fdem_min) && (fmem <= fmem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz / 1000)) { 2089 spur = 0; 2090 /* test fs harmonics positions */ 2091 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000 * fs)); harmonic_id <= ((fe->dtv_property_cache.frequency / (1000 * fs)) + 1); harmonic_id++) { 2092 if (((fs * harmonic_id) >= (fe->dtv_property_cache.frequency / 1000 - (fe->dtv_property_cache.bandwidth_hz / 2000))) && ((fs * harmonic_id) <= (fe->dtv_property_cache.frequency / 1000 + (fe->dtv_property_cache.bandwidth_hz / 2000)))) { 2093 spur = 1; 2094 break; 2095 } 2096 } 2097 2098 if (!spur) { 2099 adc->pll_loopdiv = loopdiv; 2100 adc->pll_prediv = prediv; 2101 adc->timf = (4260880253U / fdem) * (1 << 8); 2102 adc->timf += ((4260880253U % fdem) << 8) / fdem; 2103 2104 deb_info("RF %6d; BW %6d; Xtal %6d; Fmem %6d; Fdem %6d; Fs %6d; Prediv %2d; Loopdiv %2d; Timf %8d;", fe->dtv_property_cache.frequency, fe->dtv_property_cache.bandwidth_hz, xtal, fmem, fdem, fs, prediv, loopdiv, adc->timf); 2105 break; 2106 } 2107 } 2108 } 2109 } 2110 if (!spur) 2111 break; 2112 } 2113 2114 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0) 2115 return -EINVAL; 2116 return 0; 2117 } 2118 2119 static int dib8096p_agc_startup(struct dvb_frontend *fe) 2120 { 2121 struct dvb_usb_adapter *adap = fe->dvb->priv; 2122 struct dib0700_adapter_state *state = adap->priv; 2123 struct dibx000_bandwidth_config pll; 2124 struct dibx090p_best_adc adc; 2125 u16 target; 2126 int ret; 2127 2128 ret = state->set_param_save(fe); 2129 if (ret < 0) 2130 return ret; 2131 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config)); 2132 2133 dib0090_pwm_gain_reset(fe); 2134 /* dib0090_get_wbd_target is returning any possible 2135 temperature compensated wbd-target */ 2136 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2; 2137 state->dib8000_ops.set_wbd_ref(fe, target); 2138 2139 if (dib8096p_get_best_sampling(fe, &adc) == 0) { 2140 pll.pll_ratio = adc.pll_loopdiv; 2141 pll.pll_prediv = adc.pll_prediv; 2142 2143 dib0700_set_i2c_speed(adap->dev, 200); 2144 state->dib8000_ops.update_pll(fe, &pll, fe->dtv_property_cache.bandwidth_hz / 1000, 0); 2145 state->dib8000_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf); 2146 dib0700_set_i2c_speed(adap->dev, 1000); 2147 } 2148 return 0; 2149 } 2150 2151 static int tfe8096p_frontend_attach(struct dvb_usb_adapter *adap) 2152 { 2153 struct dib0700_state *st = adap->dev->priv; 2154 u32 fw_version; 2155 struct dib0700_adapter_state *state = adap->priv; 2156 2157 if (!dvb_attach(dib8000_attach, &state->dib8000_ops)) 2158 return -ENODEV; 2159 2160 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL); 2161 if (fw_version >= 0x10200) 2162 st->fw_use_new_i2c_api = 1; 2163 2164 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 2165 msleep(20); 2166 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 2167 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 2168 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 2169 2170 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 2171 2172 dib0700_ctrl_clock(adap->dev, 72, 1); 2173 2174 msleep(20); 2175 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 2176 msleep(20); 2177 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 2178 2179 state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80, 1); 2180 2181 adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 2182 0x80, &tfe8096p_dib8000_config); 2183 2184 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 2185 } 2186 2187 static int tfe8096p_tuner_attach(struct dvb_usb_adapter *adap) 2188 { 2189 struct dib0700_adapter_state *st = adap->priv; 2190 struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_tuner(adap->fe_adap[0].fe); 2191 2192 tfe8096p_dib0090_config.reset = st->dib8000_ops.tuner_sleep; 2193 tfe8096p_dib0090_config.sleep = st->dib8000_ops.tuner_sleep; 2194 tfe8096p_dib0090_config.wbd = dib8096p_wbd_table; 2195 2196 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, 2197 &tfe8096p_dib0090_config) == NULL) 2198 return -ENODEV; 2199 2200 st->dib8000_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 2201 2202 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 2203 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096p_agc_startup; 2204 return 0; 2205 } 2206 2207 /* STK9090M */ 2208 static int dib90x0_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff) 2209 { 2210 return dib9000_fw_pid_filter(adapter->fe_adap[0].fe, index, pid, onoff); 2211 } 2212 2213 static int dib90x0_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff) 2214 { 2215 return dib9000_fw_pid_filter_ctrl(adapter->fe_adap[0].fe, onoff); 2216 } 2217 2218 static int dib90x0_tuner_reset(struct dvb_frontend *fe, int onoff) 2219 { 2220 return dib9000_set_gpio(fe, 5, 0, !onoff); 2221 } 2222 2223 static int dib90x0_tuner_sleep(struct dvb_frontend *fe, int onoff) 2224 { 2225 return dib9000_set_gpio(fe, 0, 0, onoff); 2226 } 2227 2228 static int dib01x0_pmu_update(struct i2c_adapter *i2c, u16 *data, u8 len) 2229 { 2230 u8 wb[4] = { 0xc >> 8, 0xc & 0xff, 0, 0 }; 2231 u8 rb[2]; 2232 struct i2c_msg msg[2] = { 2233 {.addr = 0x1e >> 1, .flags = 0, .buf = wb, .len = 2}, 2234 {.addr = 0x1e >> 1, .flags = I2C_M_RD, .buf = rb, .len = 2}, 2235 }; 2236 u8 index_data; 2237 2238 dibx000_i2c_set_speed(i2c, 250); 2239 2240 if (i2c_transfer(i2c, msg, 2) != 2) 2241 return -EIO; 2242 2243 switch (rb[0] << 8 | rb[1]) { 2244 case 0: 2245 deb_info("Found DiB0170 rev1: This version of DiB0170 is not supported any longer.\n"); 2246 return -EIO; 2247 case 1: 2248 deb_info("Found DiB0170 rev2"); 2249 break; 2250 case 2: 2251 deb_info("Found DiB0190 rev2"); 2252 break; 2253 default: 2254 deb_info("DiB01x0 not found"); 2255 return -EIO; 2256 } 2257 2258 for (index_data = 0; index_data < len; index_data += 2) { 2259 wb[2] = (data[index_data + 1] >> 8) & 0xff; 2260 wb[3] = (data[index_data + 1]) & 0xff; 2261 2262 if (data[index_data] == 0) { 2263 wb[0] = (data[index_data] >> 8) & 0xff; 2264 wb[1] = (data[index_data]) & 0xff; 2265 msg[0].len = 2; 2266 if (i2c_transfer(i2c, msg, 2) != 2) 2267 return -EIO; 2268 wb[2] |= rb[0]; 2269 wb[3] |= rb[1] & ~(3 << 4); 2270 } 2271 2272 wb[0] = (data[index_data] >> 8)&0xff; 2273 wb[1] = (data[index_data])&0xff; 2274 msg[0].len = 4; 2275 if (i2c_transfer(i2c, &msg[0], 1) != 1) 2276 return -EIO; 2277 } 2278 return 0; 2279 } 2280 2281 static struct dib9000_config stk9090m_config = { 2282 .output_mpeg2_in_188_bytes = 1, 2283 .output_mode = OUTMODE_MPEG2_FIFO, 2284 .vcxo_timer = 279620, 2285 .timing_frequency = 20452225, 2286 .demod_clock_khz = 60000, 2287 .xtal_clock_khz = 30000, 2288 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0), 2289 .subband = { 2290 2, 2291 { 2292 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0008 } }, /* GPIO 3 to 1 for VHF */ 2293 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0008, 0x0000, 0x0000 } }, /* GPIO 3 to 0 for UHF */ 2294 { 0 }, 2295 }, 2296 }, 2297 .gpio_function = { 2298 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 }, 2299 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 }, 2300 }, 2301 }; 2302 2303 static struct dib9000_config nim9090md_config[2] = { 2304 { 2305 .output_mpeg2_in_188_bytes = 1, 2306 .output_mode = OUTMODE_MPEG2_FIFO, 2307 .vcxo_timer = 279620, 2308 .timing_frequency = 20452225, 2309 .demod_clock_khz = 60000, 2310 .xtal_clock_khz = 30000, 2311 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0), 2312 }, { 2313 .output_mpeg2_in_188_bytes = 1, 2314 .output_mode = OUTMODE_DIVERSITY, 2315 .vcxo_timer = 279620, 2316 .timing_frequency = 20452225, 2317 .demod_clock_khz = 60000, 2318 .xtal_clock_khz = 30000, 2319 .if_drives = (0 << 15) | (1 << 13) | (0 << 12) | (3 << 10) | (0 << 9) | (1 << 7) | (0 << 6) | (0 << 4) | (1 << 3) | (1 << 1) | (0), 2320 .subband = { 2321 2, 2322 { 2323 { 240, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0006 } }, /* GPIO 1 and 2 to 1 for VHF */ 2324 { 890, { BOARD_GPIO_COMPONENT_DEMOD, BOARD_GPIO_FUNCTION_SUBBAND_GPIO, 0x0006, 0x0000, 0x0000 } }, /* GPIO 1 and 2 to 0 for UHF */ 2325 { 0 }, 2326 }, 2327 }, 2328 .gpio_function = { 2329 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_ON, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = (0x10 & ~0x1) | 0x20 }, 2330 { .component = BOARD_GPIO_COMPONENT_DEMOD, .function = BOARD_GPIO_FUNCTION_COMPONENT_OFF, .mask = 0x10 | 0x21, .direction = 0 & ~0x21, .value = 0 | 0x21 }, 2331 }, 2332 } 2333 }; 2334 2335 static struct dib0090_config dib9090_dib0090_config = { 2336 .io.pll_bypass = 0, 2337 .io.pll_range = 1, 2338 .io.pll_prediv = 1, 2339 .io.pll_loopdiv = 8, 2340 .io.adc_clock_ratio = 8, 2341 .io.pll_int_loop_filt = 0, 2342 .io.clock_khz = 30000, 2343 .reset = dib90x0_tuner_reset, 2344 .sleep = dib90x0_tuner_sleep, 2345 .clkouttobamse = 0, 2346 .analog_output = 0, 2347 .use_pwm_agc = 0, 2348 .clkoutdrive = 0, 2349 .freq_offset_khz_uhf = 0, 2350 .freq_offset_khz_vhf = 0, 2351 }; 2352 2353 static struct dib0090_config nim9090md_dib0090_config[2] = { 2354 { 2355 .io.pll_bypass = 0, 2356 .io.pll_range = 1, 2357 .io.pll_prediv = 1, 2358 .io.pll_loopdiv = 8, 2359 .io.adc_clock_ratio = 8, 2360 .io.pll_int_loop_filt = 0, 2361 .io.clock_khz = 30000, 2362 .reset = dib90x0_tuner_reset, 2363 .sleep = dib90x0_tuner_sleep, 2364 .clkouttobamse = 1, 2365 .analog_output = 0, 2366 .use_pwm_agc = 0, 2367 .clkoutdrive = 0, 2368 .freq_offset_khz_uhf = 0, 2369 .freq_offset_khz_vhf = 0, 2370 }, { 2371 .io.pll_bypass = 0, 2372 .io.pll_range = 1, 2373 .io.pll_prediv = 1, 2374 .io.pll_loopdiv = 8, 2375 .io.adc_clock_ratio = 8, 2376 .io.pll_int_loop_filt = 0, 2377 .io.clock_khz = 30000, 2378 .reset = dib90x0_tuner_reset, 2379 .sleep = dib90x0_tuner_sleep, 2380 .clkouttobamse = 0, 2381 .analog_output = 0, 2382 .use_pwm_agc = 0, 2383 .clkoutdrive = 0, 2384 .freq_offset_khz_uhf = 0, 2385 .freq_offset_khz_vhf = 0, 2386 } 2387 }; 2388 2389 2390 static int stk9090m_frontend_attach(struct dvb_usb_adapter *adap) 2391 { 2392 struct dib0700_adapter_state *state = adap->priv; 2393 struct dib0700_state *st = adap->dev->priv; 2394 u32 fw_version; 2395 2396 /* Make use of the new i2c functions from FW 1.20 */ 2397 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL); 2398 if (fw_version >= 0x10200) 2399 st->fw_use_new_i2c_api = 1; 2400 dib0700_set_i2c_speed(adap->dev, 340); 2401 2402 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 2403 msleep(20); 2404 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 2405 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 2406 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 2407 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 2408 2409 dib0700_ctrl_clock(adap->dev, 72, 1); 2410 2411 msleep(20); 2412 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 2413 msleep(20); 2414 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 2415 2416 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x80); 2417 2418 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) { 2419 deb_info("%s: Upload failed. (file not found?)\n", __func__); 2420 return -ENODEV; 2421 } else { 2422 deb_info("%s: firmware read %zu bytes.\n", __func__, state->frontend_firmware->size); 2423 } 2424 stk9090m_config.microcode_B_fe_size = state->frontend_firmware->size; 2425 stk9090m_config.microcode_B_fe_buffer = state->frontend_firmware->data; 2426 2427 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &stk9090m_config); 2428 2429 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 2430 } 2431 2432 static int dib9090_tuner_attach(struct dvb_usb_adapter *adap) 2433 { 2434 struct dib0700_adapter_state *state = adap->priv; 2435 struct i2c_adapter *i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe); 2436 u16 data_dib190[10] = { 2437 1, 0x1374, 2438 2, 0x01a2, 2439 7, 0x0020, 2440 0, 0x00ef, 2441 8, 0x0486, 2442 }; 2443 2444 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL) 2445 return -ENODEV; 2446 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0); 2447 if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0) 2448 return -ENODEV; 2449 dib0700_set_i2c_speed(adap->dev, 1500); 2450 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0) 2451 return -ENODEV; 2452 release_firmware(state->frontend_firmware); 2453 return 0; 2454 } 2455 2456 static int nim9090md_frontend_attach(struct dvb_usb_adapter *adap) 2457 { 2458 struct dib0700_adapter_state *state = adap->priv; 2459 struct dib0700_state *st = adap->dev->priv; 2460 struct i2c_adapter *i2c; 2461 struct dvb_frontend *fe_slave; 2462 u32 fw_version; 2463 2464 /* Make use of the new i2c functions from FW 1.20 */ 2465 dib0700_get_version(adap->dev, NULL, NULL, &fw_version, NULL); 2466 if (fw_version >= 0x10200) 2467 st->fw_use_new_i2c_api = 1; 2468 dib0700_set_i2c_speed(adap->dev, 340); 2469 2470 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 2471 msleep(20); 2472 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 2473 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 2474 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 2475 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 2476 2477 dib0700_ctrl_clock(adap->dev, 72, 1); 2478 2479 msleep(20); 2480 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 2481 msleep(20); 2482 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 2483 2484 if (request_firmware(&state->frontend_firmware, "dib9090.fw", &adap->dev->udev->dev)) { 2485 deb_info("%s: Upload failed. (file not found?)\n", __func__); 2486 return -EIO; 2487 } else { 2488 deb_info("%s: firmware read %zu bytes.\n", __func__, state->frontend_firmware->size); 2489 } 2490 nim9090md_config[0].microcode_B_fe_size = state->frontend_firmware->size; 2491 nim9090md_config[0].microcode_B_fe_buffer = state->frontend_firmware->data; 2492 nim9090md_config[1].microcode_B_fe_size = state->frontend_firmware->size; 2493 nim9090md_config[1].microcode_B_fe_buffer = state->frontend_firmware->data; 2494 2495 dib9000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, 0x80); 2496 adap->fe_adap[0].fe = dvb_attach(dib9000_attach, &adap->dev->i2c_adap, 0x80, &nim9090md_config[0]); 2497 2498 if (adap->fe_adap[0].fe == NULL) 2499 return -ENODEV; 2500 2501 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_3_4, 0); 2502 dib9000_i2c_enumeration(i2c, 1, 0x12, 0x82); 2503 2504 fe_slave = dvb_attach(dib9000_attach, i2c, 0x82, &nim9090md_config[1]); 2505 dib9000_set_slave_frontend(adap->fe_adap[0].fe, fe_slave); 2506 2507 return fe_slave == NULL ? -ENODEV : 0; 2508 } 2509 2510 static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap) 2511 { 2512 struct dib0700_adapter_state *state = adap->priv; 2513 struct i2c_adapter *i2c; 2514 struct dvb_frontend *fe_slave; 2515 u16 data_dib190[10] = { 2516 1, 0x5374, 2517 2, 0x01ae, 2518 7, 0x0020, 2519 0, 0x00ef, 2520 8, 0x0406, 2521 }; 2522 i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe); 2523 if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL) 2524 return -ENODEV; 2525 i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0); 2526 if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0) 2527 return -ENODEV; 2528 2529 dib0700_set_i2c_speed(adap->dev, 1500); 2530 if (dib9000_firmware_post_pll_init(adap->fe_adap[0].fe) < 0) 2531 return -ENODEV; 2532 2533 fe_slave = dib9000_get_slave_frontend(adap->fe_adap[0].fe, 1); 2534 if (fe_slave != NULL) { 2535 i2c = dib9000_get_component_bus_interface(adap->fe_adap[0].fe); 2536 dib9000_set_i2c_adapter(fe_slave, i2c); 2537 2538 i2c = dib9000_get_tuner_interface(fe_slave); 2539 if (dvb_attach(dib0090_fw_register, fe_slave, i2c, &nim9090md_dib0090_config[1]) == NULL) 2540 return -ENODEV; 2541 fe_slave->dvb = adap->fe_adap[0].fe->dvb; 2542 dib9000_fw_set_component_bus_speed(adap->fe_adap[0].fe, 1500); 2543 if (dib9000_firmware_post_pll_init(fe_slave) < 0) 2544 return -ENODEV; 2545 } 2546 release_firmware(state->frontend_firmware); 2547 2548 return 0; 2549 } 2550 2551 /* NIM7090 */ 2552 static int dib7090p_get_best_sampling(struct dvb_frontend *fe , struct dibx090p_best_adc *adc) 2553 { 2554 u8 spur = 0, prediv = 0, loopdiv = 0, min_prediv = 1, max_prediv = 1; 2555 2556 u16 xtal = 12000; 2557 u32 fcp_min = 1900; /* PLL Minimum Frequency comparator KHz */ 2558 u32 fcp_max = 20000; /* PLL Maximum Frequency comparator KHz */ 2559 u32 fdem_max = 76000; 2560 u32 fdem_min = 69500; 2561 u32 fcp = 0, fs = 0, fdem = 0; 2562 u32 harmonic_id = 0; 2563 2564 adc->pll_loopdiv = loopdiv; 2565 adc->pll_prediv = prediv; 2566 adc->timf = 0; 2567 2568 deb_info("bandwidth = %d fdem_min =%d", fe->dtv_property_cache.bandwidth_hz, fdem_min); 2569 2570 /* Find Min and Max prediv */ 2571 while ((xtal/max_prediv) >= fcp_min) 2572 max_prediv++; 2573 2574 max_prediv--; 2575 min_prediv = max_prediv; 2576 while ((xtal/min_prediv) <= fcp_max) { 2577 min_prediv--; 2578 if (min_prediv == 1) 2579 break; 2580 } 2581 deb_info("MIN prediv = %d : MAX prediv = %d", min_prediv, max_prediv); 2582 2583 min_prediv = 2; 2584 2585 for (prediv = min_prediv ; prediv < max_prediv; prediv++) { 2586 fcp = xtal / prediv; 2587 if (fcp > fcp_min && fcp < fcp_max) { 2588 for (loopdiv = 1 ; loopdiv < 64 ; loopdiv++) { 2589 fdem = ((xtal/prediv) * loopdiv); 2590 fs = fdem / 4; 2591 /* test min/max system restrictions */ 2592 2593 if ((fdem >= fdem_min) && (fdem <= fdem_max) && (fs >= fe->dtv_property_cache.bandwidth_hz/1000)) { 2594 spur = 0; 2595 /* test fs harmonics positions */ 2596 for (harmonic_id = (fe->dtv_property_cache.frequency / (1000*fs)) ; harmonic_id <= ((fe->dtv_property_cache.frequency / (1000*fs))+1) ; harmonic_id++) { 2597 if (((fs*harmonic_id) >= ((fe->dtv_property_cache.frequency/1000) - (fe->dtv_property_cache.bandwidth_hz/2000))) && ((fs*harmonic_id) <= ((fe->dtv_property_cache.frequency/1000) + (fe->dtv_property_cache.bandwidth_hz/2000)))) { 2598 spur = 1; 2599 break; 2600 } 2601 } 2602 2603 if (!spur) { 2604 adc->pll_loopdiv = loopdiv; 2605 adc->pll_prediv = prediv; 2606 adc->timf = 2396745143UL/fdem*(1 << 9); 2607 adc->timf += ((2396745143UL%fdem) << 9)/fdem; 2608 deb_info("loopdiv=%i prediv=%i timf=%i", loopdiv, prediv, adc->timf); 2609 break; 2610 } 2611 } 2612 } 2613 } 2614 if (!spur) 2615 break; 2616 } 2617 2618 2619 if (adc->pll_loopdiv == 0 && adc->pll_prediv == 0) 2620 return -EINVAL; 2621 else 2622 return 0; 2623 } 2624 2625 static int dib7090_agc_startup(struct dvb_frontend *fe) 2626 { 2627 struct dvb_usb_adapter *adap = fe->dvb->priv; 2628 struct dib0700_adapter_state *state = adap->priv; 2629 struct dibx000_bandwidth_config pll; 2630 u16 target; 2631 struct dibx090p_best_adc adc; 2632 int ret; 2633 2634 ret = state->set_param_save(fe); 2635 if (ret < 0) 2636 return ret; 2637 2638 memset(&pll, 0, sizeof(struct dibx000_bandwidth_config)); 2639 dib0090_pwm_gain_reset(fe); 2640 target = (dib0090_get_wbd_target(fe) * 8 + 1) / 2; 2641 state->dib7000p_ops.set_wbd_ref(fe, target); 2642 2643 if (dib7090p_get_best_sampling(fe, &adc) == 0) { 2644 pll.pll_ratio = adc.pll_loopdiv; 2645 pll.pll_prediv = adc.pll_prediv; 2646 2647 state->dib7000p_ops.update_pll(fe, &pll); 2648 state->dib7000p_ops.ctrl_timf(fe, DEMOD_TIMF_SET, adc.timf); 2649 } 2650 return 0; 2651 } 2652 2653 static int dib7090_agc_restart(struct dvb_frontend *fe, u8 restart) 2654 { 2655 deb_info("AGC restart callback: %d", restart); 2656 if (restart == 0) /* before AGC startup */ 2657 dib0090_set_dc_servo(fe, 1); 2658 return 0; 2659 } 2660 2661 static int tfe7790p_update_lna(struct dvb_frontend *fe, u16 agc_global) 2662 { 2663 struct dvb_usb_adapter *adap = fe->dvb->priv; 2664 struct dib0700_adapter_state *state = adap->priv; 2665 2666 deb_info("update LNA: agc global=%i", agc_global); 2667 2668 if (agc_global < 25000) { 2669 state->dib7000p_ops.set_gpio(fe, 8, 0, 0); 2670 state->dib7000p_ops.set_agc1_min(fe, 0); 2671 } else { 2672 state->dib7000p_ops.set_gpio(fe, 8, 0, 1); 2673 state->dib7000p_ops.set_agc1_min(fe, 32768); 2674 } 2675 2676 return 0; 2677 } 2678 2679 static struct dib0090_wbd_slope dib7090_wbd_table[] = { 2680 { 380, 81, 850, 64, 540, 4}, 2681 { 860, 51, 866, 21, 375, 4}, 2682 {1700, 0, 250, 0, 100, 6}, 2683 {2600, 0, 250, 0, 100, 6}, 2684 { 0xFFFF, 0, 0, 0, 0, 0}, 2685 }; 2686 2687 static struct dibx000_agc_config dib7090_agc_config[2] = { 2688 { 2689 .band_caps = BAND_UHF, 2690 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 2691 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ 2692 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 2693 2694 .inv_gain = 687, 2695 .time_stabiliz = 10, 2696 2697 .alpha_level = 0, 2698 .thlock = 118, 2699 2700 .wbd_inv = 0, 2701 .wbd_ref = 1200, 2702 .wbd_sel = 3, 2703 .wbd_alpha = 5, 2704 2705 .agc1_max = 65535, 2706 .agc1_min = 32768, 2707 2708 .agc2_max = 65535, 2709 .agc2_min = 0, 2710 2711 .agc1_pt1 = 0, 2712 .agc1_pt2 = 32, 2713 .agc1_pt3 = 114, 2714 .agc1_slope1 = 143, 2715 .agc1_slope2 = 144, 2716 .agc2_pt1 = 114, 2717 .agc2_pt2 = 227, 2718 .agc2_slope1 = 116, 2719 .agc2_slope2 = 117, 2720 2721 .alpha_mant = 18, 2722 .alpha_exp = 0, 2723 .beta_mant = 20, 2724 .beta_exp = 59, 2725 2726 .perform_agc_softsplit = 0, 2727 } , { 2728 .band_caps = BAND_FM | BAND_VHF | BAND_CBAND, 2729 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 2730 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */ 2731 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 2732 2733 .inv_gain = 732, 2734 .time_stabiliz = 10, 2735 2736 .alpha_level = 0, 2737 .thlock = 118, 2738 2739 .wbd_inv = 0, 2740 .wbd_ref = 1200, 2741 .wbd_sel = 3, 2742 .wbd_alpha = 5, 2743 2744 .agc1_max = 65535, 2745 .agc1_min = 0, 2746 2747 .agc2_max = 65535, 2748 .agc2_min = 0, 2749 2750 .agc1_pt1 = 0, 2751 .agc1_pt2 = 0, 2752 .agc1_pt3 = 98, 2753 .agc1_slope1 = 0, 2754 .agc1_slope2 = 167, 2755 .agc2_pt1 = 98, 2756 .agc2_pt2 = 255, 2757 .agc2_slope1 = 104, 2758 .agc2_slope2 = 0, 2759 2760 .alpha_mant = 18, 2761 .alpha_exp = 0, 2762 .beta_mant = 20, 2763 .beta_exp = 59, 2764 2765 .perform_agc_softsplit = 0, 2766 } 2767 }; 2768 2769 static struct dibx000_bandwidth_config dib7090_clock_config_12_mhz = { 2770 .internal = 60000, 2771 .sampling = 15000, 2772 .pll_prediv = 1, 2773 .pll_ratio = 5, 2774 .pll_range = 0, 2775 .pll_reset = 0, 2776 .pll_bypass = 0, 2777 .enable_refdiv = 0, 2778 .bypclk_div = 0, 2779 .IO_CLK_en_core = 1, 2780 .ADClkSrc = 1, 2781 .modulo = 2, 2782 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 2783 .ifreq = (0 << 25) | 0, 2784 .timf = 20452225, 2785 .xtal_hz = 15000000, 2786 }; 2787 2788 static struct dib7000p_config nim7090_dib7000p_config = { 2789 .output_mpeg2_in_188_bytes = 1, 2790 .hostbus_diversity = 1, 2791 .tuner_is_baseband = 1, 2792 .update_lna = tfe7790p_update_lna, /* GPIO used is the same as TFE7790 */ 2793 2794 .agc_config_count = 2, 2795 .agc = dib7090_agc_config, 2796 2797 .bw = &dib7090_clock_config_12_mhz, 2798 2799 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 2800 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 2801 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 2802 2803 .pwm_freq_div = 0, 2804 2805 .agc_control = dib7090_agc_restart, 2806 2807 .spur_protect = 0, 2808 .disable_sample_and_hold = 0, 2809 .enable_current_mirror = 0, 2810 .diversity_delay = 0, 2811 2812 .output_mode = OUTMODE_MPEG2_FIFO, 2813 .enMpegOutput = 1, 2814 }; 2815 2816 static int tfe7090p_pvr_update_lna(struct dvb_frontend *fe, u16 agc_global) 2817 { 2818 struct dvb_usb_adapter *adap = fe->dvb->priv; 2819 struct dib0700_adapter_state *state = adap->priv; 2820 2821 deb_info("TFE7090P-PVR update LNA: agc global=%i", agc_global); 2822 if (agc_global < 25000) { 2823 state->dib7000p_ops.set_gpio(fe, 5, 0, 0); 2824 state->dib7000p_ops.set_agc1_min(fe, 0); 2825 } else { 2826 state->dib7000p_ops.set_gpio(fe, 5, 0, 1); 2827 state->dib7000p_ops.set_agc1_min(fe, 32768); 2828 } 2829 2830 return 0; 2831 } 2832 2833 static struct dib7000p_config tfe7090pvr_dib7000p_config[2] = { 2834 { 2835 .output_mpeg2_in_188_bytes = 1, 2836 .hostbus_diversity = 1, 2837 .tuner_is_baseband = 1, 2838 .update_lna = tfe7090p_pvr_update_lna, 2839 2840 .agc_config_count = 2, 2841 .agc = dib7090_agc_config, 2842 2843 .bw = &dib7090_clock_config_12_mhz, 2844 2845 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 2846 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 2847 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 2848 2849 .pwm_freq_div = 0, 2850 2851 .agc_control = dib7090_agc_restart, 2852 2853 .spur_protect = 0, 2854 .disable_sample_and_hold = 0, 2855 .enable_current_mirror = 0, 2856 .diversity_delay = 0, 2857 2858 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, 2859 .default_i2c_addr = 0x90, 2860 .enMpegOutput = 1, 2861 }, { 2862 .output_mpeg2_in_188_bytes = 1, 2863 .hostbus_diversity = 1, 2864 .tuner_is_baseband = 1, 2865 .update_lna = tfe7090p_pvr_update_lna, 2866 2867 .agc_config_count = 2, 2868 .agc = dib7090_agc_config, 2869 2870 .bw = &dib7090_clock_config_12_mhz, 2871 2872 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 2873 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 2874 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 2875 2876 .pwm_freq_div = 0, 2877 2878 .agc_control = dib7090_agc_restart, 2879 2880 .spur_protect = 0, 2881 .disable_sample_and_hold = 0, 2882 .enable_current_mirror = 0, 2883 .diversity_delay = 0, 2884 2885 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, 2886 .default_i2c_addr = 0x92, 2887 .enMpegOutput = 0, 2888 } 2889 }; 2890 2891 static struct dib0090_config nim7090_dib0090_config = { 2892 .io.clock_khz = 12000, 2893 .io.pll_bypass = 0, 2894 .io.pll_range = 0, 2895 .io.pll_prediv = 3, 2896 .io.pll_loopdiv = 6, 2897 .io.adc_clock_ratio = 0, 2898 .io.pll_int_loop_filt = 0, 2899 2900 .freq_offset_khz_uhf = 0, 2901 .freq_offset_khz_vhf = 0, 2902 2903 .clkouttobamse = 1, 2904 .analog_output = 0, 2905 2906 .wbd_vhf_offset = 0, 2907 .wbd_cband_offset = 0, 2908 .use_pwm_agc = 1, 2909 .clkoutdrive = 0, 2910 2911 .fref_clock_ratio = 0, 2912 2913 .wbd = dib7090_wbd_table, 2914 2915 .ls_cfg_pad_drv = 0, 2916 .data_tx_drv = 0, 2917 .low_if = NULL, 2918 .in_soc = 1, 2919 }; 2920 2921 static struct dib7000p_config tfe7790p_dib7000p_config = { 2922 .output_mpeg2_in_188_bytes = 1, 2923 .hostbus_diversity = 1, 2924 .tuner_is_baseband = 1, 2925 .update_lna = tfe7790p_update_lna, 2926 2927 .agc_config_count = 2, 2928 .agc = dib7090_agc_config, 2929 2930 .bw = &dib7090_clock_config_12_mhz, 2931 2932 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 2933 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 2934 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 2935 2936 .pwm_freq_div = 0, 2937 2938 .agc_control = dib7090_agc_restart, 2939 2940 .spur_protect = 0, 2941 .disable_sample_and_hold = 0, 2942 .enable_current_mirror = 0, 2943 .diversity_delay = 0, 2944 2945 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, 2946 .enMpegOutput = 1, 2947 }; 2948 2949 static struct dib0090_config tfe7790p_dib0090_config = { 2950 .io.clock_khz = 12000, 2951 .io.pll_bypass = 0, 2952 .io.pll_range = 0, 2953 .io.pll_prediv = 3, 2954 .io.pll_loopdiv = 6, 2955 .io.adc_clock_ratio = 0, 2956 .io.pll_int_loop_filt = 0, 2957 2958 .freq_offset_khz_uhf = 0, 2959 .freq_offset_khz_vhf = 0, 2960 2961 .clkouttobamse = 1, 2962 .analog_output = 0, 2963 2964 .wbd_vhf_offset = 0, 2965 .wbd_cband_offset = 0, 2966 .use_pwm_agc = 1, 2967 .clkoutdrive = 0, 2968 2969 .fref_clock_ratio = 0, 2970 2971 .wbd = dib7090_wbd_table, 2972 2973 .ls_cfg_pad_drv = 0, 2974 .data_tx_drv = 0, 2975 .low_if = NULL, 2976 .in_soc = 1, 2977 .force_cband_input = 0, 2978 .is_dib7090e = 0, 2979 .force_crystal_mode = 1, 2980 }; 2981 2982 static struct dib0090_config tfe7090pvr_dib0090_config[2] = { 2983 { 2984 .io.clock_khz = 12000, 2985 .io.pll_bypass = 0, 2986 .io.pll_range = 0, 2987 .io.pll_prediv = 3, 2988 .io.pll_loopdiv = 6, 2989 .io.adc_clock_ratio = 0, 2990 .io.pll_int_loop_filt = 0, 2991 2992 .freq_offset_khz_uhf = 50, 2993 .freq_offset_khz_vhf = 70, 2994 2995 .clkouttobamse = 1, 2996 .analog_output = 0, 2997 2998 .wbd_vhf_offset = 0, 2999 .wbd_cband_offset = 0, 3000 .use_pwm_agc = 1, 3001 .clkoutdrive = 0, 3002 3003 .fref_clock_ratio = 0, 3004 3005 .wbd = dib7090_wbd_table, 3006 3007 .ls_cfg_pad_drv = 0, 3008 .data_tx_drv = 0, 3009 .low_if = NULL, 3010 .in_soc = 1, 3011 }, { 3012 .io.clock_khz = 12000, 3013 .io.pll_bypass = 0, 3014 .io.pll_range = 0, 3015 .io.pll_prediv = 3, 3016 .io.pll_loopdiv = 6, 3017 .io.adc_clock_ratio = 0, 3018 .io.pll_int_loop_filt = 0, 3019 3020 .freq_offset_khz_uhf = -50, 3021 .freq_offset_khz_vhf = -70, 3022 3023 .clkouttobamse = 1, 3024 .analog_output = 0, 3025 3026 .wbd_vhf_offset = 0, 3027 .wbd_cband_offset = 0, 3028 .use_pwm_agc = 1, 3029 .clkoutdrive = 0, 3030 3031 .fref_clock_ratio = 0, 3032 3033 .wbd = dib7090_wbd_table, 3034 3035 .ls_cfg_pad_drv = 0, 3036 .data_tx_drv = 0, 3037 .low_if = NULL, 3038 .in_soc = 1, 3039 } 3040 }; 3041 3042 static int nim7090_frontend_attach(struct dvb_usb_adapter *adap) 3043 { 3044 struct dib0700_adapter_state *state = adap->priv; 3045 3046 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3047 return -ENODEV; 3048 3049 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3050 msleep(20); 3051 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 3052 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 3053 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 3054 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3055 3056 msleep(20); 3057 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3058 msleep(20); 3059 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 3060 3061 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, &nim7090_dib7000p_config) != 0) { 3062 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__); 3063 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3064 return -ENODEV; 3065 } 3066 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &nim7090_dib7000p_config); 3067 3068 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3069 } 3070 3071 static int nim7090_tuner_attach(struct dvb_usb_adapter *adap) 3072 { 3073 struct dib0700_adapter_state *st = adap->priv; 3074 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe); 3075 3076 nim7090_dib0090_config.reset = st->dib7000p_ops.tuner_sleep, 3077 nim7090_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep, 3078 nim7090_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power; 3079 3080 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &nim7090_dib0090_config) == NULL) 3081 return -ENODEV; 3082 3083 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 3084 3085 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 3086 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup; 3087 return 0; 3088 } 3089 3090 static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap) 3091 { 3092 struct dib0700_state *st = adap->dev->priv; 3093 struct dib0700_adapter_state *state = adap->priv; 3094 3095 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3096 return -ENODEV; 3097 3098 /* The TFE7090 requires the dib0700 to not be in master mode */ 3099 st->disable_streaming_master_mode = 1; 3100 3101 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3102 msleep(20); 3103 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 3104 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 3105 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 3106 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3107 3108 msleep(20); 3109 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3110 msleep(20); 3111 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 3112 3113 /* initialize IC 0 */ 3114 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x20, &tfe7090pvr_dib7000p_config[0]) != 0) { 3115 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__); 3116 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3117 return -ENODEV; 3118 } 3119 3120 dib0700_set_i2c_speed(adap->dev, 340); 3121 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]); 3122 if (adap->fe_adap[0].fe == NULL) 3123 return -ENODEV; 3124 3125 state->dib7000p_ops.slave_reset(adap->fe_adap[0].fe); 3126 3127 return 0; 3128 } 3129 3130 static int tfe7090pvr_frontend1_attach(struct dvb_usb_adapter *adap) 3131 { 3132 struct i2c_adapter *i2c; 3133 struct dib0700_adapter_state *state = adap->priv; 3134 3135 if (adap->dev->adapter[0].fe_adap[0].fe == NULL) { 3136 err("the master dib7090 has to be initialized first"); 3137 return -ENODEV; /* the master device has not been initialized */ 3138 } 3139 3140 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3141 return -ENODEV; 3142 3143 i2c = state->dib7000p_ops.get_i2c_master(adap->dev->adapter[0].fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_6_7, 1); 3144 if (state->dib7000p_ops.i2c_enumeration(i2c, 1, 0x10, &tfe7090pvr_dib7000p_config[1]) != 0) { 3145 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", __func__); 3146 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3147 return -ENODEV; 3148 } 3149 3150 adap->fe_adap[0].fe = state->dib7000p_ops.init(i2c, 0x92, &tfe7090pvr_dib7000p_config[1]); 3151 dib0700_set_i2c_speed(adap->dev, 200); 3152 3153 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3154 } 3155 3156 static int tfe7090pvr_tuner0_attach(struct dvb_usb_adapter *adap) 3157 { 3158 struct dib0700_adapter_state *st = adap->priv; 3159 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe); 3160 3161 tfe7090pvr_dib0090_config[0].reset = st->dib7000p_ops.tuner_sleep; 3162 tfe7090pvr_dib0090_config[0].sleep = st->dib7000p_ops.tuner_sleep; 3163 tfe7090pvr_dib0090_config[0].get_adc_power = st->dib7000p_ops.get_adc_power; 3164 3165 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[0]) == NULL) 3166 return -ENODEV; 3167 3168 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 3169 3170 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 3171 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup; 3172 return 0; 3173 } 3174 3175 static int tfe7090pvr_tuner1_attach(struct dvb_usb_adapter *adap) 3176 { 3177 struct dib0700_adapter_state *st = adap->priv; 3178 struct i2c_adapter *tun_i2c = st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe); 3179 3180 tfe7090pvr_dib0090_config[1].reset = st->dib7000p_ops.tuner_sleep; 3181 tfe7090pvr_dib0090_config[1].sleep = st->dib7000p_ops.tuner_sleep; 3182 tfe7090pvr_dib0090_config[1].get_adc_power = st->dib7000p_ops.get_adc_power; 3183 3184 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &tfe7090pvr_dib0090_config[1]) == NULL) 3185 return -ENODEV; 3186 3187 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 3188 3189 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 3190 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup; 3191 return 0; 3192 } 3193 3194 static int tfe7790p_frontend_attach(struct dvb_usb_adapter *adap) 3195 { 3196 struct dib0700_state *st = adap->dev->priv; 3197 struct dib0700_adapter_state *state = adap->priv; 3198 3199 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3200 return -ENODEV; 3201 3202 /* The TFE7790P requires the dib0700 to not be in master mode */ 3203 st->disable_streaming_master_mode = 1; 3204 3205 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3206 msleep(20); 3207 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 3208 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 3209 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 3210 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3211 msleep(20); 3212 dib0700_ctrl_clock(adap->dev, 72, 1); 3213 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3214 msleep(20); 3215 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 3216 3217 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 3218 1, 0x10, &tfe7790p_dib7000p_config) != 0) { 3219 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", 3220 __func__); 3221 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3222 return -ENODEV; 3223 } 3224 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 3225 0x80, &tfe7790p_dib7000p_config); 3226 3227 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3228 } 3229 3230 static int tfe7790p_tuner_attach(struct dvb_usb_adapter *adap) 3231 { 3232 struct dib0700_adapter_state *st = adap->priv; 3233 struct i2c_adapter *tun_i2c = 3234 st->dib7000p_ops.get_i2c_tuner(adap->fe_adap[0].fe); 3235 3236 3237 tfe7790p_dib0090_config.reset = st->dib7000p_ops.tuner_sleep; 3238 tfe7790p_dib0090_config.sleep = st->dib7000p_ops.tuner_sleep; 3239 tfe7790p_dib0090_config.get_adc_power = st->dib7000p_ops.get_adc_power; 3240 3241 if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, 3242 &tfe7790p_dib0090_config) == NULL) 3243 return -ENODEV; 3244 3245 st->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 3246 3247 st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; 3248 adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib7090_agc_startup; 3249 return 0; 3250 } 3251 3252 /* STK7070PD */ 3253 static struct dib7000p_config stk7070pd_dib7000p_config[2] = { 3254 { 3255 .output_mpeg2_in_188_bytes = 1, 3256 3257 .agc_config_count = 1, 3258 .agc = &dib7070_agc_config, 3259 .bw = &dib7070_bw_config_12_mhz, 3260 .tuner_is_baseband = 1, 3261 .spur_protect = 1, 3262 3263 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 3264 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 3265 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 3266 3267 .hostbus_diversity = 1, 3268 }, { 3269 .output_mpeg2_in_188_bytes = 1, 3270 3271 .agc_config_count = 1, 3272 .agc = &dib7070_agc_config, 3273 .bw = &dib7070_bw_config_12_mhz, 3274 .tuner_is_baseband = 1, 3275 .spur_protect = 1, 3276 3277 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 3278 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 3279 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 3280 3281 .hostbus_diversity = 1, 3282 } 3283 }; 3284 3285 static void stk7070pd_init(struct dvb_usb_device *dev) 3286 { 3287 dib0700_set_gpio(dev, GPIO6, GPIO_OUT, 1); 3288 msleep(10); 3289 dib0700_set_gpio(dev, GPIO9, GPIO_OUT, 1); 3290 dib0700_set_gpio(dev, GPIO4, GPIO_OUT, 1); 3291 dib0700_set_gpio(dev, GPIO7, GPIO_OUT, 1); 3292 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 0); 3293 3294 dib0700_ctrl_clock(dev, 72, 1); 3295 3296 msleep(10); 3297 dib0700_set_gpio(dev, GPIO10, GPIO_OUT, 1); 3298 } 3299 3300 static int stk7070pd_frontend_attach0(struct dvb_usb_adapter *adap) 3301 { 3302 struct dib0700_adapter_state *state = adap->priv; 3303 3304 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3305 return -ENODEV; 3306 3307 stk7070pd_init(adap->dev); 3308 3309 msleep(10); 3310 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 3311 3312 if (state->dib7000p_ops.i2c_enumeration(&adap->dev->i2c_adap, 2, 18, 3313 stk7070pd_dib7000p_config) != 0) { 3314 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", 3315 __func__); 3316 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3317 return -ENODEV; 3318 } 3319 3320 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x80, &stk7070pd_dib7000p_config[0]); 3321 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3322 } 3323 3324 static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap) 3325 { 3326 struct dib0700_adapter_state *state = adap->priv; 3327 3328 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3329 return -ENODEV; 3330 3331 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x82, &stk7070pd_dib7000p_config[1]); 3332 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3333 } 3334 3335 static int novatd_read_status_override(struct dvb_frontend *fe, 3336 enum fe_status *stat) 3337 { 3338 struct dvb_usb_adapter *adap = fe->dvb->priv; 3339 struct dvb_usb_device *dev = adap->dev; 3340 struct dib0700_state *state = dev->priv; 3341 int ret; 3342 3343 ret = state->read_status(fe, stat); 3344 3345 if (!ret) 3346 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 3347 !!(*stat & FE_HAS_LOCK)); 3348 3349 return ret; 3350 } 3351 3352 static int novatd_sleep_override(struct dvb_frontend* fe) 3353 { 3354 struct dvb_usb_adapter *adap = fe->dvb->priv; 3355 struct dvb_usb_device *dev = adap->dev; 3356 struct dib0700_state *state = dev->priv; 3357 3358 /* turn off LED */ 3359 dib0700_set_gpio(dev, adap->id == 0 ? GPIO1 : GPIO0, GPIO_OUT, 0); 3360 3361 return state->sleep(fe); 3362 } 3363 3364 /* 3365 * novatd_frontend_attach - Nova-TD specific attach 3366 * 3367 * Nova-TD has GPIO0, 1 and 2 for LEDs. So do not fiddle with them except for 3368 * information purposes. 3369 */ 3370 static int novatd_frontend_attach(struct dvb_usb_adapter *adap) 3371 { 3372 struct dvb_usb_device *dev = adap->dev; 3373 struct dib0700_state *st = dev->priv; 3374 struct dib0700_adapter_state *state = adap->priv; 3375 3376 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3377 return -ENODEV; 3378 3379 if (adap->id == 0) { 3380 stk7070pd_init(dev); 3381 3382 /* turn the power LED on, the other two off (just in case) */ 3383 dib0700_set_gpio(dev, GPIO0, GPIO_OUT, 0); 3384 dib0700_set_gpio(dev, GPIO1, GPIO_OUT, 0); 3385 dib0700_set_gpio(dev, GPIO2, GPIO_OUT, 1); 3386 3387 if (state->dib7000p_ops.i2c_enumeration(&dev->i2c_adap, 2, 18, 3388 stk7070pd_dib7000p_config) != 0) { 3389 err("%s: state->dib7000p_ops.i2c_enumeration failed. Cannot continue\n", 3390 __func__); 3391 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3392 return -ENODEV; 3393 } 3394 } 3395 3396 adap->fe_adap[0].fe = state->dib7000p_ops.init(&dev->i2c_adap, 3397 adap->id == 0 ? 0x80 : 0x82, 3398 &stk7070pd_dib7000p_config[adap->id]); 3399 3400 if (adap->fe_adap[0].fe == NULL) 3401 return -ENODEV; 3402 3403 st->read_status = adap->fe_adap[0].fe->ops.read_status; 3404 adap->fe_adap[0].fe->ops.read_status = novatd_read_status_override; 3405 st->sleep = adap->fe_adap[0].fe->ops.sleep; 3406 adap->fe_adap[0].fe->ops.sleep = novatd_sleep_override; 3407 3408 return 0; 3409 } 3410 3411 /* S5H1411 */ 3412 static struct s5h1411_config pinnacle_801e_config = { 3413 .output_mode = S5H1411_PARALLEL_OUTPUT, 3414 .gpio = S5H1411_GPIO_OFF, 3415 .mpeg_timing = S5H1411_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK, 3416 .qam_if = S5H1411_IF_44000, 3417 .vsb_if = S5H1411_IF_44000, 3418 .inversion = S5H1411_INVERSION_OFF, 3419 .status_mode = S5H1411_DEMODLOCKING 3420 }; 3421 3422 /* Pinnacle PCTV HD Pro 801e GPIOs map: 3423 GPIO0 - currently unknown 3424 GPIO1 - xc5000 tuner reset 3425 GPIO2 - CX25843 sleep 3426 GPIO3 - currently unknown 3427 GPIO4 - currently unknown 3428 GPIO6 - currently unknown 3429 GPIO7 - currently unknown 3430 GPIO9 - currently unknown 3431 GPIO10 - CX25843 reset 3432 */ 3433 static int s5h1411_frontend_attach(struct dvb_usb_adapter *adap) 3434 { 3435 struct dib0700_state *st = adap->dev->priv; 3436 3437 /* Make use of the new i2c functions from FW 1.20 */ 3438 st->fw_use_new_i2c_api = 1; 3439 3440 /* The s5h1411 requires the dib0700 to not be in master mode */ 3441 st->disable_streaming_master_mode = 1; 3442 3443 /* All msleep values taken from Windows USB trace */ 3444 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 0); 3445 dib0700_set_gpio(adap->dev, GPIO3, GPIO_OUT, 0); 3446 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3447 msleep(400); 3448 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3449 msleep(60); 3450 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3451 msleep(30); 3452 dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); 3453 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 3454 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 3455 dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); 3456 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 0); 3457 msleep(30); 3458 3459 /* Put the CX25843 to sleep for now since we're in digital mode */ 3460 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1); 3461 3462 /* GPIOs are initialized, do the attach */ 3463 adap->fe_adap[0].fe = dvb_attach(s5h1411_attach, &pinnacle_801e_config, 3464 &adap->dev->i2c_adap); 3465 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3466 } 3467 3468 static int dib0700_xc5000_tuner_callback(void *priv, int component, 3469 int command, int arg) 3470 { 3471 struct dvb_usb_adapter *adap = priv; 3472 3473 if (command == XC5000_TUNER_RESET) { 3474 /* Reset the tuner */ 3475 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 0); 3476 msleep(10); 3477 dib0700_set_gpio(adap->dev, GPIO1, GPIO_OUT, 1); 3478 msleep(10); 3479 } else { 3480 err("xc5000: unknown tuner callback command: %d\n", command); 3481 return -EINVAL; 3482 } 3483 3484 return 0; 3485 } 3486 3487 static struct xc5000_config s5h1411_xc5000_tunerconfig = { 3488 .i2c_address = 0x64, 3489 .if_khz = 5380, 3490 }; 3491 3492 static int xc5000_tuner_attach(struct dvb_usb_adapter *adap) 3493 { 3494 /* FIXME: generalize & move to common area */ 3495 adap->fe_adap[0].fe->callback = dib0700_xc5000_tuner_callback; 3496 3497 return dvb_attach(xc5000_attach, adap->fe_adap[0].fe, &adap->dev->i2c_adap, 3498 &s5h1411_xc5000_tunerconfig) 3499 == NULL ? -ENODEV : 0; 3500 } 3501 3502 static int dib0700_xc4000_tuner_callback(void *priv, int component, 3503 int command, int arg) 3504 { 3505 struct dvb_usb_adapter *adap = priv; 3506 struct dib0700_adapter_state *state = adap->priv; 3507 3508 if (command == XC4000_TUNER_RESET) { 3509 /* Reset the tuner */ 3510 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 0); 3511 msleep(10); 3512 state->dib7000p_ops.set_gpio(adap->fe_adap[0].fe, 8, 0, 1); 3513 } else { 3514 err("xc4000: unknown tuner callback command: %d\n", command); 3515 return -EINVAL; 3516 } 3517 3518 return 0; 3519 } 3520 3521 static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = { 3522 .band_caps = BAND_UHF | BAND_VHF, 3523 .setup = 0x64, 3524 .inv_gain = 0x02c8, 3525 .time_stabiliz = 0x15, 3526 .alpha_level = 0x00, 3527 .thlock = 0x76, 3528 .wbd_inv = 0x01, 3529 .wbd_ref = 0x0b33, 3530 .wbd_sel = 0x00, 3531 .wbd_alpha = 0x02, 3532 .agc1_max = 0x00, 3533 .agc1_min = 0x00, 3534 .agc2_max = 0x9b26, 3535 .agc2_min = 0x26ca, 3536 .agc1_pt1 = 0x00, 3537 .agc1_pt2 = 0x00, 3538 .agc1_pt3 = 0x00, 3539 .agc1_slope1 = 0x00, 3540 .agc1_slope2 = 0x00, 3541 .agc2_pt1 = 0x00, 3542 .agc2_pt2 = 0x80, 3543 .agc2_slope1 = 0x1d, 3544 .agc2_slope2 = 0x1d, 3545 .alpha_mant = 0x11, 3546 .alpha_exp = 0x1b, 3547 .beta_mant = 0x17, 3548 .beta_exp = 0x33, 3549 .perform_agc_softsplit = 0x00, 3550 }; 3551 3552 static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = { 3553 .internal = 60000, 3554 .sampling = 30000, 3555 .pll_prediv = 1, 3556 .pll_ratio = 8, 3557 .pll_range = 3, 3558 .pll_reset = 1, 3559 .pll_bypass = 0, 3560 .enable_refdiv = 0, 3561 .bypclk_div = 0, 3562 .IO_CLK_en_core = 1, 3563 .ADClkSrc = 1, 3564 .modulo = 0, 3565 .sad_cfg = (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */ 3566 .ifreq = 39370534, 3567 .timf = 20452225, 3568 .xtal_hz = 30000000 3569 }; 3570 3571 /* FIXME: none of these inputs are validated yet */ 3572 static struct dib7000p_config pctv_340e_config = { 3573 .output_mpeg2_in_188_bytes = 1, 3574 3575 .agc_config_count = 1, 3576 .agc = &stk7700p_7000p_xc4000_agc_config, 3577 .bw = &stk7700p_xc4000_pll_config, 3578 3579 .gpio_dir = DIB7000M_GPIO_DEFAULT_DIRECTIONS, 3580 .gpio_val = DIB7000M_GPIO_DEFAULT_VALUES, 3581 .gpio_pwm_pos = DIB7000M_GPIO_DEFAULT_PWM_POS, 3582 }; 3583 3584 /* PCTV 340e GPIOs map: 3585 dib0700: 3586 GPIO2 - CX25843 sleep 3587 GPIO3 - CS5340 reset 3588 GPIO5 - IRD 3589 GPIO6 - Power Supply 3590 GPIO8 - LNA (1=off 0=on) 3591 GPIO10 - CX25843 reset 3592 dib7000: 3593 GPIO8 - xc4000 reset 3594 */ 3595 static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap) 3596 { 3597 struct dib0700_state *st = adap->dev->priv; 3598 struct dib0700_adapter_state *state = adap->priv; 3599 3600 if (!dvb_attach(dib7000p_attach, &state->dib7000p_ops)) 3601 return -ENODEV; 3602 3603 /* Power Supply on */ 3604 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 3605 msleep(50); 3606 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3607 msleep(100); /* Allow power supply to settle before probing */ 3608 3609 /* cx25843 reset */ 3610 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3611 msleep(1); /* cx25843 datasheet say 350us required */ 3612 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3613 3614 /* LNA off for now */ 3615 dib0700_set_gpio(adap->dev, GPIO8, GPIO_OUT, 1); 3616 3617 /* Put the CX25843 to sleep for now since we're in digital mode */ 3618 dib0700_set_gpio(adap->dev, GPIO2, GPIO_OUT, 1); 3619 3620 /* FIXME: not verified yet */ 3621 dib0700_ctrl_clock(adap->dev, 72, 1); 3622 3623 msleep(500); 3624 3625 if (state->dib7000p_ops.dib7000pc_detection(&adap->dev->i2c_adap) == 0) { 3626 /* Demodulator not found for some reason? */ 3627 dvb_detach(state->dib7000p_ops.set_wbd_ref); 3628 return -ENODEV; 3629 } 3630 3631 adap->fe_adap[0].fe = state->dib7000p_ops.init(&adap->dev->i2c_adap, 0x12, 3632 &pctv_340e_config); 3633 st->is_dib7000pc = 1; 3634 3635 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3636 } 3637 3638 static struct xc4000_config dib7000p_xc4000_tunerconfig = { 3639 .i2c_address = 0x61, 3640 .default_pm = 1, 3641 .dvb_amplitude = 0, 3642 .set_smoothedcvbs = 0, 3643 .if_khz = 5400 3644 }; 3645 3646 static int xc4000_tuner_attach(struct dvb_usb_adapter *adap) 3647 { 3648 struct i2c_adapter *tun_i2c; 3649 struct dib0700_adapter_state *state = adap->priv; 3650 3651 /* The xc4000 is not on the main i2c bus */ 3652 tun_i2c = state->dib7000p_ops.get_i2c_master(adap->fe_adap[0].fe, 3653 DIBX000_I2C_INTERFACE_TUNER, 1); 3654 if (tun_i2c == NULL) { 3655 printk(KERN_ERR "Could not reach tuner i2c bus\n"); 3656 return 0; 3657 } 3658 3659 /* Setup the reset callback */ 3660 adap->fe_adap[0].fe->callback = dib0700_xc4000_tuner_callback; 3661 3662 return dvb_attach(xc4000_attach, adap->fe_adap[0].fe, tun_i2c, 3663 &dib7000p_xc4000_tunerconfig) 3664 == NULL ? -ENODEV : 0; 3665 } 3666 3667 static struct lgdt3305_config hcw_lgdt3305_config = { 3668 .i2c_addr = 0x0e, 3669 .mpeg_mode = LGDT3305_MPEG_PARALLEL, 3670 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, 3671 .tpvalid_polarity = LGDT3305_TP_VALID_LOW, 3672 .deny_i2c_rptr = 0, 3673 .spectral_inversion = 1, 3674 .qam_if_khz = 6000, 3675 .vsb_if_khz = 6000, 3676 .usref_8vsb = 0x0500, 3677 }; 3678 3679 static struct mxl5007t_config hcw_mxl5007t_config = { 3680 .xtal_freq_hz = MxL_XTAL_25_MHZ, 3681 .if_freq_hz = MxL_IF_6_MHZ, 3682 .invert_if = 1, 3683 }; 3684 3685 /* TIGER-ATSC map: 3686 GPIO0 - LNA_CTR (H: LNA power enabled, L: LNA power disabled) 3687 GPIO1 - ANT_SEL (H: VPA, L: MCX) 3688 GPIO4 - SCL2 3689 GPIO6 - EN_TUNER 3690 GPIO7 - SDA2 3691 GPIO10 - DEM_RST 3692 3693 MXL is behind LG's i2c repeater. LG is on SCL2/SDA2 gpios on the DIB 3694 */ 3695 static int lgdt3305_frontend_attach(struct dvb_usb_adapter *adap) 3696 { 3697 struct dib0700_state *st = adap->dev->priv; 3698 3699 /* Make use of the new i2c functions from FW 1.20 */ 3700 st->fw_use_new_i2c_api = 1; 3701 3702 st->disable_streaming_master_mode = 1; 3703 3704 /* fe power enable */ 3705 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 3706 msleep(30); 3707 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3708 msleep(30); 3709 3710 /* demod reset */ 3711 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3712 msleep(30); 3713 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3714 msleep(30); 3715 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3716 msleep(30); 3717 3718 adap->fe_adap[0].fe = dvb_attach(lgdt3305_attach, 3719 &hcw_lgdt3305_config, 3720 &adap->dev->i2c_adap); 3721 3722 return adap->fe_adap[0].fe == NULL ? -ENODEV : 0; 3723 } 3724 3725 static int mxl5007t_tuner_attach(struct dvb_usb_adapter *adap) 3726 { 3727 return dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe, 3728 &adap->dev->i2c_adap, 0x60, 3729 &hcw_mxl5007t_config) == NULL ? -ENODEV : 0; 3730 } 3731 3732 static int xbox_one_attach(struct dvb_usb_adapter *adap) 3733 { 3734 struct dib0700_state *st = adap->dev->priv; 3735 struct i2c_client *client_demod, *client_tuner; 3736 struct dvb_usb_device *d = adap->dev; 3737 struct mn88472_config mn88472_config = { }; 3738 struct tda18250_config tda18250_config; 3739 struct i2c_board_info info; 3740 3741 st->fw_use_new_i2c_api = 1; 3742 st->disable_streaming_master_mode = 1; 3743 3744 /* fe power enable */ 3745 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 3746 msleep(30); 3747 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 3748 msleep(30); 3749 3750 /* demod reset */ 3751 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3752 msleep(30); 3753 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); 3754 msleep(30); 3755 dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); 3756 msleep(30); 3757 3758 /* attach demod */ 3759 mn88472_config.fe = &adap->fe_adap[0].fe; 3760 mn88472_config.i2c_wr_max = 22; 3761 mn88472_config.xtal = 20500000; 3762 mn88472_config.ts_mode = PARALLEL_TS_MODE; 3763 mn88472_config.ts_clock = FIXED_TS_CLOCK; 3764 memset(&info, 0, sizeof(struct i2c_board_info)); 3765 strlcpy(info.type, "mn88472", I2C_NAME_SIZE); 3766 info.addr = 0x18; 3767 info.platform_data = &mn88472_config; 3768 request_module(info.type); 3769 client_demod = i2c_new_device(&d->i2c_adap, &info); 3770 if (client_demod == NULL || client_demod->dev.driver == NULL) 3771 goto fail_demod_device; 3772 if (!try_module_get(client_demod->dev.driver->owner)) 3773 goto fail_demod_module; 3774 3775 st->i2c_client_demod = client_demod; 3776 3777 adap->fe_adap[0].fe = mn88472_config.get_dvb_frontend(client_demod); 3778 3779 /* attach tuner */ 3780 memset(&tda18250_config, 0, sizeof(tda18250_config)); 3781 tda18250_config.if_dvbt_6 = 3950; 3782 tda18250_config.if_dvbt_7 = 4450; 3783 tda18250_config.if_dvbt_8 = 4950; 3784 tda18250_config.if_dvbc_6 = 4950; 3785 tda18250_config.if_dvbc_8 = 4950; 3786 tda18250_config.if_atsc = 4079; 3787 tda18250_config.loopthrough = true; 3788 tda18250_config.xtal_freq = TDA18250_XTAL_FREQ_27MHZ; 3789 tda18250_config.fe = adap->fe_adap[0].fe; 3790 3791 memset(&info, 0, sizeof(struct i2c_board_info)); 3792 strlcpy(info.type, "tda18250", I2C_NAME_SIZE); 3793 info.addr = 0x60; 3794 info.platform_data = &tda18250_config; 3795 3796 request_module(info.type); 3797 client_tuner = i2c_new_device(&adap->dev->i2c_adap, &info); 3798 if (client_tuner == NULL || client_tuner->dev.driver == NULL) 3799 goto fail_tuner_device; 3800 if (!try_module_get(client_tuner->dev.driver->owner)) 3801 goto fail_tuner_module; 3802 3803 st->i2c_client_tuner = client_tuner; 3804 return 0; 3805 3806 fail_tuner_module: 3807 i2c_unregister_device(client_tuner); 3808 fail_tuner_device: 3809 module_put(client_demod->dev.driver->owner); 3810 fail_demod_module: 3811 i2c_unregister_device(client_demod); 3812 fail_demod_device: 3813 return -ENODEV; 3814 } 3815 3816 3817 /* DVB-USB and USB stuff follows */ 3818 struct usb_device_id dib0700_usb_id_table[] = { 3819 /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) }, 3820 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) }, 3821 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) }, 3822 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) }, 3823 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) }, 3824 /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) }, 3825 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) }, 3826 { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) }, 3827 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) }, 3828 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) }, 3829 /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) }, 3830 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) }, 3831 { USB_DEVICE(USB_VID_TERRATEC, 3832 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) }, 3833 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) }, 3834 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) }, 3835 /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) }, 3836 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) }, 3837 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) }, 3838 { USB_DEVICE(USB_VID_PINNACLE, 3839 USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) }, 3840 { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) }, 3841 /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) }, 3842 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) }, 3843 { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) }, 3844 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) }, 3845 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) }, 3846 /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) }, 3847 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) }, 3848 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) }, 3849 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) }, 3850 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) }, 3851 /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) }, 3852 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) }, 3853 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) }, 3854 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) }, 3855 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) }, 3856 /* 35 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK_52009) }, 3857 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_3) }, 3858 { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U8000) }, 3859 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700PH) }, 3860 { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000H) }, 3861 /* 40 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E) }, 3862 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV801E_SE) }, 3863 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_EXPRESS) }, 3864 { USB_DEVICE(USB_VID_TERRATEC, 3865 USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2) }, 3866 { USB_DEVICE(USB_VID_SONY, USB_PID_SONY_PLAYTV) }, 3867 /* 45 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_PD378S) }, 3868 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC) }, 3869 { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_TIGER_ATSC_B210) }, 3870 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_MC770) }, 3871 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT) }, 3872 /* 50 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_Dlx) }, 3873 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) }, 3874 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) }, 3875 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) }, 3876 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) }, 3877 /* 55 */{ USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) }, 3878 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73A) }, 3879 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV73ESE) }, 3880 { USB_DEVICE(USB_VID_PCTV, USB_PID_PINNACLE_PCTV282E) }, 3881 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7770P) }, 3882 /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) }, 3883 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XPVR) }, 3884 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK807XP) }, 3885 { USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x000, 0x3f00) }, 3886 { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) }, 3887 /* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) }, 3888 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV282E) }, 3889 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096GP) }, 3890 { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DIVERSITY) }, 3891 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090M) }, 3892 /* 70 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM8096MD) }, 3893 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM9090MD) }, 3894 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_NIM7090) }, 3895 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7090PVR) }, 3896 { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_AIRSTAR_TELESTICK_2) }, 3897 /* 75 */{ USB_DEVICE(USB_VID_MEDION, USB_PID_CREATIX_CTX1921) }, 3898 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E) }, 3899 { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV340E_SE) }, 3900 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE7790P) }, 3901 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_TFE8096P) }, 3902 /* 80 */{ USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_DTT_2) }, 3903 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E) }, 3904 { USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_2002E_SE) }, 3905 { USB_DEVICE(USB_VID_PCTV, USB_PID_DIBCOM_STK8096PVR) }, 3906 { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK8096PVR) }, 3907 /* 85 */{ USB_DEVICE(USB_VID_HAMA, USB_PID_HAMA_DVBT_HYBRID) }, 3908 { USB_DEVICE(USB_VID_MICROSOFT, USB_PID_XBOX_ONE_TUNER) }, 3909 { 0 } /* Terminating entry */ 3910 }; 3911 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 3912 3913 #define DIB0700_DEFAULT_DEVICE_PROPERTIES \ 3914 .caps = DVB_USB_IS_AN_I2C_ADAPTER, \ 3915 .usb_ctrl = DEVICE_SPECIFIC, \ 3916 .firmware = "dvb-usb-dib0700-1.20.fw", \ 3917 .download_firmware = dib0700_download_firmware, \ 3918 .no_reconnect = 1, \ 3919 .size_of_priv = sizeof(struct dib0700_state), \ 3920 .i2c_algo = &dib0700_i2c_algo, \ 3921 .identify_state = dib0700_identify_state 3922 3923 #define DIB0700_DEFAULT_STREAMING_CONFIG(ep) \ 3924 .streaming_ctrl = dib0700_streaming_ctrl, \ 3925 .stream = { \ 3926 .type = USB_BULK, \ 3927 .count = 4, \ 3928 .endpoint = ep, \ 3929 .u = { \ 3930 .bulk = { \ 3931 .buffersize = 39480, \ 3932 } \ 3933 } \ 3934 } 3935 3936 #define DIB0700_NUM_FRONTENDS(n) \ 3937 .num_frontends = n, \ 3938 .size_of_priv = sizeof(struct dib0700_adapter_state) 3939 3940 struct dvb_usb_device_properties dib0700_devices[] = { 3941 { 3942 DIB0700_DEFAULT_DEVICE_PROPERTIES, 3943 3944 .num_adapters = 1, 3945 .adapter = { 3946 { 3947 DIB0700_NUM_FRONTENDS(1), 3948 .fe = {{ 3949 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 3950 .pid_filter_count = 32, 3951 .pid_filter = stk7700p_pid_filter, 3952 .pid_filter_ctrl = stk7700p_pid_filter_ctrl, 3953 .frontend_attach = stk7700p_frontend_attach, 3954 .tuner_attach = stk7700p_tuner_attach, 3955 3956 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 3957 }}, 3958 }, 3959 }, 3960 3961 .num_device_descs = 8, 3962 .devices = { 3963 { "DiBcom STK7700P reference design", 3964 { &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] }, 3965 { NULL }, 3966 }, 3967 { "Hauppauge Nova-T Stick", 3968 { &dib0700_usb_id_table[4], &dib0700_usb_id_table[9], NULL }, 3969 { NULL }, 3970 }, 3971 { "AVerMedia AVerTV DVB-T Volar", 3972 { &dib0700_usb_id_table[5], &dib0700_usb_id_table[10] }, 3973 { NULL }, 3974 }, 3975 { "Compro Videomate U500", 3976 { &dib0700_usb_id_table[6], &dib0700_usb_id_table[19] }, 3977 { NULL }, 3978 }, 3979 { "Uniwill STK7700P based (Hama and others)", 3980 { &dib0700_usb_id_table[7], NULL }, 3981 { NULL }, 3982 }, 3983 { "Leadtek Winfast DTV Dongle (STK7700P based)", 3984 { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] }, 3985 { NULL }, 3986 }, 3987 { "AVerMedia AVerTV DVB-T Express", 3988 { &dib0700_usb_id_table[20] }, 3989 { NULL }, 3990 }, 3991 { "Gigabyte U7000", 3992 { &dib0700_usb_id_table[21], NULL }, 3993 { NULL }, 3994 } 3995 }, 3996 3997 .rc.core = { 3998 .rc_interval = DEFAULT_RC_INTERVAL, 3999 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4000 .rc_query = dib0700_rc_query_old_firmware, 4001 .allowed_protos = RC_PROTO_BIT_RC5 | 4002 RC_PROTO_BIT_RC6_MCE | 4003 RC_PROTO_BIT_NEC, 4004 .change_protocol = dib0700_change_protocol, 4005 }, 4006 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4007 4008 .num_adapters = 2, 4009 .adapter = { 4010 { 4011 DIB0700_NUM_FRONTENDS(1), 4012 .fe = {{ 4013 .frontend_attach = bristol_frontend_attach, 4014 .tuner_attach = bristol_tuner_attach, 4015 4016 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4017 }}, 4018 }, { 4019 DIB0700_NUM_FRONTENDS(1), 4020 .fe = {{ 4021 .frontend_attach = bristol_frontend_attach, 4022 .tuner_attach = bristol_tuner_attach, 4023 4024 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4025 }}, 4026 } 4027 }, 4028 4029 .num_device_descs = 1, 4030 .devices = { 4031 { "Hauppauge Nova-T 500 Dual DVB-T", 4032 { &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL }, 4033 { NULL }, 4034 }, 4035 }, 4036 4037 .rc.core = { 4038 .rc_interval = DEFAULT_RC_INTERVAL, 4039 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4040 .rc_query = dib0700_rc_query_old_firmware, 4041 .allowed_protos = RC_PROTO_BIT_RC5 | 4042 RC_PROTO_BIT_RC6_MCE | 4043 RC_PROTO_BIT_NEC, 4044 .change_protocol = dib0700_change_protocol, 4045 }, 4046 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4047 4048 .num_adapters = 2, 4049 .adapter = { 4050 { 4051 DIB0700_NUM_FRONTENDS(1), 4052 .fe = {{ 4053 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4054 .pid_filter_count = 32, 4055 .pid_filter = stk70x0p_pid_filter, 4056 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4057 .frontend_attach = stk7700d_frontend_attach, 4058 .tuner_attach = stk7700d_tuner_attach, 4059 4060 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4061 }}, 4062 }, { 4063 DIB0700_NUM_FRONTENDS(1), 4064 .fe = {{ 4065 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4066 .pid_filter_count = 32, 4067 .pid_filter = stk70x0p_pid_filter, 4068 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4069 .frontend_attach = stk7700d_frontend_attach, 4070 .tuner_attach = stk7700d_tuner_attach, 4071 4072 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4073 }}, 4074 } 4075 }, 4076 4077 .num_device_descs = 5, 4078 .devices = { 4079 { "Pinnacle PCTV 2000e", 4080 { &dib0700_usb_id_table[11], NULL }, 4081 { NULL }, 4082 }, 4083 { "Terratec Cinergy DT XS Diversity", 4084 { &dib0700_usb_id_table[12], NULL }, 4085 { NULL }, 4086 }, 4087 { "Hauppauge Nova-TD Stick/Elgato Eye-TV Diversity", 4088 { &dib0700_usb_id_table[13], NULL }, 4089 { NULL }, 4090 }, 4091 { "DiBcom STK7700D reference design", 4092 { &dib0700_usb_id_table[14], NULL }, 4093 { NULL }, 4094 }, 4095 { "YUAN High-Tech DiBcom STK7700D", 4096 { &dib0700_usb_id_table[55], NULL }, 4097 { NULL }, 4098 }, 4099 4100 }, 4101 4102 .rc.core = { 4103 .rc_interval = DEFAULT_RC_INTERVAL, 4104 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4105 .rc_query = dib0700_rc_query_old_firmware, 4106 .allowed_protos = RC_PROTO_BIT_RC5 | 4107 RC_PROTO_BIT_RC6_MCE | 4108 RC_PROTO_BIT_NEC, 4109 .change_protocol = dib0700_change_protocol, 4110 }, 4111 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4112 4113 .num_adapters = 1, 4114 .adapter = { 4115 { 4116 DIB0700_NUM_FRONTENDS(1), 4117 .fe = {{ 4118 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4119 .pid_filter_count = 32, 4120 .pid_filter = stk70x0p_pid_filter, 4121 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4122 .frontend_attach = stk7700P2_frontend_attach, 4123 .tuner_attach = stk7700d_tuner_attach, 4124 4125 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4126 }}, 4127 }, 4128 }, 4129 4130 .num_device_descs = 3, 4131 .devices = { 4132 { "ASUS My Cinema U3000 Mini DVBT Tuner", 4133 { &dib0700_usb_id_table[23], NULL }, 4134 { NULL }, 4135 }, 4136 { "Yuan EC372S", 4137 { &dib0700_usb_id_table[31], NULL }, 4138 { NULL }, 4139 }, 4140 { "Terratec Cinergy T Express", 4141 { &dib0700_usb_id_table[42], NULL }, 4142 { NULL }, 4143 } 4144 }, 4145 4146 .rc.core = { 4147 .rc_interval = DEFAULT_RC_INTERVAL, 4148 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4149 .module_name = "dib0700", 4150 .rc_query = dib0700_rc_query_old_firmware, 4151 .allowed_protos = RC_PROTO_BIT_RC5 | 4152 RC_PROTO_BIT_RC6_MCE | 4153 RC_PROTO_BIT_NEC, 4154 .change_protocol = dib0700_change_protocol, 4155 }, 4156 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4157 4158 .num_adapters = 1, 4159 .adapter = { 4160 { 4161 DIB0700_NUM_FRONTENDS(1), 4162 .fe = {{ 4163 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4164 .pid_filter_count = 32, 4165 .pid_filter = stk70x0p_pid_filter, 4166 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4167 .frontend_attach = stk7070p_frontend_attach, 4168 .tuner_attach = dib7070p_tuner_attach, 4169 4170 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4171 }}, 4172 }, 4173 }, 4174 4175 .num_device_descs = 12, 4176 .devices = { 4177 { "DiBcom STK7070P reference design", 4178 { &dib0700_usb_id_table[15], NULL }, 4179 { NULL }, 4180 }, 4181 { "Pinnacle PCTV DVB-T Flash Stick", 4182 { &dib0700_usb_id_table[16], NULL }, 4183 { NULL }, 4184 }, 4185 { "Artec T14BR DVB-T", 4186 { &dib0700_usb_id_table[22], NULL }, 4187 { NULL }, 4188 }, 4189 { "ASUS My Cinema U3100 Mini DVBT Tuner", 4190 { &dib0700_usb_id_table[24], NULL }, 4191 { NULL }, 4192 }, 4193 { "Hauppauge Nova-T Stick", 4194 { &dib0700_usb_id_table[25], NULL }, 4195 { NULL }, 4196 }, 4197 { "Hauppauge Nova-T MyTV.t", 4198 { &dib0700_usb_id_table[26], NULL }, 4199 { NULL }, 4200 }, 4201 { "Pinnacle PCTV 72e", 4202 { &dib0700_usb_id_table[29], NULL }, 4203 { NULL }, 4204 }, 4205 { "Pinnacle PCTV 73e", 4206 { &dib0700_usb_id_table[30], NULL }, 4207 { NULL }, 4208 }, 4209 { "Elgato EyeTV DTT", 4210 { &dib0700_usb_id_table[49], NULL }, 4211 { NULL }, 4212 }, 4213 { "Yuan PD378S", 4214 { &dib0700_usb_id_table[45], NULL }, 4215 { NULL }, 4216 }, 4217 { "Elgato EyeTV Dtt Dlx PD378S", 4218 { &dib0700_usb_id_table[50], NULL }, 4219 { NULL }, 4220 }, 4221 { "Elgato EyeTV DTT rev. 2", 4222 { &dib0700_usb_id_table[80], NULL }, 4223 { NULL }, 4224 }, 4225 }, 4226 4227 .rc.core = { 4228 .rc_interval = DEFAULT_RC_INTERVAL, 4229 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4230 .module_name = "dib0700", 4231 .rc_query = dib0700_rc_query_old_firmware, 4232 .allowed_protos = RC_PROTO_BIT_RC5 | 4233 RC_PROTO_BIT_RC6_MCE | 4234 RC_PROTO_BIT_NEC, 4235 .change_protocol = dib0700_change_protocol, 4236 }, 4237 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4238 4239 .num_adapters = 1, 4240 .adapter = { 4241 { 4242 DIB0700_NUM_FRONTENDS(1), 4243 .fe = {{ 4244 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4245 .pid_filter_count = 32, 4246 .pid_filter = stk70x0p_pid_filter, 4247 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4248 .frontend_attach = stk7070p_frontend_attach, 4249 .tuner_attach = dib7070p_tuner_attach, 4250 4251 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4252 }}, 4253 }, 4254 }, 4255 4256 .num_device_descs = 3, 4257 .devices = { 4258 { "Pinnacle PCTV 73A", 4259 { &dib0700_usb_id_table[56], NULL }, 4260 { NULL }, 4261 }, 4262 { "Pinnacle PCTV 73e SE", 4263 { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL }, 4264 { NULL }, 4265 }, 4266 { "Pinnacle PCTV 282e", 4267 { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL }, 4268 { NULL }, 4269 }, 4270 }, 4271 4272 .rc.core = { 4273 .rc_interval = DEFAULT_RC_INTERVAL, 4274 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4275 .module_name = "dib0700", 4276 .rc_query = dib0700_rc_query_old_firmware, 4277 .allowed_protos = RC_PROTO_BIT_RC5 | 4278 RC_PROTO_BIT_RC6_MCE | 4279 RC_PROTO_BIT_NEC, 4280 .change_protocol = dib0700_change_protocol, 4281 }, 4282 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4283 4284 .num_adapters = 2, 4285 .adapter = { 4286 { 4287 DIB0700_NUM_FRONTENDS(1), 4288 .fe = {{ 4289 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4290 .pid_filter_count = 32, 4291 .pid_filter = stk70x0p_pid_filter, 4292 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4293 .frontend_attach = novatd_frontend_attach, 4294 .tuner_attach = dib7070p_tuner_attach, 4295 4296 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4297 }}, 4298 }, { 4299 DIB0700_NUM_FRONTENDS(1), 4300 .fe = {{ 4301 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4302 .pid_filter_count = 32, 4303 .pid_filter = stk70x0p_pid_filter, 4304 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4305 .frontend_attach = novatd_frontend_attach, 4306 .tuner_attach = dib7070p_tuner_attach, 4307 4308 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4309 }}, 4310 } 4311 }, 4312 4313 .num_device_descs = 3, 4314 .devices = { 4315 { "Hauppauge Nova-TD Stick (52009)", 4316 { &dib0700_usb_id_table[35], NULL }, 4317 { NULL }, 4318 }, 4319 { "PCTV 2002e", 4320 { &dib0700_usb_id_table[81], NULL }, 4321 { NULL }, 4322 }, 4323 { "PCTV 2002e SE", 4324 { &dib0700_usb_id_table[82], NULL }, 4325 { NULL }, 4326 }, 4327 }, 4328 4329 .rc.core = { 4330 .rc_interval = DEFAULT_RC_INTERVAL, 4331 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4332 .module_name = "dib0700", 4333 .rc_query = dib0700_rc_query_old_firmware, 4334 .allowed_protos = RC_PROTO_BIT_RC5 | 4335 RC_PROTO_BIT_RC6_MCE | 4336 RC_PROTO_BIT_NEC, 4337 .change_protocol = dib0700_change_protocol, 4338 }, 4339 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4340 4341 .num_adapters = 2, 4342 .adapter = { 4343 { 4344 DIB0700_NUM_FRONTENDS(1), 4345 .fe = {{ 4346 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4347 .pid_filter_count = 32, 4348 .pid_filter = stk70x0p_pid_filter, 4349 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4350 .frontend_attach = stk7070pd_frontend_attach0, 4351 .tuner_attach = dib7070p_tuner_attach, 4352 4353 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4354 }}, 4355 }, { 4356 DIB0700_NUM_FRONTENDS(1), 4357 .fe = {{ 4358 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4359 .pid_filter_count = 32, 4360 .pid_filter = stk70x0p_pid_filter, 4361 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4362 .frontend_attach = stk7070pd_frontend_attach1, 4363 .tuner_attach = dib7070p_tuner_attach, 4364 4365 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4366 }}, 4367 } 4368 }, 4369 4370 .num_device_descs = 5, 4371 .devices = { 4372 { "DiBcom STK7070PD reference design", 4373 { &dib0700_usb_id_table[17], NULL }, 4374 { NULL }, 4375 }, 4376 { "Pinnacle PCTV Dual DVB-T Diversity Stick", 4377 { &dib0700_usb_id_table[18], NULL }, 4378 { NULL }, 4379 }, 4380 { "Hauppauge Nova-TD-500 (84xxx)", 4381 { &dib0700_usb_id_table[36], NULL }, 4382 { NULL }, 4383 }, 4384 { "Terratec Cinergy DT USB XS Diversity/ T5", 4385 { &dib0700_usb_id_table[43], 4386 &dib0700_usb_id_table[53], NULL}, 4387 { NULL }, 4388 }, 4389 { "Sony PlayTV", 4390 { &dib0700_usb_id_table[44], NULL }, 4391 { NULL }, 4392 }, 4393 }, 4394 4395 .rc.core = { 4396 .rc_interval = DEFAULT_RC_INTERVAL, 4397 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4398 .module_name = "dib0700", 4399 .rc_query = dib0700_rc_query_old_firmware, 4400 .allowed_protos = RC_PROTO_BIT_RC5 | 4401 RC_PROTO_BIT_RC6_MCE | 4402 RC_PROTO_BIT_NEC, 4403 .change_protocol = dib0700_change_protocol, 4404 }, 4405 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4406 4407 .num_adapters = 2, 4408 .adapter = { 4409 { 4410 DIB0700_NUM_FRONTENDS(1), 4411 .fe = {{ 4412 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4413 .pid_filter_count = 32, 4414 .pid_filter = stk70x0p_pid_filter, 4415 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4416 .frontend_attach = stk7070pd_frontend_attach0, 4417 .tuner_attach = dib7070p_tuner_attach, 4418 4419 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4420 }}, 4421 }, { 4422 DIB0700_NUM_FRONTENDS(1), 4423 .fe = {{ 4424 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4425 .pid_filter_count = 32, 4426 .pid_filter = stk70x0p_pid_filter, 4427 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4428 .frontend_attach = stk7070pd_frontend_attach1, 4429 .tuner_attach = dib7070p_tuner_attach, 4430 4431 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4432 }}, 4433 } 4434 }, 4435 4436 .num_device_descs = 1, 4437 .devices = { 4438 { "Elgato EyeTV Diversity", 4439 { &dib0700_usb_id_table[68], NULL }, 4440 { NULL }, 4441 }, 4442 }, 4443 4444 .rc.core = { 4445 .rc_interval = DEFAULT_RC_INTERVAL, 4446 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 4447 .module_name = "dib0700", 4448 .rc_query = dib0700_rc_query_old_firmware, 4449 .allowed_protos = RC_PROTO_BIT_RC5 | 4450 RC_PROTO_BIT_RC6_MCE | 4451 RC_PROTO_BIT_NEC, 4452 .change_protocol = dib0700_change_protocol, 4453 }, 4454 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4455 4456 .num_adapters = 1, 4457 .adapter = { 4458 { 4459 DIB0700_NUM_FRONTENDS(1), 4460 .fe = {{ 4461 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4462 .pid_filter_count = 32, 4463 .pid_filter = stk70x0p_pid_filter, 4464 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4465 .frontend_attach = stk7700ph_frontend_attach, 4466 .tuner_attach = stk7700ph_tuner_attach, 4467 4468 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4469 }}, 4470 }, 4471 }, 4472 4473 .num_device_descs = 10, 4474 .devices = { 4475 { "Terratec Cinergy HT USB XE", 4476 { &dib0700_usb_id_table[27], NULL }, 4477 { NULL }, 4478 }, 4479 { "Pinnacle Expresscard 320cx", 4480 { &dib0700_usb_id_table[28], NULL }, 4481 { NULL }, 4482 }, 4483 { "Terratec Cinergy HT Express", 4484 { &dib0700_usb_id_table[32], NULL }, 4485 { NULL }, 4486 }, 4487 { "Gigabyte U8000-RH", 4488 { &dib0700_usb_id_table[37], NULL }, 4489 { NULL }, 4490 }, 4491 { "YUAN High-Tech STK7700PH", 4492 { &dib0700_usb_id_table[38], NULL }, 4493 { NULL }, 4494 }, 4495 { "Asus My Cinema-U3000Hybrid", 4496 { &dib0700_usb_id_table[39], NULL }, 4497 { NULL }, 4498 }, 4499 { "YUAN High-Tech MC770", 4500 { &dib0700_usb_id_table[48], NULL }, 4501 { NULL }, 4502 }, 4503 { "Leadtek WinFast DTV Dongle H", 4504 { &dib0700_usb_id_table[51], NULL }, 4505 { NULL }, 4506 }, 4507 { "YUAN High-Tech STK7700D", 4508 { &dib0700_usb_id_table[54], NULL }, 4509 { NULL }, 4510 }, 4511 { "Hama DVB=T Hybrid USB Stick", 4512 { &dib0700_usb_id_table[85], NULL }, 4513 { NULL }, 4514 }, 4515 }, 4516 4517 .rc.core = { 4518 .rc_interval = DEFAULT_RC_INTERVAL, 4519 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4520 .module_name = "dib0700", 4521 .rc_query = dib0700_rc_query_old_firmware, 4522 .allowed_protos = RC_PROTO_BIT_RC5 | 4523 RC_PROTO_BIT_RC6_MCE | 4524 RC_PROTO_BIT_NEC, 4525 .change_protocol = dib0700_change_protocol, 4526 }, 4527 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4528 .num_adapters = 1, 4529 .adapter = { 4530 { 4531 DIB0700_NUM_FRONTENDS(1), 4532 .fe = {{ 4533 .frontend_attach = s5h1411_frontend_attach, 4534 .tuner_attach = xc5000_tuner_attach, 4535 4536 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4537 }}, 4538 }, 4539 }, 4540 4541 .num_device_descs = 2, 4542 .devices = { 4543 { "Pinnacle PCTV HD Pro USB Stick", 4544 { &dib0700_usb_id_table[40], NULL }, 4545 { NULL }, 4546 }, 4547 { "Pinnacle PCTV HD USB Stick", 4548 { &dib0700_usb_id_table[41], NULL }, 4549 { NULL }, 4550 }, 4551 }, 4552 4553 .rc.core = { 4554 .rc_interval = DEFAULT_RC_INTERVAL, 4555 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4556 .module_name = "dib0700", 4557 .rc_query = dib0700_rc_query_old_firmware, 4558 .allowed_protos = RC_PROTO_BIT_RC5 | 4559 RC_PROTO_BIT_RC6_MCE | 4560 RC_PROTO_BIT_NEC, 4561 .change_protocol = dib0700_change_protocol, 4562 }, 4563 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4564 .num_adapters = 1, 4565 .adapter = { 4566 { 4567 DIB0700_NUM_FRONTENDS(1), 4568 .fe = {{ 4569 .frontend_attach = lgdt3305_frontend_attach, 4570 .tuner_attach = mxl5007t_tuner_attach, 4571 4572 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4573 }}, 4574 }, 4575 }, 4576 4577 .num_device_descs = 2, 4578 .devices = { 4579 { "Hauppauge ATSC MiniCard (B200)", 4580 { &dib0700_usb_id_table[46], NULL }, 4581 { NULL }, 4582 }, 4583 { "Hauppauge ATSC MiniCard (B210)", 4584 { &dib0700_usb_id_table[47], NULL }, 4585 { NULL }, 4586 }, 4587 }, 4588 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4589 4590 .num_adapters = 1, 4591 .adapter = { 4592 { 4593 DIB0700_NUM_FRONTENDS(1), 4594 .fe = {{ 4595 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4596 .pid_filter_count = 32, 4597 .pid_filter = stk70x0p_pid_filter, 4598 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4599 .frontend_attach = stk7770p_frontend_attach, 4600 .tuner_attach = dib7770p_tuner_attach, 4601 4602 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4603 }}, 4604 }, 4605 }, 4606 4607 .num_device_descs = 4, 4608 .devices = { 4609 { "DiBcom STK7770P reference design", 4610 { &dib0700_usb_id_table[59], NULL }, 4611 { NULL }, 4612 }, 4613 { "Terratec Cinergy T USB XXS (HD)/ T3", 4614 { &dib0700_usb_id_table[33], 4615 &dib0700_usb_id_table[52], 4616 &dib0700_usb_id_table[60], NULL}, 4617 { NULL }, 4618 }, 4619 { "TechniSat AirStar TeleStick 2", 4620 { &dib0700_usb_id_table[74], NULL }, 4621 { NULL }, 4622 }, 4623 { "Medion CTX1921 DVB-T USB", 4624 { &dib0700_usb_id_table[75], NULL }, 4625 { NULL }, 4626 }, 4627 }, 4628 4629 .rc.core = { 4630 .rc_interval = DEFAULT_RC_INTERVAL, 4631 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4632 .module_name = "dib0700", 4633 .rc_query = dib0700_rc_query_old_firmware, 4634 .allowed_protos = RC_PROTO_BIT_RC5 | 4635 RC_PROTO_BIT_RC6_MCE | 4636 RC_PROTO_BIT_NEC, 4637 .change_protocol = dib0700_change_protocol, 4638 }, 4639 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4640 .num_adapters = 1, 4641 .adapter = { 4642 { 4643 DIB0700_NUM_FRONTENDS(1), 4644 .fe = {{ 4645 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4646 .pid_filter_count = 32, 4647 .pid_filter = stk80xx_pid_filter, 4648 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 4649 .frontend_attach = stk807x_frontend_attach, 4650 .tuner_attach = dib807x_tuner_attach, 4651 4652 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4653 }}, 4654 }, 4655 }, 4656 4657 .num_device_descs = 3, 4658 .devices = { 4659 { "DiBcom STK807xP reference design", 4660 { &dib0700_usb_id_table[62], NULL }, 4661 { NULL }, 4662 }, 4663 { "Prolink Pixelview SBTVD", 4664 { &dib0700_usb_id_table[63], NULL }, 4665 { NULL }, 4666 }, 4667 { "EvolutePC TVWay+", 4668 { &dib0700_usb_id_table[64], NULL }, 4669 { NULL }, 4670 }, 4671 }, 4672 4673 .rc.core = { 4674 .rc_interval = DEFAULT_RC_INTERVAL, 4675 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 4676 .module_name = "dib0700", 4677 .rc_query = dib0700_rc_query_old_firmware, 4678 .allowed_protos = RC_PROTO_BIT_RC5 | 4679 RC_PROTO_BIT_RC6_MCE | 4680 RC_PROTO_BIT_NEC, 4681 .change_protocol = dib0700_change_protocol, 4682 }, 4683 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4684 .num_adapters = 2, 4685 .adapter = { 4686 { 4687 DIB0700_NUM_FRONTENDS(1), 4688 .fe = {{ 4689 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4690 .pid_filter_count = 32, 4691 .pid_filter = stk80xx_pid_filter, 4692 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 4693 .frontend_attach = stk807xpvr_frontend_attach0, 4694 .tuner_attach = dib807x_tuner_attach, 4695 4696 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4697 }}, 4698 }, 4699 { 4700 DIB0700_NUM_FRONTENDS(1), 4701 .fe = {{ 4702 .caps = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4703 .pid_filter_count = 32, 4704 .pid_filter = stk80xx_pid_filter, 4705 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 4706 .frontend_attach = stk807xpvr_frontend_attach1, 4707 .tuner_attach = dib807x_tuner_attach, 4708 4709 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4710 }}, 4711 }, 4712 }, 4713 4714 .num_device_descs = 1, 4715 .devices = { 4716 { "DiBcom STK807xPVR reference design", 4717 { &dib0700_usb_id_table[61], NULL }, 4718 { NULL }, 4719 }, 4720 }, 4721 4722 .rc.core = { 4723 .rc_interval = DEFAULT_RC_INTERVAL, 4724 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4725 .module_name = "dib0700", 4726 .rc_query = dib0700_rc_query_old_firmware, 4727 .allowed_protos = RC_PROTO_BIT_RC5 | 4728 RC_PROTO_BIT_RC6_MCE | 4729 RC_PROTO_BIT_NEC, 4730 .change_protocol = dib0700_change_protocol, 4731 }, 4732 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4733 .num_adapters = 1, 4734 .adapter = { 4735 { 4736 DIB0700_NUM_FRONTENDS(1), 4737 .fe = {{ 4738 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4739 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4740 .pid_filter_count = 32, 4741 .pid_filter = stk80xx_pid_filter, 4742 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 4743 .frontend_attach = stk809x_frontend_attach, 4744 .tuner_attach = dib809x_tuner_attach, 4745 4746 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4747 }}, 4748 }, 4749 }, 4750 4751 .num_device_descs = 1, 4752 .devices = { 4753 { "DiBcom STK8096GP reference design", 4754 { &dib0700_usb_id_table[67], NULL }, 4755 { NULL }, 4756 }, 4757 }, 4758 4759 .rc.core = { 4760 .rc_interval = DEFAULT_RC_INTERVAL, 4761 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4762 .module_name = "dib0700", 4763 .rc_query = dib0700_rc_query_old_firmware, 4764 .allowed_protos = RC_PROTO_BIT_RC5 | 4765 RC_PROTO_BIT_RC6_MCE | 4766 RC_PROTO_BIT_NEC, 4767 .change_protocol = dib0700_change_protocol, 4768 }, 4769 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4770 .num_adapters = 1, 4771 .adapter = { 4772 { 4773 DIB0700_NUM_FRONTENDS(1), 4774 .fe = {{ 4775 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4776 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4777 .pid_filter_count = 32, 4778 .pid_filter = dib90x0_pid_filter, 4779 .pid_filter_ctrl = dib90x0_pid_filter_ctrl, 4780 .frontend_attach = stk9090m_frontend_attach, 4781 .tuner_attach = dib9090_tuner_attach, 4782 4783 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4784 }}, 4785 }, 4786 }, 4787 4788 .num_device_descs = 1, 4789 .devices = { 4790 { "DiBcom STK9090M reference design", 4791 { &dib0700_usb_id_table[69], NULL }, 4792 { NULL }, 4793 }, 4794 }, 4795 4796 .rc.core = { 4797 .rc_interval = DEFAULT_RC_INTERVAL, 4798 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4799 .module_name = "dib0700", 4800 .rc_query = dib0700_rc_query_old_firmware, 4801 .allowed_protos = RC_PROTO_BIT_RC5 | 4802 RC_PROTO_BIT_RC6_MCE | 4803 RC_PROTO_BIT_NEC, 4804 .change_protocol = dib0700_change_protocol, 4805 }, 4806 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4807 .num_adapters = 1, 4808 .adapter = { 4809 { 4810 DIB0700_NUM_FRONTENDS(1), 4811 .fe = {{ 4812 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4813 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4814 .pid_filter_count = 32, 4815 .pid_filter = stk80xx_pid_filter, 4816 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 4817 .frontend_attach = nim8096md_frontend_attach, 4818 .tuner_attach = nim8096md_tuner_attach, 4819 4820 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4821 }}, 4822 }, 4823 }, 4824 4825 .num_device_descs = 1, 4826 .devices = { 4827 { "DiBcom NIM8096MD reference design", 4828 { &dib0700_usb_id_table[70], NULL }, 4829 { NULL }, 4830 }, 4831 }, 4832 4833 .rc.core = { 4834 .rc_interval = DEFAULT_RC_INTERVAL, 4835 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4836 .module_name = "dib0700", 4837 .rc_query = dib0700_rc_query_old_firmware, 4838 .allowed_protos = RC_PROTO_BIT_RC5 | 4839 RC_PROTO_BIT_RC6_MCE | 4840 RC_PROTO_BIT_NEC, 4841 .change_protocol = dib0700_change_protocol, 4842 }, 4843 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4844 .num_adapters = 1, 4845 .adapter = { 4846 { 4847 DIB0700_NUM_FRONTENDS(1), 4848 .fe = {{ 4849 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4850 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4851 .pid_filter_count = 32, 4852 .pid_filter = dib90x0_pid_filter, 4853 .pid_filter_ctrl = dib90x0_pid_filter_ctrl, 4854 .frontend_attach = nim9090md_frontend_attach, 4855 .tuner_attach = nim9090md_tuner_attach, 4856 4857 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4858 }}, 4859 }, 4860 }, 4861 4862 .num_device_descs = 1, 4863 .devices = { 4864 { "DiBcom NIM9090MD reference design", 4865 { &dib0700_usb_id_table[71], NULL }, 4866 { NULL }, 4867 }, 4868 }, 4869 4870 .rc.core = { 4871 .rc_interval = DEFAULT_RC_INTERVAL, 4872 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4873 .module_name = "dib0700", 4874 .rc_query = dib0700_rc_query_old_firmware, 4875 .allowed_protos = RC_PROTO_BIT_RC5 | 4876 RC_PROTO_BIT_RC6_MCE | 4877 RC_PROTO_BIT_NEC, 4878 .change_protocol = dib0700_change_protocol, 4879 }, 4880 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4881 .num_adapters = 1, 4882 .adapter = { 4883 { 4884 DIB0700_NUM_FRONTENDS(1), 4885 .fe = {{ 4886 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4887 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4888 .pid_filter_count = 32, 4889 .pid_filter = stk70x0p_pid_filter, 4890 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4891 .frontend_attach = nim7090_frontend_attach, 4892 .tuner_attach = nim7090_tuner_attach, 4893 4894 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4895 }}, 4896 }, 4897 }, 4898 4899 .num_device_descs = 1, 4900 .devices = { 4901 { "DiBcom NIM7090 reference design", 4902 { &dib0700_usb_id_table[72], NULL }, 4903 { NULL }, 4904 }, 4905 }, 4906 4907 .rc.core = { 4908 .rc_interval = DEFAULT_RC_INTERVAL, 4909 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4910 .module_name = "dib0700", 4911 .rc_query = dib0700_rc_query_old_firmware, 4912 .allowed_protos = RC_PROTO_BIT_RC5 | 4913 RC_PROTO_BIT_RC6_MCE | 4914 RC_PROTO_BIT_NEC, 4915 .change_protocol = dib0700_change_protocol, 4916 }, 4917 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4918 .num_adapters = 2, 4919 .adapter = { 4920 { 4921 DIB0700_NUM_FRONTENDS(1), 4922 .fe = {{ 4923 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4924 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4925 .pid_filter_count = 32, 4926 .pid_filter = stk70x0p_pid_filter, 4927 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4928 .frontend_attach = tfe7090pvr_frontend0_attach, 4929 .tuner_attach = tfe7090pvr_tuner0_attach, 4930 4931 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 4932 }}, 4933 }, 4934 { 4935 DIB0700_NUM_FRONTENDS(1), 4936 .fe = {{ 4937 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 4938 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 4939 .pid_filter_count = 32, 4940 .pid_filter = stk70x0p_pid_filter, 4941 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 4942 .frontend_attach = tfe7090pvr_frontend1_attach, 4943 .tuner_attach = tfe7090pvr_tuner1_attach, 4944 4945 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4946 }}, 4947 }, 4948 }, 4949 4950 .num_device_descs = 1, 4951 .devices = { 4952 { "DiBcom TFE7090PVR reference design", 4953 { &dib0700_usb_id_table[73], NULL }, 4954 { NULL }, 4955 }, 4956 }, 4957 4958 .rc.core = { 4959 .rc_interval = DEFAULT_RC_INTERVAL, 4960 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4961 .module_name = "dib0700", 4962 .rc_query = dib0700_rc_query_old_firmware, 4963 .allowed_protos = RC_PROTO_BIT_RC5 | 4964 RC_PROTO_BIT_RC6_MCE | 4965 RC_PROTO_BIT_NEC, 4966 .change_protocol = dib0700_change_protocol, 4967 }, 4968 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4969 .num_adapters = 1, 4970 .adapter = { 4971 { 4972 DIB0700_NUM_FRONTENDS(1), 4973 .fe = {{ 4974 .frontend_attach = pctv340e_frontend_attach, 4975 .tuner_attach = xc4000_tuner_attach, 4976 4977 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 4978 }}, 4979 }, 4980 }, 4981 4982 .num_device_descs = 2, 4983 .devices = { 4984 { "Pinnacle PCTV 340e HD Pro USB Stick", 4985 { &dib0700_usb_id_table[76], NULL }, 4986 { NULL }, 4987 }, 4988 { "Pinnacle PCTV Hybrid Stick Solo", 4989 { &dib0700_usb_id_table[77], NULL }, 4990 { NULL }, 4991 }, 4992 }, 4993 .rc.core = { 4994 .rc_interval = DEFAULT_RC_INTERVAL, 4995 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4996 .module_name = "dib0700", 4997 .rc_query = dib0700_rc_query_old_firmware, 4998 .allowed_protos = RC_PROTO_BIT_RC5 | 4999 RC_PROTO_BIT_RC6_MCE | 5000 RC_PROTO_BIT_NEC, 5001 .change_protocol = dib0700_change_protocol, 5002 }, 5003 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 5004 .num_adapters = 1, 5005 .adapter = { 5006 { 5007 DIB0700_NUM_FRONTENDS(1), 5008 .fe = {{ 5009 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 5010 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 5011 .pid_filter_count = 32, 5012 .pid_filter = stk70x0p_pid_filter, 5013 .pid_filter_ctrl = stk70x0p_pid_filter_ctrl, 5014 .frontend_attach = tfe7790p_frontend_attach, 5015 .tuner_attach = tfe7790p_tuner_attach, 5016 5017 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 5018 } }, 5019 }, 5020 }, 5021 5022 .num_device_descs = 1, 5023 .devices = { 5024 { "DiBcom TFE7790P reference design", 5025 { &dib0700_usb_id_table[78], NULL }, 5026 { NULL }, 5027 }, 5028 }, 5029 5030 .rc.core = { 5031 .rc_interval = DEFAULT_RC_INTERVAL, 5032 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 5033 .module_name = "dib0700", 5034 .rc_query = dib0700_rc_query_old_firmware, 5035 .allowed_protos = RC_PROTO_BIT_RC5 | 5036 RC_PROTO_BIT_RC6_MCE | 5037 RC_PROTO_BIT_NEC, 5038 .change_protocol = dib0700_change_protocol, 5039 }, 5040 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 5041 .num_adapters = 1, 5042 .adapter = { 5043 { 5044 DIB0700_NUM_FRONTENDS(1), 5045 .fe = {{ 5046 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 5047 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 5048 .pid_filter_count = 32, 5049 .pid_filter = stk80xx_pid_filter, 5050 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 5051 .frontend_attach = tfe8096p_frontend_attach, 5052 .tuner_attach = tfe8096p_tuner_attach, 5053 5054 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 5055 5056 } }, 5057 }, 5058 }, 5059 5060 .num_device_descs = 1, 5061 .devices = { 5062 { "DiBcom TFE8096P reference design", 5063 { &dib0700_usb_id_table[79], NULL }, 5064 { NULL }, 5065 }, 5066 }, 5067 5068 .rc.core = { 5069 .rc_interval = DEFAULT_RC_INTERVAL, 5070 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 5071 .module_name = "dib0700", 5072 .rc_query = dib0700_rc_query_old_firmware, 5073 .allowed_protos = RC_PROTO_BIT_RC5 | 5074 RC_PROTO_BIT_RC6_MCE | 5075 RC_PROTO_BIT_NEC, 5076 .change_protocol = dib0700_change_protocol, 5077 }, 5078 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 5079 .num_adapters = 2, 5080 .adapter = { 5081 { 5082 .num_frontends = 1, 5083 .fe = {{ 5084 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 5085 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 5086 .pid_filter_count = 32, 5087 .pid_filter = stk80xx_pid_filter, 5088 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 5089 .frontend_attach = stk809x_frontend_attach, 5090 .tuner_attach = dib809x_tuner_attach, 5091 5092 DIB0700_DEFAULT_STREAMING_CONFIG(0x02), 5093 } }, 5094 .size_of_priv = 5095 sizeof(struct dib0700_adapter_state), 5096 }, { 5097 .num_frontends = 1, 5098 .fe = { { 5099 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 5100 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 5101 .pid_filter_count = 32, 5102 .pid_filter = stk80xx_pid_filter, 5103 .pid_filter_ctrl = stk80xx_pid_filter_ctrl, 5104 .frontend_attach = stk809x_frontend1_attach, 5105 .tuner_attach = dib809x_tuner_attach, 5106 5107 DIB0700_DEFAULT_STREAMING_CONFIG(0x03), 5108 } }, 5109 .size_of_priv = 5110 sizeof(struct dib0700_adapter_state), 5111 }, 5112 }, 5113 .num_device_descs = 1, 5114 .devices = { 5115 { "DiBcom STK8096-PVR reference design", 5116 { &dib0700_usb_id_table[83], 5117 &dib0700_usb_id_table[84], NULL}, 5118 { NULL }, 5119 }, 5120 }, 5121 5122 .rc.core = { 5123 .rc_interval = DEFAULT_RC_INTERVAL, 5124 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 5125 .module_name = "dib0700", 5126 .rc_query = dib0700_rc_query_old_firmware, 5127 .allowed_protos = RC_PROTO_BIT_RC5 | 5128 RC_PROTO_BIT_RC6_MCE | 5129 RC_PROTO_BIT_NEC, 5130 .change_protocol = dib0700_change_protocol, 5131 }, 5132 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 5133 .num_adapters = 1, 5134 .adapter = { 5135 { 5136 DIB0700_NUM_FRONTENDS(1), 5137 .fe = {{ 5138 .frontend_attach = xbox_one_attach, 5139 5140 DIB0700_DEFAULT_STREAMING_CONFIG(0x82), 5141 } }, 5142 }, 5143 }, 5144 .num_device_descs = 1, 5145 .devices = { 5146 { "Microsoft Xbox One Digital TV Tuner", 5147 { &dib0700_usb_id_table[86], NULL }, 5148 { NULL }, 5149 }, 5150 }, 5151 }, 5152 }; 5153 5154 int dib0700_device_count = ARRAY_SIZE(dib0700_devices); 5155