diff options
Diffstat (limited to 'drivers/media/dvb/b2c2/flexcop-fe-tuner.c')
-rw-r--r-- | drivers/media/dvb/b2c2/flexcop-fe-tuner.c | 211 |
1 files changed, 164 insertions, 47 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0378fd646591..7b0ea3bdfafb 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c | |||
@@ -5,6 +5,8 @@ | |||
5 | * | 5 | * |
6 | * see flexcop.c for copyright information. | 6 | * see flexcop.c for copyright information. |
7 | */ | 7 | */ |
8 | #include <media/tuner.h> | ||
9 | |||
8 | #include "flexcop.h" | 10 | #include "flexcop.h" |
9 | 11 | ||
10 | #include "stv0299.h" | 12 | #include "stv0299.h" |
@@ -15,6 +17,15 @@ | |||
15 | #include "mt312.h" | 17 | #include "mt312.h" |
16 | #include "lgdt330x.h" | 18 | #include "lgdt330x.h" |
17 | #include "dvb-pll.h" | 19 | #include "dvb-pll.h" |
20 | #include "tuner-simple.h" | ||
21 | |||
22 | #include "s5h1420.h" | ||
23 | #include "itd1000.h" | ||
24 | |||
25 | #include "cx24123.h" | ||
26 | #include "cx24113.h" | ||
27 | |||
28 | #include "isl6421.h" | ||
18 | 29 | ||
19 | /* lnb control */ | 30 | /* lnb control */ |
20 | 31 | ||
@@ -180,13 +191,13 @@ static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dv | |||
180 | buf[2] = 0x84; /* 0xC4 */ | 191 | buf[2] = 0x84; /* 0xC4 */ |
181 | buf[3] = 0x08; | 192 | buf[3] = 0x08; |
182 | 193 | ||
183 | if (params->frequency < 1500000) buf[3] |= 0x10; | 194 | if (params->frequency < 1500000) |
195 | buf[3] |= 0x10; | ||
184 | 196 | ||
185 | if (fe->ops.i2c_gate_ctrl) | 197 | if (fe->ops.i2c_gate_ctrl) |
186 | fe->ops.i2c_gate_ctrl(fe, 1); | 198 | fe->ops.i2c_gate_ctrl(fe, 1); |
187 | if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) { | 199 | if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) |
188 | return -EIO; | 200 | return -EIO; |
189 | } | ||
190 | return 0; | 201 | return 0; |
191 | } | 202 | } |
192 | 203 | ||
@@ -241,7 +252,7 @@ static struct stv0299_config samsung_tbmu24112_config = { | |||
241 | .mclk = 88000000UL, | 252 | .mclk = 88000000UL, |
242 | .invert = 0, | 253 | .invert = 0, |
243 | .skip_reinit = 0, | 254 | .skip_reinit = 0, |
244 | .lock_output = STV0229_LOCKOUTPUT_LK, | 255 | .lock_output = STV0299_LOCKOUTPUT_LK, |
245 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | 256 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
246 | .min_delay_ms = 100, | 257 | .min_delay_ms = 100, |
247 | .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, | 258 | .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, |
@@ -337,7 +348,7 @@ static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe, | |||
337 | 348 | ||
338 | if (fe->ops.i2c_gate_ctrl) | 349 | if (fe->ops.i2c_gate_ctrl) |
339 | fe->ops.i2c_gate_ctrl(fe, 1); | 350 | fe->ops.i2c_gate_ctrl(fe, 1); |
340 | if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) | 351 | if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) |
341 | return -EIO; | 352 | return -EIO; |
342 | return 0; | 353 | return 0; |
343 | } | 354 | } |
@@ -386,10 +397,11 @@ static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe, | |||
386 | if (fe->ops.i2c_gate_ctrl) | 397 | if (fe->ops.i2c_gate_ctrl) |
387 | fe->ops.i2c_gate_ctrl(fe, 0); | 398 | fe->ops.i2c_gate_ctrl(fe, 0); |
388 | deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]); | 399 | deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]); |
389 | ret = fc->i2c_request(fc, FC_WRITE, FC_I2C_PORT_TUNER, 0x61, buf[0], &buf[1], 3); | 400 | ret = fc->i2c_request(&fc->fc_i2c_adap[2], |
401 | FC_WRITE, 0x61, buf[0], &buf[1], 3); | ||
390 | deb_tuner("tuner write returned: %d\n",ret); | 402 | deb_tuner("tuner write returned: %d\n",ret); |
391 | 403 | ||
392 | return 0; | 404 | return ret; |
393 | } | 405 | } |
394 | 406 | ||
395 | static u8 alps_tdee4_stv0297_inittab[] = { | 407 | static u8 alps_tdee4_stv0297_inittab[] = { |
@@ -472,56 +484,159 @@ static struct stv0297_config alps_tdee4_stv0297_config = { | |||
472 | // .pll_set = alps_tdee4_stv0297_pll_set, | 484 | // .pll_set = alps_tdee4_stv0297_pll_set, |
473 | }; | 485 | }; |
474 | 486 | ||
487 | |||
488 | /* SkyStar2 rev2.7 (a/u) */ | ||
489 | static struct s5h1420_config skystar2_rev2_7_s5h1420_config = { | ||
490 | .demod_address = 0x53, | ||
491 | .invert = 1, | ||
492 | .repeated_start_workaround = 1, | ||
493 | }; | ||
494 | |||
495 | static struct itd1000_config skystar2_rev2_7_itd1000_config = { | ||
496 | .i2c_address = 0x61, | ||
497 | }; | ||
498 | |||
499 | /* SkyStar2 rev2.8 */ | ||
500 | static struct cx24123_config skystar2_rev2_8_cx24123_config = { | ||
501 | .demod_address = 0x55, | ||
502 | .dont_use_pll = 1, | ||
503 | .agc_callback = cx24113_agc_callback, | ||
504 | }; | ||
505 | |||
506 | static const struct cx24113_config skystar2_rev2_8_cx24113_config = { | ||
507 | .i2c_addr = 0x54, | ||
508 | .xtal_khz = 10111, | ||
509 | }; | ||
510 | |||
475 | /* try to figure out the frontend, each card/box can have on of the following list */ | 511 | /* try to figure out the frontend, each card/box can have on of the following list */ |
476 | int flexcop_frontend_init(struct flexcop_device *fc) | 512 | int flexcop_frontend_init(struct flexcop_device *fc) |
477 | { | 513 | { |
478 | struct dvb_frontend_ops *ops; | 514 | struct dvb_frontend_ops *ops; |
515 | struct i2c_adapter *i2c = &fc->fc_i2c_adap[0].i2c_adap; | ||
516 | struct i2c_adapter *i2c_tuner; | ||
517 | |||
518 | /* enable no_base_addr - no repeated start when reading */ | ||
519 | fc->fc_i2c_adap[0].no_base_addr = 1; | ||
520 | fc->fe = dvb_attach(s5h1420_attach, &skystar2_rev2_7_s5h1420_config, i2c); | ||
521 | if (fc->fe != NULL) { | ||
522 | flexcop_ibi_value r108; | ||
523 | i2c_tuner = s5h1420_get_tuner_i2c_adapter(fc->fe); | ||
524 | ops = &fc->fe->ops; | ||
525 | |||
526 | fc->fe_sleep = ops->sleep; | ||
527 | ops->sleep = flexcop_sleep; | ||
528 | |||
529 | fc->dev_type = FC_SKY_REV27; | ||
530 | |||
531 | /* enable no_base_addr - no repeated start when reading */ | ||
532 | fc->fc_i2c_adap[2].no_base_addr = 1; | ||
533 | if (dvb_attach(isl6421_attach, fc->fe, &fc->fc_i2c_adap[2].i2c_adap, 0x08, 1, 1) == NULL) | ||
534 | err("ISL6421 could NOT be attached"); | ||
535 | else | ||
536 | info("ISL6421 successfully attached"); | ||
537 | |||
538 | /* the ITD1000 requires a lower i2c clock - it slows down the stuff for everyone - but is it a problem ? */ | ||
539 | r108.raw = 0x00000506; | ||
540 | fc->write_ibi_reg(fc, tw_sm_c_108, r108); | ||
541 | if (i2c_tuner) { | ||
542 | if (dvb_attach(itd1000_attach, fc->fe, i2c_tuner, &skystar2_rev2_7_itd1000_config) == NULL) | ||
543 | err("ITD1000 could NOT be attached"); | ||
544 | else | ||
545 | info("ITD1000 successfully attached"); | ||
546 | } | ||
547 | goto fe_found; | ||
548 | } | ||
549 | fc->fc_i2c_adap[0].no_base_addr = 0; /* for the next devices we need it again */ | ||
550 | |||
551 | /* try the sky v2.8 (cx24123, isl6421) */ | ||
552 | fc->fe = dvb_attach(cx24123_attach, | ||
553 | &skystar2_rev2_8_cx24123_config, i2c); | ||
554 | if (fc->fe != NULL) { | ||
555 | i2c_tuner = cx24123_get_tuner_i2c_adapter(fc->fe); | ||
556 | if (i2c_tuner != NULL) { | ||
557 | if (dvb_attach(cx24113_attach, fc->fe, | ||
558 | &skystar2_rev2_8_cx24113_config, | ||
559 | i2c_tuner) == NULL) | ||
560 | err("CX24113 could NOT be attached"); | ||
561 | else | ||
562 | info("CX24113 successfully attached"); | ||
563 | } | ||
564 | |||
565 | fc->dev_type = FC_SKY_REV28; | ||
566 | |||
567 | fc->fc_i2c_adap[2].no_base_addr = 1; | ||
568 | if (dvb_attach(isl6421_attach, fc->fe, | ||
569 | &fc->fc_i2c_adap[2].i2c_adap, 0x08, 0, 0) == NULL) | ||
570 | err("ISL6421 could NOT be attached"); | ||
571 | else | ||
572 | info("ISL6421 successfully attached"); | ||
573 | |||
574 | /* TODO on i2c_adap[1] addr 0x11 (EEPROM) there seems to be an | ||
575 | * IR-receiver (PIC16F818) - but the card has no input for | ||
576 | * that ??? */ | ||
577 | |||
578 | goto fe_found; | ||
579 | } | ||
479 | 580 | ||
480 | /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ | 581 | /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ |
481 | if ((fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { | 582 | fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c); |
583 | if (fc->fe != NULL) { | ||
482 | ops = &fc->fe->ops; | 584 | ops = &fc->fe->ops; |
483 | 585 | ||
484 | ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; | 586 | ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; |
485 | 587 | ||
486 | ops->set_voltage = flexcop_set_voltage; | 588 | ops->set_voltage = flexcop_set_voltage; |
487 | 589 | ||
488 | fc->fe_sleep = ops->sleep; | 590 | fc->fe_sleep = ops->sleep; |
489 | ops->sleep = flexcop_sleep; | 591 | ops->sleep = flexcop_sleep; |
592 | |||
593 | fc->dev_type = FC_SKY; | ||
594 | goto fe_found; | ||
595 | } | ||
490 | 596 | ||
491 | fc->dev_type = FC_SKY; | ||
492 | info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address); | ||
493 | } else | ||
494 | /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ | 597 | /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ |
495 | if ((fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { | 598 | fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c); |
496 | fc->dev_type = FC_AIR_DVB; | 599 | if (fc->fe != NULL) { |
600 | fc->dev_type = FC_AIR_DVB; | ||
497 | fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; | 601 | fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; |
498 | info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); | 602 | goto fe_found; |
499 | } else | 603 | } |
604 | |||
500 | /* try the air atsc 2nd generation (nxt2002) */ | 605 | /* try the air atsc 2nd generation (nxt2002) */ |
501 | if ((fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, &fc->i2c_adap)) != NULL) { | 606 | fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, i2c); |
502 | fc->dev_type = FC_AIR_ATSC2; | 607 | if (fc->fe != NULL) { |
608 | fc->dev_type = FC_AIR_ATSC2; | ||
503 | dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV); | 609 | dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV); |
504 | info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); | 610 | goto fe_found; |
505 | } else | 611 | } |
506 | /* try the air atsc 3nd generation (lgdt3303) */ | 612 | |
507 | if ((fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) { | 613 | fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, i2c); |
508 | fc->dev_type = FC_AIR_ATSC3; | 614 | if (fc->fe != NULL) { |
509 | dvb_attach(dvb_pll_attach, fc->fe, 0x61, &fc->i2c_adap, DVB_PLL_LG_TDVS_H06XF); | 615 | fc->dev_type = FC_AIR_ATSC3; |
510 | info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address); | 616 | dvb_attach(simple_tuner_attach, fc->fe, i2c, 0x61, |
511 | } else | 617 | TUNER_LG_TDVS_H06XF); |
618 | goto fe_found; | ||
619 | } | ||
620 | |||
512 | /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ | 621 | /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ |
513 | if ((fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) { | 622 | fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, i2c); |
514 | fc->dev_type = FC_AIR_ATSC1; | 623 | if (fc->fe != NULL) { |
515 | info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); | 624 | fc->dev_type = FC_AIR_ATSC1; |
516 | } else | 625 | goto fe_found; |
626 | } | ||
627 | |||
517 | /* try the cable dvb (stv0297) */ | 628 | /* try the cable dvb (stv0297) */ |
518 | if ((fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { | 629 | fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c); |
519 | fc->dev_type = FC_CABLE; | 630 | if (fc->fe != NULL) { |
631 | fc->dev_type = FC_CABLE; | ||
520 | fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; | 632 | fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; |
521 | info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); | 633 | goto fe_found; |
522 | } else | 634 | } |
635 | |||
523 | /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ | 636 | /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ |
524 | if ((fc->fe = dvb_attach(vp310_mt312_attach, &skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { | 637 | fc->fe = dvb_attach(vp310_mt312_attach, |
638 | &skystar23_samsung_tbdu18132_config, i2c); | ||
639 | if (fc->fe != NULL) { | ||
525 | ops = &fc->fe->ops; | 640 | ops = &fc->fe->ops; |
526 | 641 | ||
527 | ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; | 642 | ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; |
@@ -535,19 +650,21 @@ int flexcop_frontend_init(struct flexcop_device *fc) | |||
535 | ops->sleep = flexcop_sleep; | 650 | ops->sleep = flexcop_sleep; |
536 | 651 | ||
537 | fc->dev_type = FC_SKY_OLD; | 652 | fc->dev_type = FC_SKY_OLD; |
538 | info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address); | 653 | goto fe_found; |
539 | } | 654 | } |
540 | 655 | ||
541 | if (fc->fe == NULL) { | 656 | err("no frontend driver found for this B2C2/FlexCop adapter"); |
542 | err("no frontend driver found for this B2C2/FlexCop adapter"); | 657 | return -ENODEV; |
543 | return -ENODEV; | 658 | |
544 | } else { | 659 | fe_found: |
545 | if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { | 660 | info("found '%s' .", fc->fe->ops.info.name); |
546 | err("frontend registration failed!"); | 661 | if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { |
547 | dvb_frontend_detach(fc->fe); | 662 | err("frontend registration failed!"); |
548 | fc->fe = NULL; | 663 | ops = &fc->fe->ops; |
549 | return -EINVAL; | 664 | if (ops->release != NULL) |
550 | } | 665 | ops->release(fc->fe); |
666 | fc->fe = NULL; | ||
667 | return -EINVAL; | ||
551 | } | 668 | } |
552 | fc->init_state |= FC_STATE_FE_INIT; | 669 | fc->init_state |= FC_STATE_FE_INIT; |
553 | return 0; | 670 | return 0; |