diff options
Diffstat (limited to 'drivers/media/common/tuners/tuner-simple.c')
-rw-r--r-- | drivers/media/common/tuners/tuner-simple.c | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c index f8ee29e6059..39e7e583c8c 100644 --- a/drivers/media/common/tuners/tuner-simple.c +++ b/drivers/media/common/tuners/tuner-simple.c | |||
@@ -751,6 +751,17 @@ static int simple_set_radio_freq(struct dvb_frontend *fe, | |||
751 | if (4 != rc) | 751 | if (4 != rc) |
752 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc); | 752 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc); |
753 | 753 | ||
754 | /* Write AUX byte */ | ||
755 | switch (priv->type) { | ||
756 | case TUNER_PHILIPS_FM1216ME_MK3: | ||
757 | buffer[2] = 0x98; | ||
758 | buffer[3] = 0x20; /* set TOP AGC */ | ||
759 | rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4); | ||
760 | if (4 != rc) | ||
761 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc); | ||
762 | break; | ||
763 | } | ||
764 | |||
754 | return 0; | 765 | return 0; |
755 | } | 766 | } |
756 | 767 | ||
@@ -780,24 +791,26 @@ static int simple_set_params(struct dvb_frontend *fe, | |||
780 | } | 791 | } |
781 | 792 | ||
782 | static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | 793 | static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, |
783 | const struct dvb_frontend_parameters *params) | 794 | const u32 delsys, |
795 | const u32 frequency, | ||
796 | const u32 bandwidth) | ||
784 | { | 797 | { |
785 | struct tuner_simple_priv *priv = fe->tuner_priv; | 798 | struct tuner_simple_priv *priv = fe->tuner_priv; |
786 | 799 | ||
787 | switch (priv->type) { | 800 | switch (priv->type) { |
788 | case TUNER_PHILIPS_FMD1216ME_MK3: | 801 | case TUNER_PHILIPS_FMD1216ME_MK3: |
789 | case TUNER_PHILIPS_FMD1216MEX_MK3: | 802 | case TUNER_PHILIPS_FMD1216MEX_MK3: |
790 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && | 803 | if (bandwidth == 8000000 && |
791 | params->frequency >= 158870000) | 804 | frequency >= 158870000) |
792 | buf[3] |= 0x08; | 805 | buf[3] |= 0x08; |
793 | break; | 806 | break; |
794 | case TUNER_PHILIPS_TD1316: | 807 | case TUNER_PHILIPS_TD1316: |
795 | /* determine band */ | 808 | /* determine band */ |
796 | buf[3] |= (params->frequency < 161000000) ? 1 : | 809 | buf[3] |= (frequency < 161000000) ? 1 : |
797 | (params->frequency < 444000000) ? 2 : 4; | 810 | (frequency < 444000000) ? 2 : 4; |
798 | 811 | ||
799 | /* setup PLL filter */ | 812 | /* setup PLL filter */ |
800 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | 813 | if (bandwidth == 8000000) |
801 | buf[3] |= 1 << 3; | 814 | buf[3] |= 1 << 3; |
802 | break; | 815 | break; |
803 | case TUNER_PHILIPS_TUV1236D: | 816 | case TUNER_PHILIPS_TUV1236D: |
@@ -808,12 +821,11 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | |||
808 | if (dtv_input[priv->nr]) | 821 | if (dtv_input[priv->nr]) |
809 | new_rf = dtv_input[priv->nr]; | 822 | new_rf = dtv_input[priv->nr]; |
810 | else | 823 | else |
811 | switch (params->u.vsb.modulation) { | 824 | switch (delsys) { |
812 | case QAM_64: | 825 | case SYS_DVBC_ANNEX_B: |
813 | case QAM_256: | ||
814 | new_rf = 1; | 826 | new_rf = 1; |
815 | break; | 827 | break; |
816 | case VSB_8: | 828 | case SYS_ATSC: |
817 | default: | 829 | default: |
818 | new_rf = 0; | 830 | new_rf = 0; |
819 | break; | 831 | break; |
@@ -827,7 +839,9 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | |||
827 | } | 839 | } |
828 | 840 | ||
829 | static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | 841 | static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, |
830 | const struct dvb_frontend_parameters *params) | 842 | const u32 delsys, |
843 | const u32 freq, | ||
844 | const u32 bw) | ||
831 | { | 845 | { |
832 | /* This function returns the tuned frequency on success, 0 on error */ | 846 | /* This function returns the tuned frequency on success, 0 on error */ |
833 | struct tuner_simple_priv *priv = fe->tuner_priv; | 847 | struct tuner_simple_priv *priv = fe->tuner_priv; |
@@ -836,7 +850,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
836 | u8 config, cb; | 850 | u8 config, cb; |
837 | u32 div; | 851 | u32 div; |
838 | int ret; | 852 | int ret; |
839 | unsigned frequency = params->frequency / 62500; | 853 | u32 frequency = freq / 62500; |
840 | 854 | ||
841 | if (!tun->stepsize) { | 855 | if (!tun->stepsize) { |
842 | /* tuner-core was loaded before the digital tuner was | 856 | /* tuner-core was loaded before the digital tuner was |
@@ -860,7 +874,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
860 | buf[2] = config; | 874 | buf[2] = config; |
861 | buf[3] = cb; | 875 | buf[3] = cb; |
862 | 876 | ||
863 | simple_set_dvb(fe, buf, params); | 877 | simple_set_dvb(fe, buf, delsys, freq, bw); |
864 | 878 | ||
865 | tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", | 879 | tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", |
866 | tun->name, div, buf[0], buf[1], buf[2], buf[3]); | 880 | tun->name, div, buf[0], buf[1], buf[2], buf[3]); |
@@ -870,32 +884,37 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
870 | } | 884 | } |
871 | 885 | ||
872 | static int simple_dvb_calc_regs(struct dvb_frontend *fe, | 886 | static int simple_dvb_calc_regs(struct dvb_frontend *fe, |
873 | struct dvb_frontend_parameters *params, | ||
874 | u8 *buf, int buf_len) | 887 | u8 *buf, int buf_len) |
875 | { | 888 | { |
889 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
890 | u32 delsys = c->delivery_system; | ||
891 | u32 bw = c->bandwidth_hz; | ||
876 | struct tuner_simple_priv *priv = fe->tuner_priv; | 892 | struct tuner_simple_priv *priv = fe->tuner_priv; |
877 | u32 frequency; | 893 | u32 frequency; |
878 | 894 | ||
879 | if (buf_len < 5) | 895 | if (buf_len < 5) |
880 | return -EINVAL; | 896 | return -EINVAL; |
881 | 897 | ||
882 | frequency = simple_dvb_configure(fe, buf+1, params); | 898 | frequency = simple_dvb_configure(fe, buf+1, delsys, c->frequency, bw); |
883 | if (frequency == 0) | 899 | if (frequency == 0) |
884 | return -EINVAL; | 900 | return -EINVAL; |
885 | 901 | ||
886 | buf[0] = priv->i2c_props.addr; | 902 | buf[0] = priv->i2c_props.addr; |
887 | 903 | ||
888 | priv->frequency = frequency; | 904 | priv->frequency = frequency; |
889 | priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? | 905 | priv->bandwidth = c->bandwidth_hz; |
890 | params->u.ofdm.bandwidth : 0; | ||
891 | 906 | ||
892 | return 5; | 907 | return 5; |
893 | } | 908 | } |
894 | 909 | ||
895 | static int simple_dvb_set_params(struct dvb_frontend *fe, | 910 | static int simple_dvb_set_params(struct dvb_frontend *fe) |
896 | struct dvb_frontend_parameters *params) | ||
897 | { | 911 | { |
912 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
913 | u32 delsys = c->delivery_system; | ||
914 | u32 bw = c->bandwidth_hz; | ||
915 | u32 freq = c->frequency; | ||
898 | struct tuner_simple_priv *priv = fe->tuner_priv; | 916 | struct tuner_simple_priv *priv = fe->tuner_priv; |
917 | u32 frequency; | ||
899 | u32 prev_freq, prev_bw; | 918 | u32 prev_freq, prev_bw; |
900 | int ret; | 919 | int ret; |
901 | u8 buf[5]; | 920 | u8 buf[5]; |
@@ -906,9 +925,14 @@ static int simple_dvb_set_params(struct dvb_frontend *fe, | |||
906 | prev_freq = priv->frequency; | 925 | prev_freq = priv->frequency; |
907 | prev_bw = priv->bandwidth; | 926 | prev_bw = priv->bandwidth; |
908 | 927 | ||
909 | ret = simple_dvb_calc_regs(fe, params, buf, 5); | 928 | frequency = simple_dvb_configure(fe, buf+1, delsys, freq, bw); |
910 | if (ret != 5) | 929 | if (frequency == 0) |
911 | goto fail; | 930 | return -EINVAL; |
931 | |||
932 | buf[0] = priv->i2c_props.addr; | ||
933 | |||
934 | priv->frequency = frequency; | ||
935 | priv->bandwidth = bw; | ||
912 | 936 | ||
913 | /* put analog demod in standby when tuning digital */ | 937 | /* put analog demod in standby when tuning digital */ |
914 | if (fe->ops.analog_ops.standby) | 938 | if (fe->ops.analog_ops.standby) |