diff options
Diffstat (limited to 'drivers/media/common/tuners/mxl5007t.c')
-rw-r--r-- | drivers/media/common/tuners/mxl5007t.c | 98 |
1 files changed, 71 insertions, 27 deletions
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c index 5d02221e99dd..69e453ef0a1a 100644 --- a/drivers/media/common/tuners/mxl5007t.c +++ b/drivers/media/common/tuners/mxl5007t.c | |||
@@ -165,6 +165,8 @@ struct mxl5007t_state { | |||
165 | struct reg_pair_t tab_init_cable[ARRAY_SIZE(init_tab_cable)]; | 165 | struct reg_pair_t tab_init_cable[ARRAY_SIZE(init_tab_cable)]; |
166 | struct reg_pair_t tab_rftune[ARRAY_SIZE(reg_pair_rftune)]; | 166 | struct reg_pair_t tab_rftune[ARRAY_SIZE(reg_pair_rftune)]; |
167 | 167 | ||
168 | enum mxl5007t_if_freq if_freq; | ||
169 | |||
168 | u32 frequency; | 170 | u32 frequency; |
169 | u32 bandwidth; | 171 | u32 bandwidth; |
170 | }; | 172 | }; |
@@ -286,6 +288,8 @@ static void mxl5007t_set_if_freq_bits(struct mxl5007t_state *state, | |||
286 | /* set inverted IF or normal IF */ | 288 | /* set inverted IF or normal IF */ |
287 | set_reg_bits(state->tab_init, 0x02, 0x10, invert_if ? 0x10 : 0x00); | 289 | set_reg_bits(state->tab_init, 0x02, 0x10, invert_if ? 0x10 : 0x00); |
288 | 290 | ||
291 | state->if_freq = if_freq; | ||
292 | |||
289 | return; | 293 | return; |
290 | } | 294 | } |
291 | 295 | ||
@@ -612,47 +616,43 @@ fail: | |||
612 | 616 | ||
613 | /* ------------------------------------------------------------------------- */ | 617 | /* ------------------------------------------------------------------------- */ |
614 | 618 | ||
615 | static int mxl5007t_set_params(struct dvb_frontend *fe, | 619 | static int mxl5007t_set_params(struct dvb_frontend *fe) |
616 | struct dvb_frontend_parameters *params) | ||
617 | { | 620 | { |
621 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
622 | u32 delsys = c->delivery_system; | ||
618 | struct mxl5007t_state *state = fe->tuner_priv; | 623 | struct mxl5007t_state *state = fe->tuner_priv; |
619 | enum mxl5007t_bw_mhz bw; | 624 | enum mxl5007t_bw_mhz bw; |
620 | enum mxl5007t_mode mode; | 625 | enum mxl5007t_mode mode; |
621 | int ret; | 626 | int ret; |
622 | u32 freq = params->frequency; | 627 | u32 freq = c->frequency; |
623 | 628 | ||
624 | if (fe->ops.info.type == FE_ATSC) { | 629 | switch (delsys) { |
625 | switch (params->u.vsb.modulation) { | 630 | case SYS_ATSC: |
626 | case VSB_8: | 631 | mode = MxL_MODE_ATSC; |
627 | case VSB_16: | 632 | bw = MxL_BW_6MHz; |
628 | mode = MxL_MODE_ATSC; | 633 | break; |
629 | break; | 634 | case SYS_DVBC_ANNEX_B: |
630 | case QAM_64: | 635 | mode = MxL_MODE_CABLE; |
631 | case QAM_256: | ||
632 | mode = MxL_MODE_CABLE; | ||
633 | break; | ||
634 | default: | ||
635 | mxl_err("modulation not set!"); | ||
636 | return -EINVAL; | ||
637 | } | ||
638 | bw = MxL_BW_6MHz; | 636 | bw = MxL_BW_6MHz; |
639 | } else if (fe->ops.info.type == FE_OFDM) { | 637 | break; |
640 | switch (params->u.ofdm.bandwidth) { | 638 | case SYS_DVBT: |
641 | case BANDWIDTH_6_MHZ: | 639 | case SYS_DVBT2: |
640 | mode = MxL_MODE_DVBT; | ||
641 | switch (c->bandwidth_hz) { | ||
642 | case 6000000: | ||
642 | bw = MxL_BW_6MHz; | 643 | bw = MxL_BW_6MHz; |
643 | break; | 644 | break; |
644 | case BANDWIDTH_7_MHZ: | 645 | case 7000000: |
645 | bw = MxL_BW_7MHz; | 646 | bw = MxL_BW_7MHz; |
646 | break; | 647 | break; |
647 | case BANDWIDTH_8_MHZ: | 648 | case 8000000: |
648 | bw = MxL_BW_8MHz; | 649 | bw = MxL_BW_8MHz; |
649 | break; | 650 | break; |
650 | default: | 651 | default: |
651 | mxl_err("bandwidth not set!"); | ||
652 | return -EINVAL; | 652 | return -EINVAL; |
653 | } | 653 | } |
654 | mode = MxL_MODE_DVBT; | 654 | break; |
655 | } else { | 655 | default: |
656 | mxl_err("modulation type not supported!"); | 656 | mxl_err("modulation type not supported!"); |
657 | return -EINVAL; | 657 | return -EINVAL; |
658 | } | 658 | } |
@@ -671,8 +671,7 @@ static int mxl5007t_set_params(struct dvb_frontend *fe, | |||
671 | goto fail; | 671 | goto fail; |
672 | 672 | ||
673 | state->frequency = freq; | 673 | state->frequency = freq; |
674 | state->bandwidth = (fe->ops.info.type == FE_OFDM) ? | 674 | state->bandwidth = c->bandwidth_hz; |
675 | params->u.ofdm.bandwidth : 0; | ||
676 | fail: | 675 | fail: |
677 | mutex_unlock(&state->lock); | 676 | mutex_unlock(&state->lock); |
678 | 677 | ||
@@ -738,6 +737,50 @@ static int mxl5007t_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | |||
738 | return 0; | 737 | return 0; |
739 | } | 738 | } |
740 | 739 | ||
740 | static int mxl5007t_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
741 | { | ||
742 | struct mxl5007t_state *state = fe->tuner_priv; | ||
743 | |||
744 | *frequency = 0; | ||
745 | |||
746 | switch (state->if_freq) { | ||
747 | case MxL_IF_4_MHZ: | ||
748 | *frequency = 4000000; | ||
749 | break; | ||
750 | case MxL_IF_4_5_MHZ: | ||
751 | *frequency = 4500000; | ||
752 | break; | ||
753 | case MxL_IF_4_57_MHZ: | ||
754 | *frequency = 4570000; | ||
755 | break; | ||
756 | case MxL_IF_5_MHZ: | ||
757 | *frequency = 5000000; | ||
758 | break; | ||
759 | case MxL_IF_5_38_MHZ: | ||
760 | *frequency = 5380000; | ||
761 | break; | ||
762 | case MxL_IF_6_MHZ: | ||
763 | *frequency = 6000000; | ||
764 | break; | ||
765 | case MxL_IF_6_28_MHZ: | ||
766 | *frequency = 6280000; | ||
767 | break; | ||
768 | case MxL_IF_9_1915_MHZ: | ||
769 | *frequency = 9191500; | ||
770 | break; | ||
771 | case MxL_IF_35_25_MHZ: | ||
772 | *frequency = 35250000; | ||
773 | break; | ||
774 | case MxL_IF_36_15_MHZ: | ||
775 | *frequency = 36150000; | ||
776 | break; | ||
777 | case MxL_IF_44_MHZ: | ||
778 | *frequency = 44000000; | ||
779 | break; | ||
780 | } | ||
781 | return 0; | ||
782 | } | ||
783 | |||
741 | static int mxl5007t_release(struct dvb_frontend *fe) | 784 | static int mxl5007t_release(struct dvb_frontend *fe) |
742 | { | 785 | { |
743 | struct mxl5007t_state *state = fe->tuner_priv; | 786 | struct mxl5007t_state *state = fe->tuner_priv; |
@@ -767,6 +810,7 @@ static struct dvb_tuner_ops mxl5007t_tuner_ops = { | |||
767 | .get_frequency = mxl5007t_get_frequency, | 810 | .get_frequency = mxl5007t_get_frequency, |
768 | .get_bandwidth = mxl5007t_get_bandwidth, | 811 | .get_bandwidth = mxl5007t_get_bandwidth, |
769 | .release = mxl5007t_release, | 812 | .release = mxl5007t_release, |
813 | .get_if_frequency = mxl5007t_get_if_frequency, | ||
770 | }; | 814 | }; |
771 | 815 | ||
772 | static int mxl5007t_get_chip_id(struct mxl5007t_state *state) | 816 | static int mxl5007t_get_chip_id(struct mxl5007t_state *state) |