1 /* 2 * Driver for the Conexant CX23885 PCIe bridge 3 * 4 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * 15 * GNU General Public License for more details. 16 */ 17 18 #include <linux/module.h> 19 #include <linux/init.h> 20 #include <linux/device.h> 21 #include <linux/fs.h> 22 #include <linux/kthread.h> 23 #include <linux/file.h> 24 #include <linux/suspend.h> 25 26 #include "cx23885.h" 27 #include <media/v4l2-common.h> 28 29 #include "dvb_ca_en50221.h" 30 #include "s5h1409.h" 31 #include "s5h1411.h" 32 #include "mt2131.h" 33 #include "tda8290.h" 34 #include "tda18271.h" 35 #include "lgdt330x.h" 36 #include "xc4000.h" 37 #include "xc5000.h" 38 #include "max2165.h" 39 #include "tda10048.h" 40 #include "tuner-xc2028.h" 41 #include "tuner-simple.h" 42 #include "dib7000p.h" 43 #include "dib0070.h" 44 #include "dibx000_common.h" 45 #include "zl10353.h" 46 #include "stv0900.h" 47 #include "stv0900_reg.h" 48 #include "stv6110.h" 49 #include "lnbh24.h" 50 #include "cx24116.h" 51 #include "cx24117.h" 52 #include "cimax2.h" 53 #include "lgs8gxx.h" 54 #include "netup-eeprom.h" 55 #include "netup-init.h" 56 #include "lgdt3305.h" 57 #include "atbm8830.h" 58 #include "ts2020.h" 59 #include "ds3000.h" 60 #include "cx23885-f300.h" 61 #include "altera-ci.h" 62 #include "stv0367.h" 63 #include "drxk.h" 64 #include "mt2063.h" 65 #include "stv090x.h" 66 #include "stb6100.h" 67 #include "stb6100_cfg.h" 68 #include "tda10071.h" 69 #include "a8293.h" 70 #include "mb86a20s.h" 71 #include "si2165.h" 72 #include "si2168.h" 73 #include "si2157.h" 74 #include "sp2.h" 75 #include "m88ds3103.h" 76 #include "m88rs6000t.h" 77 78 static unsigned int debug; 79 80 #define dprintk(level, fmt, arg...)\ 81 do { if (debug >= level)\ 82 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ 83 } while (0) 84 85 /* ------------------------------------------------------------------ */ 86 87 static unsigned int alt_tuner; 88 module_param(alt_tuner, int, 0644); 89 MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration"); 90 91 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 92 93 /* ------------------------------------------------------------------ */ 94 95 static int queue_setup(struct vb2_queue *q, 96 unsigned int *num_buffers, unsigned int *num_planes, 97 unsigned int sizes[], struct device *alloc_devs[]) 98 { 99 struct cx23885_tsport *port = q->drv_priv; 100 101 port->ts_packet_size = 188 * 4; 102 port->ts_packet_count = 32; 103 *num_planes = 1; 104 sizes[0] = port->ts_packet_size * port->ts_packet_count; 105 *num_buffers = 32; 106 return 0; 107 } 108 109 110 static int buffer_prepare(struct vb2_buffer *vb) 111 { 112 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 113 struct cx23885_tsport *port = vb->vb2_queue->drv_priv; 114 struct cx23885_buffer *buf = 115 container_of(vbuf, struct cx23885_buffer, vb); 116 117 return cx23885_buf_prepare(buf, port); 118 } 119 120 static void buffer_finish(struct vb2_buffer *vb) 121 { 122 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 123 struct cx23885_tsport *port = vb->vb2_queue->drv_priv; 124 struct cx23885_dev *dev = port->dev; 125 struct cx23885_buffer *buf = container_of(vbuf, 126 struct cx23885_buffer, vb); 127 128 cx23885_free_buffer(dev, buf); 129 } 130 131 static void buffer_queue(struct vb2_buffer *vb) 132 { 133 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 134 struct cx23885_tsport *port = vb->vb2_queue->drv_priv; 135 struct cx23885_buffer *buf = container_of(vbuf, 136 struct cx23885_buffer, vb); 137 138 cx23885_buf_queue(port, buf); 139 } 140 141 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open) 142 { 143 struct vb2_dvb_frontends *f; 144 struct vb2_dvb_frontend *fe; 145 146 f = &port->frontends; 147 148 if (f->gate <= 1) /* undefined or fe0 */ 149 fe = vb2_dvb_get_frontend(f, 1); 150 else 151 fe = vb2_dvb_get_frontend(f, f->gate); 152 153 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) 154 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open); 155 } 156 157 static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count) 158 { 159 struct cx23885_tsport *port = q->drv_priv; 160 struct cx23885_dmaqueue *dmaq = &port->mpegq; 161 struct cx23885_buffer *buf = list_entry(dmaq->active.next, 162 struct cx23885_buffer, queue); 163 164 cx23885_start_dma(port, dmaq, buf); 165 return 0; 166 } 167 168 static void cx23885_stop_streaming(struct vb2_queue *q) 169 { 170 struct cx23885_tsport *port = q->drv_priv; 171 172 cx23885_cancel_buffers(port); 173 } 174 175 static struct vb2_ops dvb_qops = { 176 .queue_setup = queue_setup, 177 .buf_prepare = buffer_prepare, 178 .buf_finish = buffer_finish, 179 .buf_queue = buffer_queue, 180 .wait_prepare = vb2_ops_wait_prepare, 181 .wait_finish = vb2_ops_wait_finish, 182 .start_streaming = cx23885_start_streaming, 183 .stop_streaming = cx23885_stop_streaming, 184 }; 185 186 static struct s5h1409_config hauppauge_generic_config = { 187 .demod_address = 0x32 >> 1, 188 .output_mode = S5H1409_SERIAL_OUTPUT, 189 .gpio = S5H1409_GPIO_ON, 190 .qam_if = 44000, 191 .inversion = S5H1409_INVERSION_OFF, 192 .status_mode = S5H1409_DEMODLOCKING, 193 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 194 }; 195 196 static struct tda10048_config hauppauge_hvr1200_config = { 197 .demod_address = 0x10 >> 1, 198 .output_mode = TDA10048_SERIAL_OUTPUT, 199 .fwbulkwritelen = TDA10048_BULKWRITE_200, 200 .inversion = TDA10048_INVERSION_ON, 201 .dtv6_if_freq_khz = TDA10048_IF_3300, 202 .dtv7_if_freq_khz = TDA10048_IF_3800, 203 .dtv8_if_freq_khz = TDA10048_IF_4300, 204 .clk_freq_khz = TDA10048_CLK_16000, 205 }; 206 207 static struct tda10048_config hauppauge_hvr1210_config = { 208 .demod_address = 0x10 >> 1, 209 .output_mode = TDA10048_SERIAL_OUTPUT, 210 .fwbulkwritelen = TDA10048_BULKWRITE_200, 211 .inversion = TDA10048_INVERSION_ON, 212 .dtv6_if_freq_khz = TDA10048_IF_3300, 213 .dtv7_if_freq_khz = TDA10048_IF_3500, 214 .dtv8_if_freq_khz = TDA10048_IF_4000, 215 .clk_freq_khz = TDA10048_CLK_16000, 216 }; 217 218 static struct s5h1409_config hauppauge_ezqam_config = { 219 .demod_address = 0x32 >> 1, 220 .output_mode = S5H1409_SERIAL_OUTPUT, 221 .gpio = S5H1409_GPIO_OFF, 222 .qam_if = 4000, 223 .inversion = S5H1409_INVERSION_ON, 224 .status_mode = S5H1409_DEMODLOCKING, 225 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 226 }; 227 228 static struct s5h1409_config hauppauge_hvr1800lp_config = { 229 .demod_address = 0x32 >> 1, 230 .output_mode = S5H1409_SERIAL_OUTPUT, 231 .gpio = S5H1409_GPIO_OFF, 232 .qam_if = 44000, 233 .inversion = S5H1409_INVERSION_OFF, 234 .status_mode = S5H1409_DEMODLOCKING, 235 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 236 }; 237 238 static struct s5h1409_config hauppauge_hvr1500_config = { 239 .demod_address = 0x32 >> 1, 240 .output_mode = S5H1409_SERIAL_OUTPUT, 241 .gpio = S5H1409_GPIO_OFF, 242 .inversion = S5H1409_INVERSION_OFF, 243 .status_mode = S5H1409_DEMODLOCKING, 244 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 245 }; 246 247 static struct mt2131_config hauppauge_generic_tunerconfig = { 248 0x61 249 }; 250 251 static struct lgdt330x_config fusionhdtv_5_express = { 252 .demod_address = 0x0e, 253 .demod_chip = LGDT3303, 254 .serial_mpeg = 0x40, 255 }; 256 257 static struct s5h1409_config hauppauge_hvr1500q_config = { 258 .demod_address = 0x32 >> 1, 259 .output_mode = S5H1409_SERIAL_OUTPUT, 260 .gpio = S5H1409_GPIO_ON, 261 .qam_if = 44000, 262 .inversion = S5H1409_INVERSION_OFF, 263 .status_mode = S5H1409_DEMODLOCKING, 264 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 265 }; 266 267 static struct s5h1409_config dvico_s5h1409_config = { 268 .demod_address = 0x32 >> 1, 269 .output_mode = S5H1409_SERIAL_OUTPUT, 270 .gpio = S5H1409_GPIO_ON, 271 .qam_if = 44000, 272 .inversion = S5H1409_INVERSION_OFF, 273 .status_mode = S5H1409_DEMODLOCKING, 274 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 275 }; 276 277 static struct s5h1411_config dvico_s5h1411_config = { 278 .output_mode = S5H1411_SERIAL_OUTPUT, 279 .gpio = S5H1411_GPIO_ON, 280 .qam_if = S5H1411_IF_44000, 281 .vsb_if = S5H1411_IF_44000, 282 .inversion = S5H1411_INVERSION_OFF, 283 .status_mode = S5H1411_DEMODLOCKING, 284 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 285 }; 286 287 static struct s5h1411_config hcw_s5h1411_config = { 288 .output_mode = S5H1411_SERIAL_OUTPUT, 289 .gpio = S5H1411_GPIO_OFF, 290 .vsb_if = S5H1411_IF_44000, 291 .qam_if = S5H1411_IF_4000, 292 .inversion = S5H1411_INVERSION_ON, 293 .status_mode = S5H1411_DEMODLOCKING, 294 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, 295 }; 296 297 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { 298 .i2c_address = 0x61, 299 .if_khz = 5380, 300 }; 301 302 static struct xc5000_config dvico_xc5000_tunerconfig = { 303 .i2c_address = 0x64, 304 .if_khz = 5380, 305 }; 306 307 static struct tda829x_config tda829x_no_probe = { 308 .probe_tuner = TDA829X_DONT_PROBE, 309 }; 310 311 static struct tda18271_std_map hauppauge_tda18271_std_map = { 312 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, 313 .if_lvl = 6, .rfagc_top = 0x37 }, 314 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0, 315 .if_lvl = 6, .rfagc_top = 0x37 }, 316 }; 317 318 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = { 319 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4, 320 .if_lvl = 1, .rfagc_top = 0x37, }, 321 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5, 322 .if_lvl = 1, .rfagc_top = 0x37, }, 323 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6, 324 .if_lvl = 1, .rfagc_top = 0x37, }, 325 }; 326 327 static struct tda18271_config hauppauge_tda18271_config = { 328 .std_map = &hauppauge_tda18271_std_map, 329 .gate = TDA18271_GATE_ANALOG, 330 .output_opt = TDA18271_OUTPUT_LT_OFF, 331 }; 332 333 static struct tda18271_config hauppauge_hvr1200_tuner_config = { 334 .std_map = &hauppauge_hvr1200_tda18271_std_map, 335 .gate = TDA18271_GATE_ANALOG, 336 .output_opt = TDA18271_OUTPUT_LT_OFF, 337 }; 338 339 static struct tda18271_config hauppauge_hvr1210_tuner_config = { 340 .gate = TDA18271_GATE_DIGITAL, 341 .output_opt = TDA18271_OUTPUT_LT_OFF, 342 }; 343 344 static struct tda18271_config hauppauge_hvr4400_tuner_config = { 345 .gate = TDA18271_GATE_DIGITAL, 346 .output_opt = TDA18271_OUTPUT_LT_OFF, 347 }; 348 349 static struct tda18271_std_map hauppauge_hvr127x_std_map = { 350 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4, 351 .if_lvl = 1, .rfagc_top = 0x58 }, 352 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5, 353 .if_lvl = 1, .rfagc_top = 0x58 }, 354 }; 355 356 static struct tda18271_config hauppauge_hvr127x_config = { 357 .std_map = &hauppauge_hvr127x_std_map, 358 .output_opt = TDA18271_OUTPUT_LT_OFF, 359 }; 360 361 static struct lgdt3305_config hauppauge_lgdt3305_config = { 362 .i2c_addr = 0x0e, 363 .mpeg_mode = LGDT3305_MPEG_SERIAL, 364 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, 365 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, 366 .deny_i2c_rptr = 1, 367 .spectral_inversion = 1, 368 .qam_if_khz = 4000, 369 .vsb_if_khz = 3250, 370 }; 371 372 static struct dibx000_agc_config xc3028_agc_config = { 373 BAND_VHF | BAND_UHF, /* band_caps */ 374 375 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, 376 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, 377 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, 378 * P_agc_nb_est=2, P_agc_write=0 379 */ 380 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | 381 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */ 382 383 712, /* inv_gain */ 384 21, /* time_stabiliz */ 385 386 0, /* alpha_level */ 387 118, /* thlock */ 388 389 0, /* wbd_inv */ 390 2867, /* wbd_ref */ 391 0, /* wbd_sel */ 392 2, /* wbd_alpha */ 393 394 0, /* agc1_max */ 395 0, /* agc1_min */ 396 39718, /* agc2_max */ 397 9930, /* agc2_min */ 398 0, /* agc1_pt1 */ 399 0, /* agc1_pt2 */ 400 0, /* agc1_pt3 */ 401 0, /* agc1_slope1 */ 402 0, /* agc1_slope2 */ 403 0, /* agc2_pt1 */ 404 128, /* agc2_pt2 */ 405 29, /* agc2_slope1 */ 406 29, /* agc2_slope2 */ 407 408 17, /* alpha_mant */ 409 27, /* alpha_exp */ 410 23, /* beta_mant */ 411 51, /* beta_exp */ 412 413 1, /* perform_agc_softsplit */ 414 }; 415 416 /* PLL Configuration for COFDM BW_MHz = 8.000000 417 * With external clock = 30.000000 */ 418 static struct dibx000_bandwidth_config xc3028_bw_config = { 419 60000, /* internal */ 420 30000, /* sampling */ 421 1, /* pll_cfg: prediv */ 422 8, /* pll_cfg: ratio */ 423 3, /* pll_cfg: range */ 424 1, /* pll_cfg: reset */ 425 0, /* pll_cfg: bypass */ 426 0, /* misc: refdiv */ 427 0, /* misc: bypclk_div */ 428 1, /* misc: IO_CLK_en_core */ 429 1, /* misc: ADClkSrc */ 430 0, /* misc: modulo */ 431 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ 432 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ 433 20452225, /* timf */ 434 30000000 /* xtal_hz */ 435 }; 436 437 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = { 438 .output_mpeg2_in_188_bytes = 1, 439 .hostbus_diversity = 1, 440 .tuner_is_baseband = 0, 441 .update_lna = NULL, 442 443 .agc_config_count = 1, 444 .agc = &xc3028_agc_config, 445 .bw = &xc3028_bw_config, 446 447 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, 448 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, 449 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 450 451 .pwm_freq_div = 0, 452 .agc_control = NULL, 453 .spur_protect = 0, 454 455 .output_mode = OUTMODE_MPEG2_SERIAL, 456 }; 457 458 static struct zl10353_config dvico_fusionhdtv_xc3028 = { 459 .demod_address = 0x0f, 460 .if2 = 45600, 461 .no_tuner = 1, 462 .disable_i2c_gate_ctrl = 1, 463 }; 464 465 static struct stv0900_reg stv0900_ts_regs[] = { 466 { R0900_TSGENERAL, 0x00 }, 467 { R0900_P1_TSSPEED, 0x40 }, 468 { R0900_P2_TSSPEED, 0x40 }, 469 { R0900_P1_TSCFGM, 0xc0 }, 470 { R0900_P2_TSCFGM, 0xc0 }, 471 { R0900_P1_TSCFGH, 0xe0 }, 472 { R0900_P2_TSCFGH, 0xe0 }, 473 { R0900_P1_TSCFGL, 0x20 }, 474 { R0900_P2_TSCFGL, 0x20 }, 475 { 0xffff, 0xff }, /* terminate */ 476 }; 477 478 static struct stv0900_config netup_stv0900_config = { 479 .demod_address = 0x68, 480 .demod_mode = 1, /* dual */ 481 .xtal = 8000000, 482 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 483 .diseqc_mode = 2,/* 2/3 PWM */ 484 .ts_config_regs = stv0900_ts_regs, 485 .tun1_maddress = 0,/* 0x60 */ 486 .tun2_maddress = 3,/* 0x63 */ 487 .tun1_adc = 1,/* 1 Vpp */ 488 .tun2_adc = 1,/* 1 Vpp */ 489 }; 490 491 static struct stv6110_config netup_stv6110_tunerconfig_a = { 492 .i2c_address = 0x60, 493 .mclk = 16000000, 494 .clk_div = 1, 495 .gain = 8, /* +16 dB - maximum gain */ 496 }; 497 498 static struct stv6110_config netup_stv6110_tunerconfig_b = { 499 .i2c_address = 0x63, 500 .mclk = 16000000, 501 .clk_div = 1, 502 .gain = 8, /* +16 dB - maximum gain */ 503 }; 504 505 static struct cx24116_config tbs_cx24116_config = { 506 .demod_address = 0x55, 507 }; 508 509 static struct cx24117_config tbs_cx24117_config = { 510 .demod_address = 0x55, 511 }; 512 513 static struct ds3000_config tevii_ds3000_config = { 514 .demod_address = 0x68, 515 }; 516 517 static struct ts2020_config tevii_ts2020_config = { 518 .tuner_address = 0x60, 519 .clk_out_div = 1, 520 .frequency_div = 1146000, 521 }; 522 523 static struct cx24116_config dvbworld_cx24116_config = { 524 .demod_address = 0x05, 525 }; 526 527 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = { 528 .prod = LGS8GXX_PROD_LGS8GL5, 529 .demod_address = 0x19, 530 .serial_ts = 0, 531 .ts_clk_pol = 1, 532 .ts_clk_gated = 1, 533 .if_clk_freq = 30400, /* 30.4 MHz */ 534 .if_freq = 5380, /* 5.38 MHz */ 535 .if_neg_center = 1, 536 .ext_adc = 0, 537 .adc_signed = 0, 538 .if_neg_edge = 0, 539 }; 540 541 static struct xc5000_config mygica_x8506_xc5000_config = { 542 .i2c_address = 0x61, 543 .if_khz = 5380, 544 }; 545 546 static struct mb86a20s_config mygica_x8507_mb86a20s_config = { 547 .demod_address = 0x10, 548 }; 549 550 static struct xc5000_config mygica_x8507_xc5000_config = { 551 .i2c_address = 0x61, 552 .if_khz = 4000, 553 }; 554 555 static struct stv090x_config prof_8000_stv090x_config = { 556 .device = STV0903, 557 .demod_mode = STV090x_SINGLE, 558 .clk_mode = STV090x_CLK_EXT, 559 .xtal = 27000000, 560 .address = 0x6A, 561 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED, 562 .repeater_level = STV090x_RPTLEVEL_64, 563 .adc1_range = STV090x_ADC_2Vpp, 564 .diseqc_envelope_mode = false, 565 566 .tuner_get_frequency = stb6100_get_frequency, 567 .tuner_set_frequency = stb6100_set_frequency, 568 .tuner_set_bandwidth = stb6100_set_bandwidth, 569 .tuner_get_bandwidth = stb6100_get_bandwidth, 570 }; 571 572 static struct stb6100_config prof_8000_stb6100_config = { 573 .tuner_address = 0x60, 574 .refclock = 27000000, 575 }; 576 577 static int p8000_set_voltage(struct dvb_frontend *fe, 578 enum fe_sec_voltage voltage) 579 { 580 struct cx23885_tsport *port = fe->dvb->priv; 581 struct cx23885_dev *dev = port->dev; 582 583 if (voltage == SEC_VOLTAGE_18) 584 cx_write(MC417_RWD, 0x00001e00); 585 else if (voltage == SEC_VOLTAGE_13) 586 cx_write(MC417_RWD, 0x00001a00); 587 else 588 cx_write(MC417_RWD, 0x00001800); 589 return 0; 590 } 591 592 static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe, 593 enum fe_sec_voltage voltage) 594 { 595 struct cx23885_tsport *port = fe->dvb->priv; 596 struct cx23885_dev *dev = port->dev; 597 598 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1); 599 600 switch (voltage) { 601 case SEC_VOLTAGE_13: 602 cx23885_gpio_set(dev, GPIO_1); 603 cx23885_gpio_clear(dev, GPIO_0); 604 break; 605 case SEC_VOLTAGE_18: 606 cx23885_gpio_set(dev, GPIO_1); 607 cx23885_gpio_set(dev, GPIO_0); 608 break; 609 case SEC_VOLTAGE_OFF: 610 cx23885_gpio_clear(dev, GPIO_1); 611 cx23885_gpio_clear(dev, GPIO_0); 612 break; 613 } 614 615 /* call the frontend set_voltage function */ 616 port->fe_set_voltage(fe, voltage); 617 618 return 0; 619 } 620 621 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe, 622 enum fe_sec_voltage voltage) 623 { 624 struct cx23885_tsport *port = fe->dvb->priv; 625 struct cx23885_dev *dev = port->dev; 626 627 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1); 628 629 switch (voltage) { 630 case SEC_VOLTAGE_13: 631 cx23885_gpio_set(dev, GPIO_13); 632 cx23885_gpio_clear(dev, GPIO_12); 633 break; 634 case SEC_VOLTAGE_18: 635 cx23885_gpio_set(dev, GPIO_13); 636 cx23885_gpio_set(dev, GPIO_12); 637 break; 638 case SEC_VOLTAGE_OFF: 639 cx23885_gpio_clear(dev, GPIO_13); 640 cx23885_gpio_clear(dev, GPIO_12); 641 break; 642 } 643 /* call the frontend set_voltage function */ 644 return port->fe_set_voltage(fe, voltage); 645 } 646 647 static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr, 648 u8 data, int *mem) 649 { 650 /* MC417 */ 651 #define SP2_DATA 0x000000ff 652 #define SP2_WR 0x00008000 653 #define SP2_RD 0x00004000 654 #define SP2_ACK 0x00001000 655 #define SP2_ADHI 0x00000800 656 #define SP2_ADLO 0x00000400 657 #define SP2_CS1 0x00000200 658 #define SP2_CS0 0x00000100 659 #define SP2_EN_ALL 0x00001000 660 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD) 661 662 struct cx23885_tsport *port = priv; 663 struct cx23885_dev *dev = port->dev; 664 int ret; 665 int tmp = 0; 666 unsigned long timeout; 667 668 mutex_lock(&dev->gpio_lock); 669 670 /* write addr */ 671 cx_write(MC417_OEN, SP2_EN_ALL); 672 cx_write(MC417_RWD, SP2_CTRL_OFF | 673 SP2_ADLO | (0xff & addr)); 674 cx_clear(MC417_RWD, SP2_ADLO); 675 cx_write(MC417_RWD, SP2_CTRL_OFF | 676 SP2_ADHI | (0xff & (addr >> 8))); 677 cx_clear(MC417_RWD, SP2_ADHI); 678 679 if (read) 680 /* data in */ 681 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA); 682 else 683 /* data out */ 684 cx_write(MC417_RWD, SP2_CTRL_OFF | data); 685 686 /* chip select 0 */ 687 cx_clear(MC417_RWD, SP2_CS0); 688 689 /* read/write */ 690 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR); 691 692 /* wait for a maximum of 1 msec */ 693 timeout = jiffies + msecs_to_jiffies(1); 694 while (!time_after(jiffies, timeout)) { 695 tmp = cx_read(MC417_RWD); 696 if ((tmp & SP2_ACK) == 0) 697 break; 698 usleep_range(50, 100); 699 } 700 701 cx_set(MC417_RWD, SP2_CTRL_OFF); 702 *mem = tmp & 0xff; 703 704 mutex_unlock(&dev->gpio_lock); 705 706 if (!read) { 707 if (*mem < 0) { 708 ret = -EREMOTEIO; 709 goto err; 710 } 711 } 712 713 return 0; 714 err: 715 return ret; 716 } 717 718 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe) 719 { 720 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 721 struct cx23885_tsport *port = fe->dvb->priv; 722 struct cx23885_dev *dev = port->dev; 723 724 switch (dev->board) { 725 case CX23885_BOARD_HAUPPAUGE_HVR1275: 726 switch (p->modulation) { 727 case VSB_8: 728 cx23885_gpio_clear(dev, GPIO_5); 729 break; 730 case QAM_64: 731 case QAM_256: 732 default: 733 cx23885_gpio_set(dev, GPIO_5); 734 break; 735 } 736 break; 737 case CX23885_BOARD_MYGICA_X8506: 738 case CX23885_BOARD_MYGICA_X8507: 739 case CX23885_BOARD_MAGICPRO_PROHDTVE2: 740 /* Select Digital TV */ 741 cx23885_gpio_set(dev, GPIO_0); 742 break; 743 } 744 745 /* Call the real set_frontend */ 746 if (port->set_frontend) 747 return port->set_frontend(fe); 748 749 return 0; 750 } 751 752 static void cx23885_set_frontend_hook(struct cx23885_tsport *port, 753 struct dvb_frontend *fe) 754 { 755 port->set_frontend = fe->ops.set_frontend; 756 fe->ops.set_frontend = cx23885_dvb_set_frontend; 757 } 758 759 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = { 760 .prod = LGS8GXX_PROD_LGS8G75, 761 .demod_address = 0x19, 762 .serial_ts = 0, 763 .ts_clk_pol = 1, 764 .ts_clk_gated = 1, 765 .if_clk_freq = 30400, /* 30.4 MHz */ 766 .if_freq = 6500, /* 6.50 MHz */ 767 .if_neg_center = 1, 768 .ext_adc = 0, 769 .adc_signed = 1, 770 .adc_vpp = 2, /* 1.6 Vpp */ 771 .if_neg_edge = 1, 772 }; 773 774 static struct xc5000_config magicpro_prohdtve2_xc5000_config = { 775 .i2c_address = 0x61, 776 .if_khz = 6500, 777 }; 778 779 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = { 780 .prod = ATBM8830_PROD_8830, 781 .demod_address = 0x44, 782 .serial_ts = 0, 783 .ts_sampling_edge = 1, 784 .ts_clk_gated = 0, 785 .osc_clk_freq = 30400, /* in kHz */ 786 .if_freq = 0, /* zero IF */ 787 .zif_swap_iq = 1, 788 .agc_min = 0x2E, 789 .agc_max = 0xFF, 790 .agc_hold_loop = 0, 791 }; 792 793 static struct max2165_config mygic_x8558pro_max2165_cfg1 = { 794 .i2c_address = 0x60, 795 .osc_clk = 20 796 }; 797 798 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = { 799 .prod = ATBM8830_PROD_8830, 800 .demod_address = 0x44, 801 .serial_ts = 1, 802 .ts_sampling_edge = 1, 803 .ts_clk_gated = 0, 804 .osc_clk_freq = 30400, /* in kHz */ 805 .if_freq = 0, /* zero IF */ 806 .zif_swap_iq = 1, 807 .agc_min = 0x2E, 808 .agc_max = 0xFF, 809 .agc_hold_loop = 0, 810 }; 811 812 static struct max2165_config mygic_x8558pro_max2165_cfg2 = { 813 .i2c_address = 0x60, 814 .osc_clk = 20 815 }; 816 static struct stv0367_config netup_stv0367_config[] = { 817 { 818 .demod_address = 0x1c, 819 .xtal = 27000000, 820 .if_khz = 4500, 821 .if_iq_mode = 0, 822 .ts_mode = 1, 823 .clk_pol = 0, 824 }, { 825 .demod_address = 0x1d, 826 .xtal = 27000000, 827 .if_khz = 4500, 828 .if_iq_mode = 0, 829 .ts_mode = 1, 830 .clk_pol = 0, 831 }, 832 }; 833 834 static struct xc5000_config netup_xc5000_config[] = { 835 { 836 .i2c_address = 0x61, 837 .if_khz = 4500, 838 }, { 839 .i2c_address = 0x64, 840 .if_khz = 4500, 841 }, 842 }; 843 844 static struct drxk_config terratec_drxk_config[] = { 845 { 846 .adr = 0x29, 847 .no_i2c_bridge = 1, 848 }, { 849 .adr = 0x2a, 850 .no_i2c_bridge = 1, 851 }, 852 }; 853 854 static struct mt2063_config terratec_mt2063_config[] = { 855 { 856 .tuner_address = 0x60, 857 }, { 858 .tuner_address = 0x67, 859 }, 860 }; 861 862 static const struct tda10071_platform_data hauppauge_tda10071_pdata = { 863 .clk = 40444000, /* 40.444 MHz */ 864 .i2c_wr_max = 64, 865 .ts_mode = TDA10071_TS_SERIAL, 866 .pll_multiplier = 20, 867 .tuner_i2c_addr = 0x54, 868 }; 869 870 static const struct si2165_config hauppauge_hvr4400_si2165_config = { 871 .i2c_addr = 0x64, 872 .chip_mode = SI2165_MODE_PLL_XTAL, 873 .ref_freq_Hz = 16000000, 874 }; 875 876 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = { 877 .i2c_addr = 0x68, 878 .clock = 27000000, 879 .i2c_wr_max = 33, 880 .clock_out = 0, 881 .ts_mode = M88DS3103_TS_PARALLEL, 882 .ts_clk = 16000, 883 .ts_clk_pol = 1, 884 .lnb_en_pol = 1, 885 .lnb_hv_pol = 0, 886 .agc = 0x99, 887 }; 888 889 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = { 890 .i2c_addr = 0x68, 891 .clock = 27000000, 892 .i2c_wr_max = 33, 893 .clock_out = 0, 894 .ts_mode = M88DS3103_TS_CI, 895 .ts_clk = 10000, 896 .ts_clk_pol = 1, 897 .lnb_en_pol = 1, 898 .lnb_hv_pol = 0, 899 .agc = 0x99, 900 }; 901 902 static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = { 903 .i2c_addr = 0x68, 904 .clock = 27000000, 905 .i2c_wr_max = 33, 906 .clock_out = 0, 907 .ts_mode = M88DS3103_TS_SERIAL, 908 .ts_clk = 96000, 909 .ts_clk_pol = 0, 910 .lnb_en_pol = 1, 911 .lnb_hv_pol = 0, 912 .agc = 0x99, 913 }; 914 915 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = { 916 .i2c_addr = 0x69, 917 .clock = 27000000, 918 .i2c_wr_max = 33, 919 .ts_mode = M88DS3103_TS_PARALLEL, 920 .ts_clk = 16000, 921 .ts_clk_pol = 1, 922 .agc = 0x99, 923 }; 924 925 static int netup_altera_fpga_rw(void *device, int flag, int data, int read) 926 { 927 struct cx23885_dev *dev = (struct cx23885_dev *)device; 928 unsigned long timeout = jiffies + msecs_to_jiffies(1); 929 uint32_t mem = 0; 930 931 mem = cx_read(MC417_RWD); 932 if (read) 933 cx_set(MC417_OEN, ALT_DATA); 934 else { 935 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */ 936 mem &= ~ALT_DATA; 937 mem |= (data & ALT_DATA); 938 } 939 940 if (flag) 941 mem |= ALT_AD_RG; 942 else 943 mem &= ~ALT_AD_RG; 944 945 mem &= ~ALT_CS; 946 if (read) 947 mem = (mem & ~ALT_RD) | ALT_WR; 948 else 949 mem = (mem & ~ALT_WR) | ALT_RD; 950 951 cx_write(MC417_RWD, mem); /* start RW cycle */ 952 953 for (;;) { 954 mem = cx_read(MC417_RWD); 955 if ((mem & ALT_RDY) == 0) 956 break; 957 if (time_after(jiffies, timeout)) 958 break; 959 udelay(1); 960 } 961 962 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS); 963 if (read) 964 return mem & ALT_DATA; 965 966 return 0; 967 }; 968 969 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff) 970 { 971 struct dib7000p_ops *dib7000p_ops = fe->sec_priv; 972 973 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff); 974 } 975 976 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff) 977 { 978 return 0; 979 } 980 981 static struct dib0070_config dib7070p_dib0070_config = { 982 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS, 983 .reset = dib7070_tuner_reset, 984 .sleep = dib7070_tuner_sleep, 985 .clock_khz = 12000, 986 .freq_offset_khz_vhf = 550, 987 /* .flip_chip = 1, */ 988 }; 989 990 /* DIB7070 generic */ 991 static struct dibx000_agc_config dib7070_agc_config = { 992 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND, 993 994 /* 995 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, 996 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, 997 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 998 */ 999 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | 1000 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), 1001 .inv_gain = 600, 1002 .time_stabiliz = 10, 1003 .alpha_level = 0, 1004 .thlock = 118, 1005 .wbd_inv = 0, 1006 .wbd_ref = 3530, 1007 .wbd_sel = 1, 1008 .wbd_alpha = 5, 1009 .agc1_max = 65535, 1010 .agc1_min = 0, 1011 .agc2_max = 65535, 1012 .agc2_min = 0, 1013 .agc1_pt1 = 0, 1014 .agc1_pt2 = 40, 1015 .agc1_pt3 = 183, 1016 .agc1_slope1 = 206, 1017 .agc1_slope2 = 255, 1018 .agc2_pt1 = 72, 1019 .agc2_pt2 = 152, 1020 .agc2_slope1 = 88, 1021 .agc2_slope2 = 90, 1022 .alpha_mant = 17, 1023 .alpha_exp = 27, 1024 .beta_mant = 23, 1025 .beta_exp = 51, 1026 .perform_agc_softsplit = 0, 1027 }; 1028 1029 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = { 1030 .internal = 60000, 1031 .sampling = 15000, 1032 .pll_prediv = 1, 1033 .pll_ratio = 20, 1034 .pll_range = 3, 1035 .pll_reset = 1, 1036 .pll_bypass = 0, 1037 .enable_refdiv = 0, 1038 .bypclk_div = 0, 1039 .IO_CLK_en_core = 1, 1040 .ADClkSrc = 1, 1041 .modulo = 2, 1042 /* refsel, sel, freq_15k */ 1043 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0), 1044 .ifreq = (0 << 25) | 0, 1045 .timf = 20452225, 1046 .xtal_hz = 12000000, 1047 }; 1048 1049 static struct dib7000p_config dib7070p_dib7000p_config = { 1050 /* .output_mode = OUTMODE_MPEG2_FIFO, */ 1051 .output_mode = OUTMODE_MPEG2_SERIAL, 1052 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */ 1053 .output_mpeg2_in_188_bytes = 1, 1054 1055 .agc_config_count = 1, 1056 .agc = &dib7070_agc_config, 1057 .bw = &dib7070_bw_config_12_mhz, 1058 .tuner_is_baseband = 1, 1059 .spur_protect = 1, 1060 1061 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */ 1062 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */ 1063 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, 1064 1065 .hostbus_diversity = 1, 1066 }; 1067 1068 static int dvb_register_ci_mac(struct cx23885_tsport *port) 1069 { 1070 struct cx23885_dev *dev = port->dev; 1071 struct i2c_client *client_ci = NULL; 1072 struct vb2_dvb_frontend *fe0; 1073 1074 fe0 = vb2_dvb_get_frontend(&port->frontends, 1); 1075 if (!fe0) 1076 return -EINVAL; 1077 1078 switch (dev->board) { 1079 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: { 1080 static struct netup_card_info cinfo; 1081 1082 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo); 1083 memcpy(port->frontends.adapter.proposed_mac, 1084 cinfo.port[port->nr - 1].mac, 6); 1085 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n", 1086 port->nr, port->frontends.adapter.proposed_mac); 1087 1088 netup_ci_init(port); 1089 return 0; 1090 } 1091 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: { 1092 struct altera_ci_config netup_ci_cfg = { 1093 .dev = dev,/* magic number to identify*/ 1094 .adapter = &port->frontends.adapter,/* for CI */ 1095 .demux = &fe0->dvb.demux,/* for hw pid filter */ 1096 .fpga_rw = netup_altera_fpga_rw, 1097 }; 1098 1099 altera_ci_init(&netup_ci_cfg, port->nr); 1100 return 0; 1101 } 1102 case CX23885_BOARD_TEVII_S470: { 1103 u8 eeprom[256]; /* 24C02 i2c eeprom */ 1104 1105 if (port->nr != 1) 1106 return 0; 1107 1108 /* Read entire EEPROM */ 1109 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 1110 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom)); 1111 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0); 1112 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); 1113 return 0; 1114 } 1115 case CX23885_BOARD_DVBSKY_T9580: 1116 case CX23885_BOARD_DVBSKY_S950: 1117 case CX23885_BOARD_DVBSKY_S952: 1118 case CX23885_BOARD_DVBSKY_T982: { 1119 u8 eeprom[256]; /* 24C02 i2c eeprom */ 1120 1121 if (port->nr > 2) 1122 return 0; 1123 1124 /* Read entire EEPROM */ 1125 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 1126 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, 1127 sizeof(eeprom)); 1128 printk(KERN_INFO "%s port %d MAC address: %pM\n", 1129 cx23885_boards[dev->board].name, port->nr, 1130 eeprom + 0xc0 + (port->nr-1) * 8); 1131 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + 1132 (port->nr-1) * 8, 6); 1133 return 0; 1134 } 1135 case CX23885_BOARD_DVBSKY_S950C: 1136 case CX23885_BOARD_DVBSKY_T980C: 1137 case CX23885_BOARD_TT_CT2_4500_CI: { 1138 u8 eeprom[256]; /* 24C02 i2c eeprom */ 1139 struct sp2_config sp2_config; 1140 struct i2c_board_info info; 1141 struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0]; 1142 1143 /* attach CI */ 1144 memset(&sp2_config, 0, sizeof(sp2_config)); 1145 sp2_config.dvb_adap = &port->frontends.adapter; 1146 sp2_config.priv = port; 1147 sp2_config.ci_control = cx23885_sp2_ci_ctrl; 1148 memset(&info, 0, sizeof(struct i2c_board_info)); 1149 strlcpy(info.type, "sp2", I2C_NAME_SIZE); 1150 info.addr = 0x40; 1151 info.platform_data = &sp2_config; 1152 request_module(info.type); 1153 client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info); 1154 if (client_ci == NULL || client_ci->dev.driver == NULL) 1155 return -ENODEV; 1156 if (!try_module_get(client_ci->dev.driver->owner)) { 1157 i2c_unregister_device(client_ci); 1158 return -ENODEV; 1159 } 1160 port->i2c_client_ci = client_ci; 1161 1162 if (port->nr != 1) 1163 return 0; 1164 1165 /* Read entire EEPROM */ 1166 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 1167 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, 1168 sizeof(eeprom)); 1169 printk(KERN_INFO "%s MAC address: %pM\n", 1170 cx23885_boards[dev->board].name, eeprom + 0xc0); 1171 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6); 1172 return 0; 1173 } 1174 } 1175 return 0; 1176 } 1177 1178 static int dvb_register(struct cx23885_tsport *port) 1179 { 1180 struct dib7000p_ops dib7000p_ops; 1181 struct cx23885_dev *dev = port->dev; 1182 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL; 1183 struct vb2_dvb_frontend *fe0, *fe1 = NULL; 1184 struct si2168_config si2168_config; 1185 struct si2157_config si2157_config; 1186 struct ts2020_config ts2020_config; 1187 struct i2c_board_info info; 1188 struct i2c_adapter *adapter; 1189 struct i2c_client *client_demod = NULL, *client_tuner = NULL; 1190 struct i2c_client *client_sec = NULL; 1191 const struct m88ds3103_config *p_m88ds3103_config = NULL; 1192 int (*p_set_voltage)(struct dvb_frontend *fe, 1193 enum fe_sec_voltage voltage) = NULL; 1194 int mfe_shared = 0; /* bus not shared by default */ 1195 int ret; 1196 1197 /* Get the first frontend */ 1198 fe0 = vb2_dvb_get_frontend(&port->frontends, 1); 1199 if (!fe0) 1200 return -EINVAL; 1201 1202 /* init struct vb2_dvb */ 1203 fe0->dvb.name = dev->name; 1204 1205 /* multi-frontend gate control is undefined or defaults to fe0 */ 1206 port->frontends.gate = 0; 1207 1208 /* Sets the gate control callback to be used by i2c command calls */ 1209 port->gate_ctrl = cx23885_dvb_gate_ctrl; 1210 1211 /* init frontend */ 1212 switch (dev->board) { 1213 case CX23885_BOARD_HAUPPAUGE_HVR1250: 1214 i2c_bus = &dev->i2c_bus[0]; 1215 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1216 &hauppauge_generic_config, 1217 &i2c_bus->i2c_adap); 1218 if (fe0->dvb.frontend == NULL) 1219 break; 1220 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1221 &i2c_bus->i2c_adap, 1222 &hauppauge_generic_tunerconfig, 0); 1223 break; 1224 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1225 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1226 i2c_bus = &dev->i2c_bus[0]; 1227 fe0->dvb.frontend = dvb_attach(lgdt3305_attach, 1228 &hauppauge_lgdt3305_config, 1229 &i2c_bus->i2c_adap); 1230 if (fe0->dvb.frontend == NULL) 1231 break; 1232 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1233 0x60, &dev->i2c_bus[1].i2c_adap, 1234 &hauppauge_hvr127x_config); 1235 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275) 1236 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1237 break; 1238 case CX23885_BOARD_HAUPPAUGE_HVR1255: 1239 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111: 1240 i2c_bus = &dev->i2c_bus[0]; 1241 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1242 &hcw_s5h1411_config, 1243 &i2c_bus->i2c_adap); 1244 if (fe0->dvb.frontend == NULL) 1245 break; 1246 1247 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1248 0x60, &dev->i2c_bus[1].i2c_adap, 1249 &hauppauge_tda18271_config); 1250 1251 tda18271_attach(&dev->ts1.analog_fe, 1252 0x60, &dev->i2c_bus[1].i2c_adap, 1253 &hauppauge_tda18271_config); 1254 1255 break; 1256 case CX23885_BOARD_HAUPPAUGE_HVR1800: 1257 i2c_bus = &dev->i2c_bus[0]; 1258 switch (alt_tuner) { 1259 case 1: 1260 fe0->dvb.frontend = 1261 dvb_attach(s5h1409_attach, 1262 &hauppauge_ezqam_config, 1263 &i2c_bus->i2c_adap); 1264 if (fe0->dvb.frontend == NULL) 1265 break; 1266 1267 dvb_attach(tda829x_attach, fe0->dvb.frontend, 1268 &dev->i2c_bus[1].i2c_adap, 0x42, 1269 &tda829x_no_probe); 1270 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1271 0x60, &dev->i2c_bus[1].i2c_adap, 1272 &hauppauge_tda18271_config); 1273 break; 1274 case 0: 1275 default: 1276 fe0->dvb.frontend = 1277 dvb_attach(s5h1409_attach, 1278 &hauppauge_generic_config, 1279 &i2c_bus->i2c_adap); 1280 if (fe0->dvb.frontend == NULL) 1281 break; 1282 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1283 &i2c_bus->i2c_adap, 1284 &hauppauge_generic_tunerconfig, 0); 1285 } 1286 break; 1287 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 1288 i2c_bus = &dev->i2c_bus[0]; 1289 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1290 &hauppauge_hvr1800lp_config, 1291 &i2c_bus->i2c_adap); 1292 if (fe0->dvb.frontend == NULL) 1293 break; 1294 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1295 &i2c_bus->i2c_adap, 1296 &hauppauge_generic_tunerconfig, 0); 1297 break; 1298 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: 1299 i2c_bus = &dev->i2c_bus[0]; 1300 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1301 &fusionhdtv_5_express, 1302 &i2c_bus->i2c_adap); 1303 if (fe0->dvb.frontend == NULL) 1304 break; 1305 dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1306 &i2c_bus->i2c_adap, 0x61, 1307 TUNER_LG_TDVS_H06XF); 1308 break; 1309 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 1310 i2c_bus = &dev->i2c_bus[1]; 1311 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1312 &hauppauge_hvr1500q_config, 1313 &dev->i2c_bus[0].i2c_adap); 1314 if (fe0->dvb.frontend == NULL) 1315 break; 1316 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1317 &i2c_bus->i2c_adap, 1318 &hauppauge_hvr1500q_tunerconfig); 1319 break; 1320 case CX23885_BOARD_HAUPPAUGE_HVR1500: 1321 i2c_bus = &dev->i2c_bus[1]; 1322 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1323 &hauppauge_hvr1500_config, 1324 &dev->i2c_bus[0].i2c_adap); 1325 if (fe0->dvb.frontend != NULL) { 1326 struct dvb_frontend *fe; 1327 struct xc2028_config cfg = { 1328 .i2c_adap = &i2c_bus->i2c_adap, 1329 .i2c_addr = 0x61, 1330 }; 1331 static struct xc2028_ctrl ctl = { 1332 .fname = XC2028_DEFAULT_FIRMWARE, 1333 .max_len = 64, 1334 .demod = XC3028_FE_OREN538, 1335 }; 1336 1337 fe = dvb_attach(xc2028_attach, 1338 fe0->dvb.frontend, &cfg); 1339 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 1340 fe->ops.tuner_ops.set_config(fe, &ctl); 1341 } 1342 break; 1343 case CX23885_BOARD_HAUPPAUGE_HVR1200: 1344 case CX23885_BOARD_HAUPPAUGE_HVR1700: 1345 i2c_bus = &dev->i2c_bus[0]; 1346 fe0->dvb.frontend = dvb_attach(tda10048_attach, 1347 &hauppauge_hvr1200_config, 1348 &i2c_bus->i2c_adap); 1349 if (fe0->dvb.frontend == NULL) 1350 break; 1351 dvb_attach(tda829x_attach, fe0->dvb.frontend, 1352 &dev->i2c_bus[1].i2c_adap, 0x42, 1353 &tda829x_no_probe); 1354 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1355 0x60, &dev->i2c_bus[1].i2c_adap, 1356 &hauppauge_hvr1200_tuner_config); 1357 break; 1358 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1359 i2c_bus = &dev->i2c_bus[0]; 1360 fe0->dvb.frontend = dvb_attach(tda10048_attach, 1361 &hauppauge_hvr1210_config, 1362 &i2c_bus->i2c_adap); 1363 if (fe0->dvb.frontend != NULL) { 1364 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1365 0x60, &dev->i2c_bus[1].i2c_adap, 1366 &hauppauge_hvr1210_tuner_config); 1367 } 1368 break; 1369 case CX23885_BOARD_HAUPPAUGE_HVR1400: 1370 i2c_bus = &dev->i2c_bus[0]; 1371 1372 if (!dvb_attach(dib7000p_attach, &dib7000p_ops)) 1373 return -ENODEV; 1374 1375 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 1376 0x12, &hauppauge_hvr1400_dib7000_config); 1377 if (fe0->dvb.frontend != NULL) { 1378 struct dvb_frontend *fe; 1379 struct xc2028_config cfg = { 1380 .i2c_adap = &dev->i2c_bus[1].i2c_adap, 1381 .i2c_addr = 0x64, 1382 }; 1383 static struct xc2028_ctrl ctl = { 1384 .fname = XC3028L_DEFAULT_FIRMWARE, 1385 .max_len = 64, 1386 .demod = XC3028_FE_DIBCOM52, 1387 /* This is true for all demods with 1388 v36 firmware? */ 1389 .type = XC2028_D2633, 1390 }; 1391 1392 fe = dvb_attach(xc2028_attach, 1393 fe0->dvb.frontend, &cfg); 1394 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 1395 fe->ops.tuner_ops.set_config(fe, &ctl); 1396 } 1397 break; 1398 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: 1399 i2c_bus = &dev->i2c_bus[port->nr - 1]; 1400 1401 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1402 &dvico_s5h1409_config, 1403 &i2c_bus->i2c_adap); 1404 if (fe0->dvb.frontend == NULL) 1405 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1406 &dvico_s5h1411_config, 1407 &i2c_bus->i2c_adap); 1408 if (fe0->dvb.frontend != NULL) 1409 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1410 &i2c_bus->i2c_adap, 1411 &dvico_xc5000_tunerconfig); 1412 break; 1413 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { 1414 i2c_bus = &dev->i2c_bus[port->nr - 1]; 1415 1416 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1417 &dvico_fusionhdtv_xc3028, 1418 &i2c_bus->i2c_adap); 1419 if (fe0->dvb.frontend != NULL) { 1420 struct dvb_frontend *fe; 1421 struct xc2028_config cfg = { 1422 .i2c_adap = &i2c_bus->i2c_adap, 1423 .i2c_addr = 0x61, 1424 }; 1425 static struct xc2028_ctrl ctl = { 1426 .fname = XC2028_DEFAULT_FIRMWARE, 1427 .max_len = 64, 1428 .demod = XC3028_FE_ZARLINK456, 1429 }; 1430 1431 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, 1432 &cfg); 1433 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 1434 fe->ops.tuner_ops.set_config(fe, &ctl); 1435 } 1436 break; 1437 } 1438 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: { 1439 i2c_bus = &dev->i2c_bus[port->nr - 1]; 1440 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */ 1441 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */ 1442 1443 if (!dvb_attach(dib7000p_attach, &dib7000p_ops)) 1444 return -ENODEV; 1445 1446 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) { 1447 printk(KERN_WARNING "Unable to enumerate dib7000p\n"); 1448 return -ENODEV; 1449 } 1450 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config); 1451 if (fe0->dvb.frontend != NULL) { 1452 struct i2c_adapter *tun_i2c; 1453 1454 fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL); 1455 memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops)); 1456 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1); 1457 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config)) 1458 return -ENODEV; 1459 } 1460 break; 1461 } 1462 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: 1463 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: 1464 case CX23885_BOARD_COMPRO_VIDEOMATE_E800: 1465 i2c_bus = &dev->i2c_bus[0]; 1466 1467 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1468 &dvico_fusionhdtv_xc3028, 1469 &i2c_bus->i2c_adap); 1470 if (fe0->dvb.frontend != NULL) { 1471 struct dvb_frontend *fe; 1472 struct xc2028_config cfg = { 1473 .i2c_adap = &dev->i2c_bus[1].i2c_adap, 1474 .i2c_addr = 0x61, 1475 }; 1476 static struct xc2028_ctrl ctl = { 1477 .fname = XC2028_DEFAULT_FIRMWARE, 1478 .max_len = 64, 1479 .demod = XC3028_FE_ZARLINK456, 1480 }; 1481 1482 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, 1483 &cfg); 1484 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) 1485 fe->ops.tuner_ops.set_config(fe, &ctl); 1486 } 1487 break; 1488 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000: 1489 i2c_bus = &dev->i2c_bus[0]; 1490 1491 fe0->dvb.frontend = dvb_attach(zl10353_attach, 1492 &dvico_fusionhdtv_xc3028, 1493 &i2c_bus->i2c_adap); 1494 if (fe0->dvb.frontend != NULL) { 1495 struct dvb_frontend *fe; 1496 struct xc4000_config cfg = { 1497 .i2c_address = 0x61, 1498 .default_pm = 0, 1499 .dvb_amplitude = 134, 1500 .set_smoothedcvbs = 1, 1501 .if_khz = 4560 1502 }; 1503 1504 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, 1505 &dev->i2c_bus[1].i2c_adap, &cfg); 1506 if (!fe) { 1507 printk(KERN_ERR "%s/2: xc4000 attach failed\n", 1508 dev->name); 1509 goto frontend_detach; 1510 } 1511 } 1512 break; 1513 case CX23885_BOARD_TBS_6920: 1514 i2c_bus = &dev->i2c_bus[1]; 1515 1516 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1517 &tbs_cx24116_config, 1518 &i2c_bus->i2c_adap); 1519 if (fe0->dvb.frontend != NULL) 1520 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage; 1521 1522 break; 1523 case CX23885_BOARD_TBS_6980: 1524 case CX23885_BOARD_TBS_6981: 1525 i2c_bus = &dev->i2c_bus[1]; 1526 1527 switch (port->nr) { 1528 /* PORT B */ 1529 case 1: 1530 fe0->dvb.frontend = dvb_attach(cx24117_attach, 1531 &tbs_cx24117_config, 1532 &i2c_bus->i2c_adap); 1533 break; 1534 /* PORT C */ 1535 case 2: 1536 fe0->dvb.frontend = dvb_attach(cx24117_attach, 1537 &tbs_cx24117_config, 1538 &i2c_bus->i2c_adap); 1539 break; 1540 } 1541 break; 1542 case CX23885_BOARD_TEVII_S470: 1543 i2c_bus = &dev->i2c_bus[1]; 1544 1545 fe0->dvb.frontend = dvb_attach(ds3000_attach, 1546 &tevii_ds3000_config, 1547 &i2c_bus->i2c_adap); 1548 if (fe0->dvb.frontend != NULL) { 1549 dvb_attach(ts2020_attach, fe0->dvb.frontend, 1550 &tevii_ts2020_config, &i2c_bus->i2c_adap); 1551 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage; 1552 } 1553 1554 break; 1555 case CX23885_BOARD_DVBWORLD_2005: 1556 i2c_bus = &dev->i2c_bus[1]; 1557 1558 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1559 &dvbworld_cx24116_config, 1560 &i2c_bus->i2c_adap); 1561 break; 1562 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: 1563 i2c_bus = &dev->i2c_bus[0]; 1564 switch (port->nr) { 1565 /* port B */ 1566 case 1: 1567 fe0->dvb.frontend = dvb_attach(stv0900_attach, 1568 &netup_stv0900_config, 1569 &i2c_bus->i2c_adap, 0); 1570 if (fe0->dvb.frontend != NULL) { 1571 if (dvb_attach(stv6110_attach, 1572 fe0->dvb.frontend, 1573 &netup_stv6110_tunerconfig_a, 1574 &i2c_bus->i2c_adap)) { 1575 if (!dvb_attach(lnbh24_attach, 1576 fe0->dvb.frontend, 1577 &i2c_bus->i2c_adap, 1578 LNBH24_PCL | LNBH24_TTX, 1579 LNBH24_TEN, 0x09)) 1580 printk(KERN_ERR 1581 "No LNBH24 found!\n"); 1582 1583 } 1584 } 1585 break; 1586 /* port C */ 1587 case 2: 1588 fe0->dvb.frontend = dvb_attach(stv0900_attach, 1589 &netup_stv0900_config, 1590 &i2c_bus->i2c_adap, 1); 1591 if (fe0->dvb.frontend != NULL) { 1592 if (dvb_attach(stv6110_attach, 1593 fe0->dvb.frontend, 1594 &netup_stv6110_tunerconfig_b, 1595 &i2c_bus->i2c_adap)) { 1596 if (!dvb_attach(lnbh24_attach, 1597 fe0->dvb.frontend, 1598 &i2c_bus->i2c_adap, 1599 LNBH24_PCL | LNBH24_TTX, 1600 LNBH24_TEN, 0x0a)) 1601 printk(KERN_ERR 1602 "No LNBH24 found!\n"); 1603 1604 } 1605 } 1606 break; 1607 } 1608 break; 1609 case CX23885_BOARD_MYGICA_X8506: 1610 i2c_bus = &dev->i2c_bus[0]; 1611 i2c_bus2 = &dev->i2c_bus[1]; 1612 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, 1613 &mygica_x8506_lgs8gl5_config, 1614 &i2c_bus->i2c_adap); 1615 if (fe0->dvb.frontend == NULL) 1616 break; 1617 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1618 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config); 1619 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1620 break; 1621 case CX23885_BOARD_MYGICA_X8507: 1622 i2c_bus = &dev->i2c_bus[0]; 1623 i2c_bus2 = &dev->i2c_bus[1]; 1624 fe0->dvb.frontend = dvb_attach(mb86a20s_attach, 1625 &mygica_x8507_mb86a20s_config, 1626 &i2c_bus->i2c_adap); 1627 if (fe0->dvb.frontend == NULL) 1628 break; 1629 1630 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1631 &i2c_bus2->i2c_adap, 1632 &mygica_x8507_xc5000_config); 1633 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1634 break; 1635 case CX23885_BOARD_MAGICPRO_PROHDTVE2: 1636 i2c_bus = &dev->i2c_bus[0]; 1637 i2c_bus2 = &dev->i2c_bus[1]; 1638 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, 1639 &magicpro_prohdtve2_lgs8g75_config, 1640 &i2c_bus->i2c_adap); 1641 if (fe0->dvb.frontend == NULL) 1642 break; 1643 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1644 &i2c_bus2->i2c_adap, 1645 &magicpro_prohdtve2_xc5000_config); 1646 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1647 break; 1648 case CX23885_BOARD_HAUPPAUGE_HVR1850: 1649 i2c_bus = &dev->i2c_bus[0]; 1650 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1651 &hcw_s5h1411_config, 1652 &i2c_bus->i2c_adap); 1653 if (fe0->dvb.frontend == NULL) 1654 break; 1655 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1656 0x60, &dev->i2c_bus[0].i2c_adap, 1657 &hauppauge_tda18271_config); 1658 1659 tda18271_attach(&dev->ts1.analog_fe, 1660 0x60, &dev->i2c_bus[1].i2c_adap, 1661 &hauppauge_tda18271_config); 1662 1663 break; 1664 case CX23885_BOARD_HAUPPAUGE_HVR1290: 1665 i2c_bus = &dev->i2c_bus[0]; 1666 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1667 &hcw_s5h1411_config, 1668 &i2c_bus->i2c_adap); 1669 if (fe0->dvb.frontend == NULL) 1670 break; 1671 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1672 0x60, &dev->i2c_bus[0].i2c_adap, 1673 &hauppauge_tda18271_config); 1674 break; 1675 case CX23885_BOARD_MYGICA_X8558PRO: 1676 switch (port->nr) { 1677 /* port B */ 1678 case 1: 1679 i2c_bus = &dev->i2c_bus[0]; 1680 fe0->dvb.frontend = dvb_attach(atbm8830_attach, 1681 &mygica_x8558pro_atbm8830_cfg1, 1682 &i2c_bus->i2c_adap); 1683 if (fe0->dvb.frontend == NULL) 1684 break; 1685 dvb_attach(max2165_attach, fe0->dvb.frontend, 1686 &i2c_bus->i2c_adap, 1687 &mygic_x8558pro_max2165_cfg1); 1688 break; 1689 /* port C */ 1690 case 2: 1691 i2c_bus = &dev->i2c_bus[1]; 1692 fe0->dvb.frontend = dvb_attach(atbm8830_attach, 1693 &mygica_x8558pro_atbm8830_cfg2, 1694 &i2c_bus->i2c_adap); 1695 if (fe0->dvb.frontend == NULL) 1696 break; 1697 dvb_attach(max2165_attach, fe0->dvb.frontend, 1698 &i2c_bus->i2c_adap, 1699 &mygic_x8558pro_max2165_cfg2); 1700 } 1701 break; 1702 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: 1703 i2c_bus = &dev->i2c_bus[0]; 1704 mfe_shared = 1;/* MFE */ 1705 port->frontends.gate = 0;/* not clear for me yet */ 1706 /* ports B, C */ 1707 /* MFE frontend 1 DVB-T */ 1708 fe0->dvb.frontend = dvb_attach(stv0367ter_attach, 1709 &netup_stv0367_config[port->nr - 1], 1710 &i2c_bus->i2c_adap); 1711 if (fe0->dvb.frontend == NULL) 1712 break; 1713 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend, 1714 &i2c_bus->i2c_adap, 1715 &netup_xc5000_config[port->nr - 1])) 1716 goto frontend_detach; 1717 /* load xc5000 firmware */ 1718 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend); 1719 1720 /* MFE frontend 2 */ 1721 fe1 = vb2_dvb_get_frontend(&port->frontends, 2); 1722 if (fe1 == NULL) 1723 goto frontend_detach; 1724 /* DVB-C init */ 1725 fe1->dvb.frontend = dvb_attach(stv0367cab_attach, 1726 &netup_stv0367_config[port->nr - 1], 1727 &i2c_bus->i2c_adap); 1728 if (fe1->dvb.frontend == NULL) 1729 break; 1730 1731 fe1->dvb.frontend->id = 1; 1732 if (NULL == dvb_attach(xc5000_attach, 1733 fe1->dvb.frontend, 1734 &i2c_bus->i2c_adap, 1735 &netup_xc5000_config[port->nr - 1])) 1736 goto frontend_detach; 1737 break; 1738 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: 1739 i2c_bus = &dev->i2c_bus[0]; 1740 i2c_bus2 = &dev->i2c_bus[1]; 1741 1742 switch (port->nr) { 1743 /* port b */ 1744 case 1: 1745 fe0->dvb.frontend = dvb_attach(drxk_attach, 1746 &terratec_drxk_config[0], 1747 &i2c_bus->i2c_adap); 1748 if (fe0->dvb.frontend == NULL) 1749 break; 1750 if (!dvb_attach(mt2063_attach, 1751 fe0->dvb.frontend, 1752 &terratec_mt2063_config[0], 1753 &i2c_bus2->i2c_adap)) 1754 goto frontend_detach; 1755 break; 1756 /* port c */ 1757 case 2: 1758 fe0->dvb.frontend = dvb_attach(drxk_attach, 1759 &terratec_drxk_config[1], 1760 &i2c_bus->i2c_adap); 1761 if (fe0->dvb.frontend == NULL) 1762 break; 1763 if (!dvb_attach(mt2063_attach, 1764 fe0->dvb.frontend, 1765 &terratec_mt2063_config[1], 1766 &i2c_bus2->i2c_adap)) 1767 goto frontend_detach; 1768 break; 1769 } 1770 break; 1771 case CX23885_BOARD_TEVII_S471: 1772 i2c_bus = &dev->i2c_bus[1]; 1773 1774 fe0->dvb.frontend = dvb_attach(ds3000_attach, 1775 &tevii_ds3000_config, 1776 &i2c_bus->i2c_adap); 1777 if (fe0->dvb.frontend == NULL) 1778 break; 1779 dvb_attach(ts2020_attach, fe0->dvb.frontend, 1780 &tevii_ts2020_config, &i2c_bus->i2c_adap); 1781 break; 1782 case CX23885_BOARD_PROF_8000: 1783 i2c_bus = &dev->i2c_bus[0]; 1784 1785 fe0->dvb.frontend = dvb_attach(stv090x_attach, 1786 &prof_8000_stv090x_config, 1787 &i2c_bus->i2c_adap, 1788 STV090x_DEMODULATOR_0); 1789 if (fe0->dvb.frontend == NULL) 1790 break; 1791 if (!dvb_attach(stb6100_attach, 1792 fe0->dvb.frontend, 1793 &prof_8000_stb6100_config, 1794 &i2c_bus->i2c_adap)) 1795 goto frontend_detach; 1796 1797 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage; 1798 break; 1799 case CX23885_BOARD_HAUPPAUGE_HVR4400: { 1800 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata; 1801 struct a8293_platform_data a8293_pdata = {}; 1802 1803 i2c_bus = &dev->i2c_bus[0]; 1804 i2c_bus2 = &dev->i2c_bus[1]; 1805 switch (port->nr) { 1806 /* port b */ 1807 case 1: 1808 /* attach demod + tuner combo */ 1809 memset(&info, 0, sizeof(info)); 1810 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE); 1811 info.addr = 0x05; 1812 info.platform_data = &tda10071_pdata; 1813 request_module("tda10071"); 1814 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); 1815 if (!client_demod || !client_demod->dev.driver) 1816 goto frontend_detach; 1817 if (!try_module_get(client_demod->dev.driver->owner)) { 1818 i2c_unregister_device(client_demod); 1819 goto frontend_detach; 1820 } 1821 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod); 1822 port->i2c_client_demod = client_demod; 1823 1824 /* attach SEC */ 1825 a8293_pdata.dvb_frontend = fe0->dvb.frontend; 1826 memset(&info, 0, sizeof(info)); 1827 strlcpy(info.type, "a8293", I2C_NAME_SIZE); 1828 info.addr = 0x0b; 1829 info.platform_data = &a8293_pdata; 1830 request_module("a8293"); 1831 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info); 1832 if (!client_sec || !client_sec->dev.driver) 1833 goto frontend_detach; 1834 if (!try_module_get(client_sec->dev.driver->owner)) { 1835 i2c_unregister_device(client_sec); 1836 goto frontend_detach; 1837 } 1838 port->i2c_client_sec = client_sec; 1839 break; 1840 /* port c */ 1841 case 2: 1842 fe0->dvb.frontend = dvb_attach(si2165_attach, 1843 &hauppauge_hvr4400_si2165_config, 1844 &i2c_bus->i2c_adap); 1845 if (fe0->dvb.frontend == NULL) 1846 break; 1847 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 1848 if (!dvb_attach(tda18271_attach, 1849 fe0->dvb.frontend, 1850 0x60, &i2c_bus2->i2c_adap, 1851 &hauppauge_hvr4400_tuner_config)) 1852 goto frontend_detach; 1853 break; 1854 } 1855 break; 1856 } 1857 case CX23885_BOARD_HAUPPAUGE_STARBURST: { 1858 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata; 1859 struct a8293_platform_data a8293_pdata = {}; 1860 1861 i2c_bus = &dev->i2c_bus[0]; 1862 1863 /* attach demod + tuner combo */ 1864 memset(&info, 0, sizeof(info)); 1865 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE); 1866 info.addr = 0x05; 1867 info.platform_data = &tda10071_pdata; 1868 request_module("tda10071"); 1869 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); 1870 if (!client_demod || !client_demod->dev.driver) 1871 goto frontend_detach; 1872 if (!try_module_get(client_demod->dev.driver->owner)) { 1873 i2c_unregister_device(client_demod); 1874 goto frontend_detach; 1875 } 1876 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod); 1877 port->i2c_client_demod = client_demod; 1878 1879 /* attach SEC */ 1880 a8293_pdata.dvb_frontend = fe0->dvb.frontend; 1881 memset(&info, 0, sizeof(info)); 1882 strlcpy(info.type, "a8293", I2C_NAME_SIZE); 1883 info.addr = 0x0b; 1884 info.platform_data = &a8293_pdata; 1885 request_module("a8293"); 1886 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info); 1887 if (!client_sec || !client_sec->dev.driver) 1888 goto frontend_detach; 1889 if (!try_module_get(client_sec->dev.driver->owner)) { 1890 i2c_unregister_device(client_sec); 1891 goto frontend_detach; 1892 } 1893 port->i2c_client_sec = client_sec; 1894 break; 1895 } 1896 case CX23885_BOARD_DVBSKY_T9580: 1897 case CX23885_BOARD_DVBSKY_S950: 1898 i2c_bus = &dev->i2c_bus[0]; 1899 i2c_bus2 = &dev->i2c_bus[1]; 1900 switch (port->nr) { 1901 /* port b - satellite */ 1902 case 1: 1903 /* attach frontend */ 1904 fe0->dvb.frontend = dvb_attach(m88ds3103_attach, 1905 &dvbsky_t9580_m88ds3103_config, 1906 &i2c_bus2->i2c_adap, &adapter); 1907 if (fe0->dvb.frontend == NULL) 1908 break; 1909 1910 /* attach tuner */ 1911 memset(&ts2020_config, 0, sizeof(ts2020_config)); 1912 ts2020_config.fe = fe0->dvb.frontend; 1913 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm; 1914 memset(&info, 0, sizeof(struct i2c_board_info)); 1915 strlcpy(info.type, "ts2020", I2C_NAME_SIZE); 1916 info.addr = 0x60; 1917 info.platform_data = &ts2020_config; 1918 request_module(info.type); 1919 client_tuner = i2c_new_device(adapter, &info); 1920 if (client_tuner == NULL || 1921 client_tuner->dev.driver == NULL) 1922 goto frontend_detach; 1923 if (!try_module_get(client_tuner->dev.driver->owner)) { 1924 i2c_unregister_device(client_tuner); 1925 goto frontend_detach; 1926 } 1927 1928 /* delegate signal strength measurement to tuner */ 1929 fe0->dvb.frontend->ops.read_signal_strength = 1930 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; 1931 1932 /* 1933 * for setting the voltage we need to set GPIOs on 1934 * the card. 1935 */ 1936 port->fe_set_voltage = 1937 fe0->dvb.frontend->ops.set_voltage; 1938 fe0->dvb.frontend->ops.set_voltage = 1939 dvbsky_t9580_set_voltage; 1940 1941 port->i2c_client_tuner = client_tuner; 1942 1943 break; 1944 /* port c - terrestrial/cable */ 1945 case 2: 1946 /* attach frontend */ 1947 memset(&si2168_config, 0, sizeof(si2168_config)); 1948 si2168_config.i2c_adapter = &adapter; 1949 si2168_config.fe = &fe0->dvb.frontend; 1950 si2168_config.ts_mode = SI2168_TS_SERIAL; 1951 memset(&info, 0, sizeof(struct i2c_board_info)); 1952 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 1953 info.addr = 0x64; 1954 info.platform_data = &si2168_config; 1955 request_module(info.type); 1956 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); 1957 if (client_demod == NULL || 1958 client_demod->dev.driver == NULL) 1959 goto frontend_detach; 1960 if (!try_module_get(client_demod->dev.driver->owner)) { 1961 i2c_unregister_device(client_demod); 1962 goto frontend_detach; 1963 } 1964 port->i2c_client_demod = client_demod; 1965 1966 /* attach tuner */ 1967 memset(&si2157_config, 0, sizeof(si2157_config)); 1968 si2157_config.fe = fe0->dvb.frontend; 1969 si2157_config.if_port = 1; 1970 memset(&info, 0, sizeof(struct i2c_board_info)); 1971 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 1972 info.addr = 0x60; 1973 info.platform_data = &si2157_config; 1974 request_module(info.type); 1975 client_tuner = i2c_new_device(adapter, &info); 1976 if (client_tuner == NULL || 1977 client_tuner->dev.driver == NULL) 1978 goto frontend_detach; 1979 1980 if (!try_module_get(client_tuner->dev.driver->owner)) { 1981 i2c_unregister_device(client_tuner); 1982 goto frontend_detach; 1983 } 1984 port->i2c_client_tuner = client_tuner; 1985 break; 1986 } 1987 break; 1988 case CX23885_BOARD_DVBSKY_T980C: 1989 case CX23885_BOARD_TT_CT2_4500_CI: 1990 i2c_bus = &dev->i2c_bus[0]; 1991 i2c_bus2 = &dev->i2c_bus[1]; 1992 1993 /* attach frontend */ 1994 memset(&si2168_config, 0, sizeof(si2168_config)); 1995 si2168_config.i2c_adapter = &adapter; 1996 si2168_config.fe = &fe0->dvb.frontend; 1997 si2168_config.ts_mode = SI2168_TS_PARALLEL; 1998 memset(&info, 0, sizeof(struct i2c_board_info)); 1999 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 2000 info.addr = 0x64; 2001 info.platform_data = &si2168_config; 2002 request_module(info.type); 2003 client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info); 2004 if (client_demod == NULL || client_demod->dev.driver == NULL) 2005 goto frontend_detach; 2006 if (!try_module_get(client_demod->dev.driver->owner)) { 2007 i2c_unregister_device(client_demod); 2008 goto frontend_detach; 2009 } 2010 port->i2c_client_demod = client_demod; 2011 2012 /* attach tuner */ 2013 memset(&si2157_config, 0, sizeof(si2157_config)); 2014 si2157_config.fe = fe0->dvb.frontend; 2015 si2157_config.if_port = 1; 2016 memset(&info, 0, sizeof(struct i2c_board_info)); 2017 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 2018 info.addr = 0x60; 2019 info.platform_data = &si2157_config; 2020 request_module(info.type); 2021 client_tuner = i2c_new_device(adapter, &info); 2022 if (client_tuner == NULL || 2023 client_tuner->dev.driver == NULL) 2024 goto frontend_detach; 2025 if (!try_module_get(client_tuner->dev.driver->owner)) { 2026 i2c_unregister_device(client_tuner); 2027 goto frontend_detach; 2028 } 2029 port->i2c_client_tuner = client_tuner; 2030 break; 2031 case CX23885_BOARD_DVBSKY_S950C: 2032 i2c_bus = &dev->i2c_bus[0]; 2033 i2c_bus2 = &dev->i2c_bus[1]; 2034 2035 /* attach frontend */ 2036 fe0->dvb.frontend = dvb_attach(m88ds3103_attach, 2037 &dvbsky_s950c_m88ds3103_config, 2038 &i2c_bus2->i2c_adap, &adapter); 2039 if (fe0->dvb.frontend == NULL) 2040 break; 2041 2042 /* attach tuner */ 2043 memset(&ts2020_config, 0, sizeof(ts2020_config)); 2044 ts2020_config.fe = fe0->dvb.frontend; 2045 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm; 2046 memset(&info, 0, sizeof(struct i2c_board_info)); 2047 strlcpy(info.type, "ts2020", I2C_NAME_SIZE); 2048 info.addr = 0x60; 2049 info.platform_data = &ts2020_config; 2050 request_module(info.type); 2051 client_tuner = i2c_new_device(adapter, &info); 2052 if (client_tuner == NULL || client_tuner->dev.driver == NULL) 2053 goto frontend_detach; 2054 if (!try_module_get(client_tuner->dev.driver->owner)) { 2055 i2c_unregister_device(client_tuner); 2056 goto frontend_detach; 2057 } 2058 2059 /* delegate signal strength measurement to tuner */ 2060 fe0->dvb.frontend->ops.read_signal_strength = 2061 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; 2062 2063 port->i2c_client_tuner = client_tuner; 2064 break; 2065 case CX23885_BOARD_DVBSKY_S952: 2066 switch (port->nr) { 2067 /* port b */ 2068 case 1: 2069 i2c_bus = &dev->i2c_bus[1]; 2070 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config; 2071 p_set_voltage = dvbsky_t9580_set_voltage; 2072 break; 2073 /* port c */ 2074 case 2: 2075 i2c_bus = &dev->i2c_bus[0]; 2076 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config; 2077 p_set_voltage = dvbsky_s952_portc_set_voltage; 2078 break; 2079 } 2080 2081 /* attach frontend */ 2082 fe0->dvb.frontend = dvb_attach(m88ds3103_attach, 2083 p_m88ds3103_config, 2084 &i2c_bus->i2c_adap, &adapter); 2085 if (fe0->dvb.frontend == NULL) 2086 break; 2087 2088 /* attach tuner */ 2089 memset(&ts2020_config, 0, sizeof(ts2020_config)); 2090 ts2020_config.fe = fe0->dvb.frontend; 2091 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm; 2092 memset(&info, 0, sizeof(struct i2c_board_info)); 2093 strlcpy(info.type, "ts2020", I2C_NAME_SIZE); 2094 info.addr = 0x60; 2095 info.platform_data = &ts2020_config; 2096 request_module(info.type); 2097 client_tuner = i2c_new_device(adapter, &info); 2098 if (client_tuner == NULL || client_tuner->dev.driver == NULL) 2099 goto frontend_detach; 2100 if (!try_module_get(client_tuner->dev.driver->owner)) { 2101 i2c_unregister_device(client_tuner); 2102 goto frontend_detach; 2103 } 2104 2105 /* delegate signal strength measurement to tuner */ 2106 fe0->dvb.frontend->ops.read_signal_strength = 2107 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; 2108 2109 /* 2110 * for setting the voltage we need to set GPIOs on 2111 * the card. 2112 */ 2113 port->fe_set_voltage = 2114 fe0->dvb.frontend->ops.set_voltage; 2115 fe0->dvb.frontend->ops.set_voltage = p_set_voltage; 2116 2117 port->i2c_client_tuner = client_tuner; 2118 break; 2119 case CX23885_BOARD_DVBSKY_T982: 2120 memset(&si2168_config, 0, sizeof(si2168_config)); 2121 switch (port->nr) { 2122 /* port b */ 2123 case 1: 2124 i2c_bus = &dev->i2c_bus[1]; 2125 si2168_config.ts_mode = SI2168_TS_PARALLEL; 2126 break; 2127 /* port c */ 2128 case 2: 2129 i2c_bus = &dev->i2c_bus[0]; 2130 si2168_config.ts_mode = SI2168_TS_SERIAL; 2131 break; 2132 } 2133 2134 /* attach frontend */ 2135 si2168_config.i2c_adapter = &adapter; 2136 si2168_config.fe = &fe0->dvb.frontend; 2137 memset(&info, 0, sizeof(struct i2c_board_info)); 2138 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 2139 info.addr = 0x64; 2140 info.platform_data = &si2168_config; 2141 request_module(info.type); 2142 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info); 2143 if (client_demod == NULL || client_demod->dev.driver == NULL) 2144 goto frontend_detach; 2145 if (!try_module_get(client_demod->dev.driver->owner)) { 2146 i2c_unregister_device(client_demod); 2147 goto frontend_detach; 2148 } 2149 port->i2c_client_demod = client_demod; 2150 2151 /* attach tuner */ 2152 memset(&si2157_config, 0, sizeof(si2157_config)); 2153 si2157_config.fe = fe0->dvb.frontend; 2154 si2157_config.if_port = 1; 2155 memset(&info, 0, sizeof(struct i2c_board_info)); 2156 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 2157 info.addr = 0x60; 2158 info.platform_data = &si2157_config; 2159 request_module(info.type); 2160 client_tuner = i2c_new_device(adapter, &info); 2161 if (client_tuner == NULL || 2162 client_tuner->dev.driver == NULL) 2163 goto frontend_detach; 2164 if (!try_module_get(client_tuner->dev.driver->owner)) { 2165 i2c_unregister_device(client_tuner); 2166 goto frontend_detach; 2167 } 2168 port->i2c_client_tuner = client_tuner; 2169 break; 2170 case CX23885_BOARD_HAUPPAUGE_HVR5525: { 2171 struct m88rs6000t_config m88rs6000t_config; 2172 struct a8293_platform_data a8293_pdata = {}; 2173 2174 switch (port->nr) { 2175 2176 /* port b - satellite */ 2177 case 1: 2178 /* attach frontend */ 2179 fe0->dvb.frontend = dvb_attach(m88ds3103_attach, 2180 &hauppauge_hvr5525_m88ds3103_config, 2181 &dev->i2c_bus[0].i2c_adap, &adapter); 2182 if (fe0->dvb.frontend == NULL) 2183 break; 2184 2185 /* attach SEC */ 2186 a8293_pdata.dvb_frontend = fe0->dvb.frontend; 2187 memset(&info, 0, sizeof(info)); 2188 strlcpy(info.type, "a8293", I2C_NAME_SIZE); 2189 info.addr = 0x0b; 2190 info.platform_data = &a8293_pdata; 2191 request_module("a8293"); 2192 client_sec = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info); 2193 if (!client_sec || !client_sec->dev.driver) 2194 goto frontend_detach; 2195 if (!try_module_get(client_sec->dev.driver->owner)) { 2196 i2c_unregister_device(client_sec); 2197 goto frontend_detach; 2198 } 2199 port->i2c_client_sec = client_sec; 2200 2201 /* attach tuner */ 2202 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config)); 2203 m88rs6000t_config.fe = fe0->dvb.frontend; 2204 memset(&info, 0, sizeof(struct i2c_board_info)); 2205 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE); 2206 info.addr = 0x21; 2207 info.platform_data = &m88rs6000t_config; 2208 request_module("%s", info.type); 2209 client_tuner = i2c_new_device(adapter, &info); 2210 if (!client_tuner || !client_tuner->dev.driver) 2211 goto frontend_detach; 2212 if (!try_module_get(client_tuner->dev.driver->owner)) { 2213 i2c_unregister_device(client_tuner); 2214 goto frontend_detach; 2215 } 2216 port->i2c_client_tuner = client_tuner; 2217 2218 /* delegate signal strength measurement to tuner */ 2219 fe0->dvb.frontend->ops.read_signal_strength = 2220 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength; 2221 break; 2222 /* port c - terrestrial/cable */ 2223 case 2: 2224 /* attach frontend */ 2225 memset(&si2168_config, 0, sizeof(si2168_config)); 2226 si2168_config.i2c_adapter = &adapter; 2227 si2168_config.fe = &fe0->dvb.frontend; 2228 si2168_config.ts_mode = SI2168_TS_SERIAL; 2229 memset(&info, 0, sizeof(struct i2c_board_info)); 2230 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 2231 info.addr = 0x64; 2232 info.platform_data = &si2168_config; 2233 request_module("%s", info.type); 2234 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info); 2235 if (!client_demod || !client_demod->dev.driver) 2236 goto frontend_detach; 2237 if (!try_module_get(client_demod->dev.driver->owner)) { 2238 i2c_unregister_device(client_demod); 2239 goto frontend_detach; 2240 } 2241 port->i2c_client_demod = client_demod; 2242 2243 /* attach tuner */ 2244 memset(&si2157_config, 0, sizeof(si2157_config)); 2245 si2157_config.fe = fe0->dvb.frontend; 2246 si2157_config.if_port = 1; 2247 memset(&info, 0, sizeof(struct i2c_board_info)); 2248 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 2249 info.addr = 0x60; 2250 info.platform_data = &si2157_config; 2251 request_module("%s", info.type); 2252 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info); 2253 if (!client_tuner || !client_tuner->dev.driver) { 2254 module_put(client_demod->dev.driver->owner); 2255 i2c_unregister_device(client_demod); 2256 port->i2c_client_demod = NULL; 2257 goto frontend_detach; 2258 } 2259 if (!try_module_get(client_tuner->dev.driver->owner)) { 2260 i2c_unregister_device(client_tuner); 2261 module_put(client_demod->dev.driver->owner); 2262 i2c_unregister_device(client_demod); 2263 port->i2c_client_demod = NULL; 2264 goto frontend_detach; 2265 } 2266 port->i2c_client_tuner = client_tuner; 2267 break; 2268 } 2269 break; 2270 } 2271 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB: 2272 switch (port->nr) { 2273 /* port b - Terrestrial/cable */ 2274 case 1: 2275 /* attach frontend */ 2276 memset(&si2168_config, 0, sizeof(si2168_config)); 2277 si2168_config.i2c_adapter = &adapter; 2278 si2168_config.fe = &fe0->dvb.frontend; 2279 si2168_config.ts_mode = SI2168_TS_SERIAL; 2280 memset(&info, 0, sizeof(struct i2c_board_info)); 2281 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 2282 info.addr = 0x64; 2283 info.platform_data = &si2168_config; 2284 request_module("%s", info.type); 2285 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info); 2286 if (!client_demod || !client_demod->dev.driver) 2287 goto frontend_detach; 2288 if (!try_module_get(client_demod->dev.driver->owner)) { 2289 i2c_unregister_device(client_demod); 2290 goto frontend_detach; 2291 } 2292 port->i2c_client_demod = client_demod; 2293 2294 /* attach tuner */ 2295 memset(&si2157_config, 0, sizeof(si2157_config)); 2296 si2157_config.fe = fe0->dvb.frontend; 2297 si2157_config.if_port = 1; 2298 memset(&info, 0, sizeof(struct i2c_board_info)); 2299 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 2300 info.addr = 0x60; 2301 info.platform_data = &si2157_config; 2302 request_module("%s", info.type); 2303 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info); 2304 if (!client_tuner || !client_tuner->dev.driver) { 2305 module_put(client_demod->dev.driver->owner); 2306 i2c_unregister_device(client_demod); 2307 port->i2c_client_demod = NULL; 2308 goto frontend_detach; 2309 } 2310 if (!try_module_get(client_tuner->dev.driver->owner)) { 2311 i2c_unregister_device(client_tuner); 2312 module_put(client_demod->dev.driver->owner); 2313 i2c_unregister_device(client_demod); 2314 port->i2c_client_demod = NULL; 2315 goto frontend_detach; 2316 } 2317 port->i2c_client_tuner = client_tuner; 2318 break; 2319 2320 /* port c - terrestrial/cable */ 2321 case 2: 2322 /* attach frontend */ 2323 memset(&si2168_config, 0, sizeof(si2168_config)); 2324 si2168_config.i2c_adapter = &adapter; 2325 si2168_config.fe = &fe0->dvb.frontend; 2326 si2168_config.ts_mode = SI2168_TS_SERIAL; 2327 memset(&info, 0, sizeof(struct i2c_board_info)); 2328 strlcpy(info.type, "si2168", I2C_NAME_SIZE); 2329 info.addr = 0x66; 2330 info.platform_data = &si2168_config; 2331 request_module("%s", info.type); 2332 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info); 2333 if (!client_demod || !client_demod->dev.driver) 2334 goto frontend_detach; 2335 if (!try_module_get(client_demod->dev.driver->owner)) { 2336 i2c_unregister_device(client_demod); 2337 goto frontend_detach; 2338 } 2339 port->i2c_client_demod = client_demod; 2340 2341 /* attach tuner */ 2342 memset(&si2157_config, 0, sizeof(si2157_config)); 2343 si2157_config.fe = fe0->dvb.frontend; 2344 si2157_config.if_port = 1; 2345 memset(&info, 0, sizeof(struct i2c_board_info)); 2346 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 2347 info.addr = 0x62; 2348 info.platform_data = &si2157_config; 2349 request_module("%s", info.type); 2350 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info); 2351 if (!client_tuner || !client_tuner->dev.driver) { 2352 module_put(client_demod->dev.driver->owner); 2353 i2c_unregister_device(client_demod); 2354 port->i2c_client_demod = NULL; 2355 goto frontend_detach; 2356 } 2357 if (!try_module_get(client_tuner->dev.driver->owner)) { 2358 i2c_unregister_device(client_tuner); 2359 module_put(client_demod->dev.driver->owner); 2360 i2c_unregister_device(client_demod); 2361 port->i2c_client_demod = NULL; 2362 goto frontend_detach; 2363 } 2364 port->i2c_client_tuner = client_tuner; 2365 break; 2366 } 2367 break; 2368 2369 default: 2370 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 2371 " isn't supported yet\n", 2372 dev->name); 2373 break; 2374 } 2375 2376 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) { 2377 printk(KERN_ERR "%s: frontend initialization failed\n", 2378 dev->name); 2379 goto frontend_detach; 2380 } 2381 2382 /* define general-purpose callback pointer */ 2383 fe0->dvb.frontend->callback = cx23885_tuner_callback; 2384 if (fe1) 2385 fe1->dvb.frontend->callback = cx23885_tuner_callback; 2386 #if 0 2387 /* Ensure all frontends negotiate bus access */ 2388 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl; 2389 if (fe1) 2390 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl; 2391 #endif 2392 2393 /* Put the analog decoder in standby to keep it quiet */ 2394 call_all(dev, core, s_power, 0); 2395 2396 if (fe0->dvb.frontend->ops.analog_ops.standby) 2397 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); 2398 2399 /* register everything */ 2400 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port, 2401 &dev->pci->dev, NULL, 2402 adapter_nr, mfe_shared); 2403 if (ret) 2404 goto frontend_detach; 2405 2406 ret = dvb_register_ci_mac(port); 2407 if (ret) 2408 goto frontend_detach; 2409 2410 return 0; 2411 2412 frontend_detach: 2413 /* remove I2C client for SEC */ 2414 client_sec = port->i2c_client_sec; 2415 if (client_sec) { 2416 module_put(client_sec->dev.driver->owner); 2417 i2c_unregister_device(client_sec); 2418 port->i2c_client_sec = NULL; 2419 } 2420 2421 /* remove I2C client for tuner */ 2422 client_tuner = port->i2c_client_tuner; 2423 if (client_tuner) { 2424 module_put(client_tuner->dev.driver->owner); 2425 i2c_unregister_device(client_tuner); 2426 port->i2c_client_tuner = NULL; 2427 } 2428 2429 /* remove I2C client for demodulator */ 2430 client_demod = port->i2c_client_demod; 2431 if (client_demod) { 2432 module_put(client_demod->dev.driver->owner); 2433 i2c_unregister_device(client_demod); 2434 port->i2c_client_demod = NULL; 2435 } 2436 2437 port->gate_ctrl = NULL; 2438 vb2_dvb_dealloc_frontends(&port->frontends); 2439 return -EINVAL; 2440 } 2441 2442 int cx23885_dvb_register(struct cx23885_tsport *port) 2443 { 2444 2445 struct vb2_dvb_frontend *fe0; 2446 struct cx23885_dev *dev = port->dev; 2447 int err, i; 2448 2449 /* Here we need to allocate the correct number of frontends, 2450 * as reflected in the cards struct. The reality is that currently 2451 * no cx23885 boards support this - yet. But, if we don't modify this 2452 * code then the second frontend would never be allocated (later) 2453 * and fail with error before the attach in dvb_register(). 2454 * Without these changes we risk an OOPS later. The changes here 2455 * are for safety, and should provide a good foundation for the 2456 * future addition of any multi-frontend cx23885 based boards. 2457 */ 2458 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__, 2459 port->num_frontends); 2460 2461 for (i = 1; i <= port->num_frontends; i++) { 2462 struct vb2_queue *q; 2463 2464 if (vb2_dvb_alloc_frontend( 2465 &port->frontends, i) == NULL) { 2466 printk(KERN_ERR "%s() failed to alloc\n", __func__); 2467 return -ENOMEM; 2468 } 2469 2470 fe0 = vb2_dvb_get_frontend(&port->frontends, i); 2471 if (!fe0) 2472 return -EINVAL; 2473 2474 dprintk(1, "%s\n", __func__); 2475 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", 2476 dev->board, 2477 dev->name, 2478 dev->pci_bus, 2479 dev->pci_slot); 2480 2481 err = -ENODEV; 2482 2483 /* dvb stuff */ 2484 /* We have to init the queue for each frontend on a port. */ 2485 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name); 2486 q = &fe0->dvb.dvbq; 2487 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 2488 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; 2489 q->gfp_flags = GFP_DMA32; 2490 q->min_buffers_needed = 2; 2491 q->drv_priv = port; 2492 q->buf_struct_size = sizeof(struct cx23885_buffer); 2493 q->ops = &dvb_qops; 2494 q->mem_ops = &vb2_dma_sg_memops; 2495 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 2496 q->lock = &dev->lock; 2497 q->dev = &dev->pci->dev; 2498 2499 err = vb2_queue_init(q); 2500 if (err < 0) 2501 return err; 2502 } 2503 err = dvb_register(port); 2504 if (err != 0) 2505 printk(KERN_ERR "%s() dvb_register failed err = %d\n", 2506 __func__, err); 2507 2508 return err; 2509 } 2510 2511 int cx23885_dvb_unregister(struct cx23885_tsport *port) 2512 { 2513 struct vb2_dvb_frontend *fe0; 2514 struct i2c_client *client; 2515 2516 /* remove I2C client for CI */ 2517 client = port->i2c_client_ci; 2518 if (client) { 2519 module_put(client->dev.driver->owner); 2520 i2c_unregister_device(client); 2521 } 2522 2523 /* remove I2C client for SEC */ 2524 client = port->i2c_client_sec; 2525 if (client) { 2526 module_put(client->dev.driver->owner); 2527 i2c_unregister_device(client); 2528 } 2529 2530 /* remove I2C client for tuner */ 2531 client = port->i2c_client_tuner; 2532 if (client) { 2533 module_put(client->dev.driver->owner); 2534 i2c_unregister_device(client); 2535 } 2536 2537 /* remove I2C client for demodulator */ 2538 client = port->i2c_client_demod; 2539 if (client) { 2540 module_put(client->dev.driver->owner); 2541 i2c_unregister_device(client); 2542 } 2543 2544 fe0 = vb2_dvb_get_frontend(&port->frontends, 1); 2545 2546 if (fe0 && fe0->dvb.frontend) 2547 vb2_dvb_unregister_bus(&port->frontends); 2548 2549 switch (port->dev->board) { 2550 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: 2551 netup_ci_exit(port); 2552 break; 2553 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: 2554 altera_ci_release(port->dev, port->nr); 2555 break; 2556 } 2557 2558 port->gate_ctrl = NULL; 2559 2560 return 0; 2561 } 2562