aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2011-07-25 19:25:21 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-31 00:42:40 -0400
commit449d1a0ad1732476d394fb2b885092a5c554f983 (patch)
treefa9c2a3ad75e9d9ab8cdd75be9aa9b802bbeb240
parent9bd9e3bd2c57530dfe3057dd0aa9bdb37824925d (diff)
[media] anysee: use multi-frontend (MFE)
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c299
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.h1
2 files changed, 206 insertions, 94 deletions
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 1ec88b694d29..d4d2420155b4 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -446,6 +446,114 @@ static struct isl6423_config anysee_isl6423_config = {
446 * IOE[5] STV0903 1=enabled 446 * IOE[5] STV0903 1=enabled
447 */ 447 */
448 448
449static int anysee_frontend_ctrl(struct dvb_frontend *fe, int onoff)
450{
451 struct dvb_usb_adapter *adap = fe->dvb->priv;
452 struct anysee_state *state = adap->dev->priv;
453 int ret;
454
455 deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff);
456
457 /* no frontend sleep control */
458 if (onoff == 0)
459 return 0;
460
461 switch (state->hw) {
462 case ANYSEE_HW_507FA: /* 15 */
463 /* E30 Combo Plus */
464 /* E30 C Plus */
465
466 if ((fe->id ^ dvb_usb_anysee_delsys) == 0) {
467 /* disable DVB-T demod on IOD[0] */
468 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0),
469 0x01);
470 if (ret)
471 goto error;
472
473 /* enable DVB-C demod on IOD[5] */
474 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5),
475 0x20);
476 if (ret)
477 goto error;
478
479 /* enable DVB-C tuner on IOE[0] */
480 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0),
481 0x01);
482 if (ret)
483 goto error;
484 } else {
485 /* disable DVB-C demod on IOD[5] */
486 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5),
487 0x20);
488 if (ret)
489 goto error;
490
491 /* enable DVB-T demod on IOD[0] */
492 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0),
493 0x01);
494 if (ret)
495 goto error;
496
497 /* enable DVB-T tuner on IOE[0] */
498 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0),
499 0x01);
500 if (ret)
501 goto error;
502 }
503
504 break;
505 case ANYSEE_HW_508TC: /* 18 */
506 case ANYSEE_HW_508PTC: /* 21 */
507 /* E7 TC */
508 /* E7 PTC */
509
510 if ((fe->id ^ dvb_usb_anysee_delsys) == 0) {
511 /* disable DVB-T demod on IOD[6] */
512 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6),
513 0x40);
514 if (ret)
515 goto error;
516
517 /* enable DVB-C demod on IOD[5] */
518 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5),
519 0x20);
520 if (ret)
521 goto error;
522
523 /* enable IF route on IOE[0] */
524 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0),
525 0x01);
526 if (ret)
527 goto error;
528 } else {
529 /* disable DVB-C demod on IOD[5] */
530 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5),
531 0x20);
532 if (ret)
533 goto error;
534
535 /* enable DVB-T demod on IOD[6] */
536 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6),
537 0x40);
538 if (ret)
539 goto error;
540
541 /* enable IF route on IOE[0] */
542 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0),
543 0x01);
544 if (ret)
545 goto error;
546 }
547
548 break;
549 default:
550 ret = 0;
551 }
552
553error:
554 return ret;
555}
556
449static int anysee_frontend_attach(struct dvb_usb_adapter *adap) 557static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
450{ 558{
451 int ret; 559 int ret;
@@ -466,27 +574,37 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
466 } 574 }
467 }; 575 };
468 576
469 /* Check which hardware we have. 577 /* detect hardware only once */
470 * We must do this call two times to get reliable values (hw bug). 578 if (adap->fe[0] == NULL) {
471 */ 579 /* Check which hardware we have.
472 ret = anysee_get_hw_info(adap->dev, hw_info); 580 * We must do this call two times to get reliable values (hw bug).
473 if (ret) 581 */
474 goto error; 582 ret = anysee_get_hw_info(adap->dev, hw_info);
583 if (ret)
584 goto error;
475 585
476 ret = anysee_get_hw_info(adap->dev, hw_info); 586 ret = anysee_get_hw_info(adap->dev, hw_info);
477 if (ret) 587 if (ret)
478 goto error; 588 goto error;
589
590 /* Meaning of these info bytes are guessed. */
591 info("firmware version:%d.%d hardware id:%d",
592 hw_info[1], hw_info[2], hw_info[0]);
479 593
480 /* Meaning of these info bytes are guessed. */ 594 state->hw = hw_info[0];
481 info("firmware version:%d.%d hardware id:%d", 595 }
482 hw_info[1], hw_info[2], hw_info[0]);
483 596
484 state->hw = hw_info[0]; 597 /* set current frondend ID for devices having two frondends */
598 if (adap->fe[0])
599 state->fe_id++;
485 600
486 switch (state->hw) { 601 switch (state->hw) {
487 case ANYSEE_HW_507T: /* 2 */ 602 case ANYSEE_HW_507T: /* 2 */
488 /* E30 */ 603 /* E30 */
489 604
605 if (state->fe_id)
606 break;
607
490 /* attach demod */ 608 /* attach demod */
491 adap->fe[0] = dvb_attach(mt352_attach, &anysee_mt352_config, 609 adap->fe[0] = dvb_attach(mt352_attach, &anysee_mt352_config,
492 &adap->dev->i2c_adap); 610 &adap->dev->i2c_adap);
@@ -501,6 +619,9 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
501 case ANYSEE_HW_507CD: /* 6 */ 619 case ANYSEE_HW_507CD: /* 6 */
502 /* E30 Plus */ 620 /* E30 Plus */
503 621
622 if (state->fe_id)
623 break;
624
504 /* enable DVB-T demod on IOD[0] */ 625 /* enable DVB-T demod on IOD[0] */
505 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); 626 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01);
506 if (ret) 627 if (ret)
@@ -512,26 +633,32 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
512 goto error; 633 goto error;
513 634
514 /* attach demod */ 635 /* attach demod */
515 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config, 636 adap->fe[0] = dvb_attach(zl10353_attach,
516 &adap->dev->i2c_adap); 637 &anysee_zl10353_config, &adap->dev->i2c_adap);
517 638
518 break; 639 break;
519 case ANYSEE_HW_507DC: /* 10 */ 640 case ANYSEE_HW_507DC: /* 10 */
520 /* E30 C Plus */ 641 /* E30 C Plus */
521 642
643 if (state->fe_id)
644 break;
645
522 /* enable DVB-C demod on IOD[0] */ 646 /* enable DVB-C demod on IOD[0] */
523 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); 647 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01);
524 if (ret) 648 if (ret)
525 goto error; 649 goto error;
526 650
527 /* attach demod */ 651 /* attach demod */
528 adap->fe[0] = dvb_attach(tda10023_attach, &anysee_tda10023_config, 652 adap->fe[0] = dvb_attach(tda10023_attach,
529 &adap->dev->i2c_adap, 0x48); 653 &anysee_tda10023_config, &adap->dev->i2c_adap, 0x48);
530 654
531 break; 655 break;
532 case ANYSEE_HW_507SI: /* 11 */ 656 case ANYSEE_HW_507SI: /* 11 */
533 /* E30 S2 Plus */ 657 /* E30 S2 Plus */
534 658
659 if (state->fe_id)
660 break;
661
535 /* enable DVB-S/S2 demod on IOD[0] */ 662 /* enable DVB-S/S2 demod on IOD[0] */
536 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); 663 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01);
537 if (ret) 664 if (ret)
@@ -564,55 +691,59 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
564 if (ret) 691 if (ret)
565 goto error; 692 goto error;
566 693
567 if (dvb_usb_anysee_delsys) { 694 if ((state->fe_id ^ dvb_usb_anysee_delsys) == 0) {
568 /* disable DVB-C demod on IOD[5] */ 695 /* disable DVB-T demod on IOD[0] */
569 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), 696 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0),
570 0x20); 697 0x01);
571 if (ret) 698 if (ret)
572 goto error; 699 goto error;
573 700
574 /* enable DVB-T demod on IOD[0] */ 701 /* enable DVB-C demod on IOD[5] */
575 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 702 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5),
576 0x01); 703 0x20);
577 if (ret) 704 if (ret)
578 goto error; 705 goto error;
579 706
580 /* attach demod */ 707 /* attach demod */
581 if (tmp == 0xc7) { 708 if (tmp == 0xc7) {
582 /* TDA18212 config */ 709 /* TDA18212 config */
583 adap->fe[0] = dvb_attach(zl10353_attach, 710 adap->fe[state->fe_id] = dvb_attach(
584 &anysee_zl10353_tda18212_config2, 711 tda10023_attach,
585 &adap->dev->i2c_adap); 712 &anysee_tda10023_tda18212_config,
713 &adap->dev->i2c_adap, 0x48);
586 } else { 714 } else {
587 /* PLL config */ 715 /* PLL config */
588 adap->fe[0] = dvb_attach(zl10353_attach, 716 adap->fe[state->fe_id] = dvb_attach(
589 &anysee_zl10353_config, 717 tda10023_attach,
590 &adap->dev->i2c_adap); 718 &anysee_tda10023_config,
719 &adap->dev->i2c_adap, 0x48);
591 } 720 }
592 } else { 721 } else {
593 /* disable DVB-T demod on IOD[0] */ 722 /* disable DVB-C demod on IOD[5] */
594 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0), 723 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5),
595 0x01); 724 0x20);
596 if (ret) 725 if (ret)
597 goto error; 726 goto error;
598 727
599 /* enable DVB-C demod on IOD[5] */ 728 /* enable DVB-T demod on IOD[0] */
600 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), 729 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0),
601 0x20); 730 0x01);
602 if (ret) 731 if (ret)
603 goto error; 732 goto error;
604 733
605 /* attach demod */ 734 /* attach demod */
606 if (tmp == 0xc7) { 735 if (tmp == 0xc7) {
607 /* TDA18212 config */ 736 /* TDA18212 config */
608 adap->fe[0] = dvb_attach(tda10023_attach, 737 adap->fe[state->fe_id] = dvb_attach(
609 &anysee_tda10023_tda18212_config, 738 zl10353_attach,
610 &adap->dev->i2c_adap, 0x48); 739 &anysee_zl10353_tda18212_config2,
740 &adap->dev->i2c_adap);
611 } else { 741 } else {
612 /* PLL config */ 742 /* PLL config */
613 adap->fe[0] = dvb_attach(tda10023_attach, 743 adap->fe[state->fe_id] = dvb_attach(
614 &anysee_tda10023_config, 744 zl10353_attach,
615 &adap->dev->i2c_adap, 0x48); 745 &anysee_zl10353_config,
746 &adap->dev->i2c_adap);
616 } 747 }
617 } 748 }
618 749
@@ -627,52 +758,40 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
627 if (ret) 758 if (ret)
628 goto error; 759 goto error;
629 760
630 if (dvb_usb_anysee_delsys) { 761 if ((state->fe_id ^ dvb_usb_anysee_delsys) == 0) {
631 /* disable DVB-C demod on IOD[5] */ 762 /* disable DVB-T demod on IOD[6] */
632 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), 763 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6),
633 0x20);
634 if (ret)
635 goto error;
636
637 /* enable DVB-T demod on IOD[6] */
638 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6),
639 0x40); 764 0x40);
640 if (ret) 765 if (ret)
641 goto error; 766 goto error;
642 767
643 /* enable IF route on IOE[0] */ 768 /* enable DVB-C demod on IOD[5] */
644 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), 769 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5),
645 0x01); 770 0x20);
646 if (ret) 771 if (ret)
647 goto error; 772 goto error;
648 773
649 /* attach demod */ 774 /* attach demod */
650 adap->fe[0] = dvb_attach(zl10353_attach, 775 adap->fe[state->fe_id] = dvb_attach(tda10023_attach,
651 &anysee_zl10353_tda18212_config, 776 &anysee_tda10023_tda18212_config,
652 &adap->dev->i2c_adap); 777 &adap->dev->i2c_adap, 0x48);
653 } else { 778 } else {
654 /* disable DVB-T demod on IOD[6] */ 779 /* disable DVB-C demod on IOD[5] */
655 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6), 780 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5),
656 0x40);
657 if (ret)
658 goto error;
659
660 /* enable DVB-C demod on IOD[5] */
661 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5),
662 0x20); 781 0x20);
663 if (ret) 782 if (ret)
664 goto error; 783 goto error;
665 784
666 /* enable IF route on IOE[0] */ 785 /* enable DVB-T demod on IOD[6] */
667 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), 786 ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6),
668 0x01); 787 0x40);
669 if (ret) 788 if (ret)
670 goto error; 789 goto error;
671 790
672 /* attach demod */ 791 /* attach demod */
673 adap->fe[0] = dvb_attach(tda10023_attach, 792 adap->fe[state->fe_id] = dvb_attach(zl10353_attach,
674 &anysee_tda10023_tda18212_config, 793 &anysee_zl10353_tda18212_config,
675 &adap->dev->i2c_adap, 0x48); 794 &adap->dev->i2c_adap);
676 } 795 }
677 796
678 break; 797 break;
@@ -681,6 +800,9 @@ static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
681 /* E7 S2 */ 800 /* E7 S2 */
682 /* E7 PS2 */ 801 /* E7 PS2 */
683 802
803 if (state->fe_id)
804 break;
805
684 /* enable transport stream on IOA[7] */ 806 /* enable transport stream on IOA[7] */
685 ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); 807 ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80);
686 if (ret) 808 if (ret)
@@ -713,7 +835,7 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
713 struct anysee_state *state = adap->dev->priv; 835 struct anysee_state *state = adap->dev->priv;
714 struct dvb_frontend *fe; 836 struct dvb_frontend *fe;
715 int ret; 837 int ret;
716 deb_info("%s:\n", __func__); 838 deb_info("%s: fe=%d\n", __func__, state->fe_id);
717 839
718 switch (state->hw) { 840 switch (state->hw) {
719 case ANYSEE_HW_507T: /* 2 */ 841 case ANYSEE_HW_507T: /* 2 */
@@ -744,28 +866,14 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
744 /* E30 S2 Plus */ 866 /* E30 S2 Plus */
745 867
746 /* attach LNB controller */ 868 /* attach LNB controller */
747 fe = dvb_attach(isl6423_attach, adap->fe[0], &adap->dev->i2c_adap, 869 fe = dvb_attach(isl6423_attach, adap->fe[0],
748 &anysee_isl6423_config); 870 &adap->dev->i2c_adap, &anysee_isl6423_config);
749 871
750 break; 872 break;
751 case ANYSEE_HW_507FA: /* 15 */ 873 case ANYSEE_HW_507FA: /* 15 */
752 /* E30 Combo Plus */ 874 /* E30 Combo Plus */
753 /* E30 C Plus */ 875 /* E30 C Plus */
754 876
755 if (dvb_usb_anysee_delsys) {
756 /* enable DVB-T tuner on IOE[0] */
757 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0),
758 0x01);
759 if (ret)
760 goto error;
761 } else {
762 /* enable DVB-C tuner on IOE[0] */
763 ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0),
764 0x01);
765 if (ret)
766 goto error;
767 }
768
769 /* Try first attach TDA18212 silicon tuner on IOE[4], if that 877 /* Try first attach TDA18212 silicon tuner on IOE[4], if that
770 * fails attach old simple PLL. */ 878 * fails attach old simple PLL. */
771 879
@@ -775,8 +883,8 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
775 goto error; 883 goto error;
776 884
777 /* attach tuner */ 885 /* attach tuner */
778 fe = dvb_attach(tda18212_attach, adap->fe[0], &adap->dev->i2c_adap, 886 fe = dvb_attach(tda18212_attach, adap->fe[state->fe_id],
779 &anysee_tda18212_config); 887 &adap->dev->i2c_adap, &anysee_tda18212_config);
780 if (fe) 888 if (fe)
781 break; 889 break;
782 890
@@ -786,8 +894,9 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
786 goto error; 894 goto error;
787 895
788 /* attach tuner */ 896 /* attach tuner */
789 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc0 >> 1), 897 fe = dvb_attach(dvb_pll_attach, adap->fe[state->fe_id],
790 &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); 898 (0xc0 >> 1), &adap->dev->i2c_adap,
899 DVB_PLL_SAMSUNG_DTOS403IH102A);
791 900
792 break; 901 break;
793 case ANYSEE_HW_508TC: /* 18 */ 902 case ANYSEE_HW_508TC: /* 18 */
@@ -801,8 +910,8 @@ static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
801 goto error; 910 goto error;
802 911
803 /* attach tuner */ 912 /* attach tuner */
804 fe = dvb_attach(tda18212_attach, adap->fe[0], &adap->dev->i2c_adap, 913 fe = dvb_attach(tda18212_attach, adap->fe[state->fe_id],
805 &anysee_tda18212_config); 914 &adap->dev->i2c_adap, &anysee_tda18212_config);
806 915
807 break; 916 break;
808 case ANYSEE_HW_508S2: /* 19 */ 917 case ANYSEE_HW_508S2: /* 19 */
@@ -918,6 +1027,8 @@ static struct dvb_usb_device_properties anysee_properties = {
918 .num_adapters = 1, 1027 .num_adapters = 1,
919 .adapter = { 1028 .adapter = {
920 { 1029 {
1030 .num_frontends = 2,
1031 .frontend_ctrl = anysee_frontend_ctrl,
921 .streaming_ctrl = anysee_streaming_ctrl, 1032 .streaming_ctrl = anysee_streaming_ctrl,
922 .frontend_attach = anysee_frontend_attach, 1033 .frontend_attach = anysee_frontend_attach,
923 .tuner_attach = anysee_tuner_attach, 1034 .tuner_attach = anysee_tuner_attach,
diff --git a/drivers/media/dvb/dvb-usb/anysee.h b/drivers/media/dvb/dvb-usb/anysee.h
index ad6ccd1ea2d9..57ee500b8c0e 100644
--- a/drivers/media/dvb/dvb-usb/anysee.h
+++ b/drivers/media/dvb/dvb-usb/anysee.h
@@ -59,6 +59,7 @@ enum cmd {
59struct anysee_state { 59struct anysee_state {
60 u8 hw; /* PCB ID */ 60 u8 hw; /* PCB ID */
61 u8 seq; 61 u8 seq;
62 u8 fe_id:1; /* frondend ID */
62}; 63};
63 64
64#define ANYSEE_HW_507T 2 /* E30 */ 65#define ANYSEE_HW_507T 2 /* E30 */