diff options
Diffstat (limited to 'drivers/media/common/tuners/xc5000.c')
-rw-r--r-- | drivers/media/common/tuners/xc5000.c | 147 |
1 files changed, 66 insertions, 81 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index aa1b2e844d32..296df05b8cda 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -628,20 +628,13 @@ static void xc_debug_dump(struct xc5000_priv *priv) | |||
628 | dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); | 628 | dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); |
629 | } | 629 | } |
630 | 630 | ||
631 | /* | 631 | static int xc5000_set_params(struct dvb_frontend *fe) |
632 | * As defined on EN 300 429, the DVB-C roll-off factor is 0.15. | ||
633 | * So, the amount of the needed bandwith is given by: | ||
634 | * Bw = Symbol_rate * (1 + 0.15) | ||
635 | * As such, the maximum symbol rate supported by 6 MHz is given by: | ||
636 | * max_symbol_rate = 6 MHz / 1.15 = 5217391 Bauds | ||
637 | */ | ||
638 | #define MAX_SYMBOL_RATE_6MHz 5217391 | ||
639 | |||
640 | static int xc5000_set_params(struct dvb_frontend *fe, | ||
641 | struct dvb_frontend_parameters *params) | ||
642 | { | 632 | { |
633 | int ret, b; | ||
643 | struct xc5000_priv *priv = fe->tuner_priv; | 634 | struct xc5000_priv *priv = fe->tuner_priv; |
644 | int ret; | 635 | u32 bw = fe->dtv_property_cache.bandwidth_hz; |
636 | u32 freq = fe->dtv_property_cache.frequency; | ||
637 | u32 delsys = fe->dtv_property_cache.delivery_system; | ||
645 | 638 | ||
646 | if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { | 639 | if (xc5000_is_firmware_loaded(fe) != XC_RESULT_SUCCESS) { |
647 | if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { | 640 | if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { |
@@ -650,88 +643,69 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
650 | } | 643 | } |
651 | } | 644 | } |
652 | 645 | ||
653 | dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); | 646 | dprintk(1, "%s() frequency=%d (Hz)\n", __func__, freq); |
654 | 647 | ||
655 | if (fe->ops.info.type == FE_ATSC) { | 648 | switch (delsys) { |
656 | dprintk(1, "%s() ATSC\n", __func__); | 649 | case SYS_ATSC: |
657 | switch (params->u.vsb.modulation) { | 650 | dprintk(1, "%s() VSB modulation\n", __func__); |
658 | case VSB_8: | 651 | priv->rf_mode = XC_RF_MODE_AIR; |
659 | case VSB_16: | 652 | priv->freq_hz = freq - 1750000; |
660 | dprintk(1, "%s() VSB modulation\n", __func__); | 653 | priv->video_standard = DTV6; |
661 | priv->rf_mode = XC_RF_MODE_AIR; | 654 | break; |
662 | priv->freq_hz = params->frequency - 1750000; | 655 | case SYS_DVBC_ANNEX_B: |
663 | priv->bandwidth = BANDWIDTH_6_MHZ; | 656 | dprintk(1, "%s() QAM modulation\n", __func__); |
664 | priv->video_standard = DTV6; | 657 | priv->rf_mode = XC_RF_MODE_CABLE; |
665 | break; | 658 | priv->freq_hz = freq - 1750000; |
666 | case QAM_64: | 659 | priv->video_standard = DTV6; |
667 | case QAM_256: | 660 | break; |
668 | case QAM_AUTO: | 661 | case SYS_DVBT: |
669 | dprintk(1, "%s() QAM modulation\n", __func__); | 662 | case SYS_DVBT2: |
670 | priv->rf_mode = XC_RF_MODE_CABLE; | ||
671 | priv->freq_hz = params->frequency - 1750000; | ||
672 | priv->bandwidth = BANDWIDTH_6_MHZ; | ||
673 | priv->video_standard = DTV6; | ||
674 | break; | ||
675 | default: | ||
676 | return -EINVAL; | ||
677 | } | ||
678 | } else if (fe->ops.info.type == FE_OFDM) { | ||
679 | dprintk(1, "%s() OFDM\n", __func__); | 663 | dprintk(1, "%s() OFDM\n", __func__); |
680 | switch (params->u.ofdm.bandwidth) { | 664 | switch (bw) { |
681 | case BANDWIDTH_6_MHZ: | 665 | case 6000000: |
682 | priv->bandwidth = BANDWIDTH_6_MHZ; | ||
683 | priv->video_standard = DTV6; | 666 | priv->video_standard = DTV6; |
684 | priv->freq_hz = params->frequency - 1750000; | 667 | priv->freq_hz = freq - 1750000; |
685 | break; | 668 | break; |
686 | case BANDWIDTH_7_MHZ: | 669 | case 7000000: |
687 | printk(KERN_ERR "xc5000 bandwidth 7MHz not supported\n"); | 670 | priv->video_standard = DTV7; |
688 | return -EINVAL; | 671 | priv->freq_hz = freq - 2250000; |
689 | case BANDWIDTH_8_MHZ: | 672 | break; |
690 | priv->bandwidth = BANDWIDTH_8_MHZ; | 673 | case 8000000: |
691 | priv->video_standard = DTV8; | 674 | priv->video_standard = DTV8; |
692 | priv->freq_hz = params->frequency - 2750000; | 675 | priv->freq_hz = freq - 2750000; |
693 | break; | 676 | break; |
694 | default: | 677 | default: |
695 | printk(KERN_ERR "xc5000 bandwidth not set!\n"); | 678 | printk(KERN_ERR "xc5000 bandwidth not set!\n"); |
696 | return -EINVAL; | 679 | return -EINVAL; |
697 | } | 680 | } |
698 | priv->rf_mode = XC_RF_MODE_AIR; | 681 | priv->rf_mode = XC_RF_MODE_AIR; |
699 | } else if (fe->ops.info.type == FE_QAM) { | 682 | case SYS_DVBC_ANNEX_A: |
700 | switch (params->u.qam.modulation) { | 683 | case SYS_DVBC_ANNEX_C: |
701 | case QAM_256: | 684 | dprintk(1, "%s() QAM modulation\n", __func__); |
702 | case QAM_AUTO: | 685 | priv->rf_mode = XC_RF_MODE_CABLE; |
703 | case QAM_16: | 686 | if (bw <= 6000000) { |
704 | case QAM_32: | 687 | priv->video_standard = DTV6; |
705 | case QAM_64: | 688 | priv->freq_hz = freq - 1750000; |
706 | case QAM_128: | 689 | b = 6; |
707 | dprintk(1, "%s() QAM modulation\n", __func__); | 690 | } else if (bw <= 7000000) { |
708 | priv->rf_mode = XC_RF_MODE_CABLE; | 691 | priv->video_standard = DTV7; |
709 | /* | 692 | priv->freq_hz = freq - 2250000; |
710 | * Using a 8MHz bandwidth sometimes fail | 693 | b = 7; |
711 | * with 6MHz-spaced channels, due to inter-carrier | 694 | } else { |
712 | * interference. So, use DTV6 firmware | 695 | priv->video_standard = DTV7_8; |
713 | */ | 696 | priv->freq_hz = freq - 2750000; |
714 | if (params->u.qam.symbol_rate <= MAX_SYMBOL_RATE_6MHz) { | 697 | b = 8; |
715 | priv->bandwidth = BANDWIDTH_6_MHZ; | ||
716 | priv->video_standard = DTV6; | ||
717 | priv->freq_hz = params->frequency - 1750000; | ||
718 | } else { | ||
719 | priv->bandwidth = BANDWIDTH_8_MHZ; | ||
720 | priv->video_standard = DTV7_8; | ||
721 | priv->freq_hz = params->frequency - 2750000; | ||
722 | } | ||
723 | break; | ||
724 | default: | ||
725 | dprintk(1, "%s() Unsupported QAM type\n", __func__); | ||
726 | return -EINVAL; | ||
727 | } | 698 | } |
728 | } else { | 699 | dprintk(1, "%s() Bandwidth %dMHz (%d)\n", __func__, |
729 | printk(KERN_ERR "xc5000 modulation type not supported!\n"); | 700 | b, bw); |
701 | break; | ||
702 | default: | ||
703 | printk(KERN_ERR "xc5000: delivery system is not supported!\n"); | ||
730 | return -EINVAL; | 704 | return -EINVAL; |
731 | } | 705 | } |
732 | 706 | ||
733 | dprintk(1, "%s() frequency=%d (compensated)\n", | 707 | dprintk(1, "%s() frequency=%d (compensated to %d)\n", |
734 | __func__, priv->freq_hz); | 708 | __func__, freq, priv->freq_hz); |
735 | 709 | ||
736 | ret = xc_SetSignalSource(priv, priv->rf_mode); | 710 | ret = xc_SetSignalSource(priv, priv->rf_mode); |
737 | if (ret != XC_RESULT_SUCCESS) { | 711 | if (ret != XC_RESULT_SUCCESS) { |
@@ -763,6 +737,8 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
763 | if (debug) | 737 | if (debug) |
764 | xc_debug_dump(priv); | 738 | xc_debug_dump(priv); |
765 | 739 | ||
740 | priv->bandwidth = bw; | ||
741 | |||
766 | return 0; | 742 | return 0; |
767 | } | 743 | } |
768 | 744 | ||
@@ -968,6 +944,14 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) | |||
968 | return 0; | 944 | return 0; |
969 | } | 945 | } |
970 | 946 | ||
947 | static int xc5000_get_if_frequency(struct dvb_frontend *fe, u32 *freq) | ||
948 | { | ||
949 | struct xc5000_priv *priv = fe->tuner_priv; | ||
950 | dprintk(1, "%s()\n", __func__); | ||
951 | *freq = priv->if_khz * 1000; | ||
952 | return 0; | ||
953 | } | ||
954 | |||
971 | static int xc5000_get_bandwidth(struct dvb_frontend *fe, u32 *bw) | 955 | static int xc5000_get_bandwidth(struct dvb_frontend *fe, u32 *bw) |
972 | { | 956 | { |
973 | struct xc5000_priv *priv = fe->tuner_priv; | 957 | struct xc5000_priv *priv = fe->tuner_priv; |
@@ -1108,6 +1092,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = { | |||
1108 | .set_params = xc5000_set_params, | 1092 | .set_params = xc5000_set_params, |
1109 | .set_analog_params = xc5000_set_analog_params, | 1093 | .set_analog_params = xc5000_set_analog_params, |
1110 | .get_frequency = xc5000_get_frequency, | 1094 | .get_frequency = xc5000_get_frequency, |
1095 | .get_if_frequency = xc5000_get_if_frequency, | ||
1111 | .get_bandwidth = xc5000_get_bandwidth, | 1096 | .get_bandwidth = xc5000_get_bandwidth, |
1112 | .get_status = xc5000_get_status | 1097 | .get_status = xc5000_get_status |
1113 | }; | 1098 | }; |
@@ -1135,7 +1120,7 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, | |||
1135 | break; | 1120 | break; |
1136 | case 1: | 1121 | case 1: |
1137 | /* new tuner instance */ | 1122 | /* new tuner instance */ |
1138 | priv->bandwidth = BANDWIDTH_6_MHZ; | 1123 | priv->bandwidth = 6000000; |
1139 | fe->tuner_priv = priv; | 1124 | fe->tuner_priv = priv; |
1140 | break; | 1125 | break; |
1141 | default: | 1126 | default: |