diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-21 07:38:52 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-31 05:38:35 -0500 |
commit | 9481f4009c7bc95a03b5553e9174cfd2a0248d57 (patch) | |
tree | a5deefb7b57880e4e5d061599ffcc4bf27ebd784 /drivers/media/common/tuners/tuner-simple.c | |
parent | 57605c9680bf2c57cb2ff3ad737fefd9c82bc012 (diff) |
[media] tuner-simple: use DVBv5 parameters on set_params()
Despite its name, tuner-simple has a complex logic to set freqs ;)
Basically, it can be called by two different ways: via set_params()
or via calc_regs() callbacks. Both are bound to the DVBv3 API.
Also, set_params internally calls calc_regs().
In order to get rid of DVBv3 params at set_params(), it shouldn't
call calc_regs() anymore. The code duplication is very small,
as most of the code there is just to check for invalid parameters.
With regards to calc_regs(), it should still trust on bandwidth and
frequency parameters passed via DVBv3, until a later patch fixes
it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common/tuners/tuner-simple.c')
-rw-r--r-- | drivers/media/common/tuners/tuner-simple.c | 63 |
1 files changed, 46 insertions, 17 deletions
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c index 4092200c148e..e6342dbb2cf7 100644 --- a/drivers/media/common/tuners/tuner-simple.c +++ b/drivers/media/common/tuners/tuner-simple.c | |||
@@ -791,24 +791,26 @@ static int simple_set_params(struct dvb_frontend *fe, | |||
791 | } | 791 | } |
792 | 792 | ||
793 | static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | 793 | static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, |
794 | const struct dvb_frontend_parameters *params) | 794 | const u32 delsys, |
795 | const u32 frequency, | ||
796 | const u32 bandwidth) | ||
795 | { | 797 | { |
796 | struct tuner_simple_priv *priv = fe->tuner_priv; | 798 | struct tuner_simple_priv *priv = fe->tuner_priv; |
797 | 799 | ||
798 | switch (priv->type) { | 800 | switch (priv->type) { |
799 | case TUNER_PHILIPS_FMD1216ME_MK3: | 801 | case TUNER_PHILIPS_FMD1216ME_MK3: |
800 | case TUNER_PHILIPS_FMD1216MEX_MK3: | 802 | case TUNER_PHILIPS_FMD1216MEX_MK3: |
801 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && | 803 | if (bandwidth == 8000000 && |
802 | params->frequency >= 158870000) | 804 | frequency >= 158870000) |
803 | buf[3] |= 0x08; | 805 | buf[3] |= 0x08; |
804 | break; | 806 | break; |
805 | case TUNER_PHILIPS_TD1316: | 807 | case TUNER_PHILIPS_TD1316: |
806 | /* determine band */ | 808 | /* determine band */ |
807 | buf[3] |= (params->frequency < 161000000) ? 1 : | 809 | buf[3] |= (frequency < 161000000) ? 1 : |
808 | (params->frequency < 444000000) ? 2 : 4; | 810 | (frequency < 444000000) ? 2 : 4; |
809 | 811 | ||
810 | /* setup PLL filter */ | 812 | /* setup PLL filter */ |
811 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | 813 | if (bandwidth == 8000000) |
812 | buf[3] |= 1 << 3; | 814 | buf[3] |= 1 << 3; |
813 | break; | 815 | break; |
814 | case TUNER_PHILIPS_TUV1236D: | 816 | case TUNER_PHILIPS_TUV1236D: |
@@ -819,12 +821,11 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | |||
819 | if (dtv_input[priv->nr]) | 821 | if (dtv_input[priv->nr]) |
820 | new_rf = dtv_input[priv->nr]; | 822 | new_rf = dtv_input[priv->nr]; |
821 | else | 823 | else |
822 | switch (params->u.vsb.modulation) { | 824 | switch (delsys) { |
823 | case QAM_64: | 825 | case SYS_DVBC_ANNEX_B: |
824 | case QAM_256: | ||
825 | new_rf = 1; | 826 | new_rf = 1; |
826 | break; | 827 | break; |
827 | case VSB_8: | 828 | case SYS_ATSC: |
828 | default: | 829 | default: |
829 | new_rf = 0; | 830 | new_rf = 0; |
830 | break; | 831 | break; |
@@ -838,7 +839,9 @@ static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | |||
838 | } | 839 | } |
839 | 840 | ||
840 | static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | 841 | static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, |
841 | const struct dvb_frontend_parameters *params) | 842 | const u32 delsys, |
843 | const u32 freq, | ||
844 | const u32 bw) | ||
842 | { | 845 | { |
843 | /* This function returns the tuned frequency on success, 0 on error */ | 846 | /* This function returns the tuned frequency on success, 0 on error */ |
844 | struct tuner_simple_priv *priv = fe->tuner_priv; | 847 | struct tuner_simple_priv *priv = fe->tuner_priv; |
@@ -847,7 +850,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
847 | u8 config, cb; | 850 | u8 config, cb; |
848 | u32 div; | 851 | u32 div; |
849 | int ret; | 852 | int ret; |
850 | unsigned frequency = params->frequency / 62500; | 853 | u32 frequency = freq / 62500; |
851 | 854 | ||
852 | if (!tun->stepsize) { | 855 | if (!tun->stepsize) { |
853 | /* tuner-core was loaded before the digital tuner was | 856 | /* tuner-core was loaded before the digital tuner was |
@@ -871,7 +874,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | |||
871 | buf[2] = config; | 874 | buf[2] = config; |
872 | buf[3] = cb; | 875 | buf[3] = cb; |
873 | 876 | ||
874 | simple_set_dvb(fe, buf, params); | 877 | simple_set_dvb(fe, buf, delsys, freq, bw); |
875 | 878 | ||
876 | 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", |
877 | tun->name, div, buf[0], buf[1], buf[2], buf[3]); | 880 | tun->name, div, buf[0], buf[1], buf[2], buf[3]); |
@@ -884,13 +887,29 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe, | |||
884 | struct dvb_frontend_parameters *params, | 887 | struct dvb_frontend_parameters *params, |
885 | u8 *buf, int buf_len) | 888 | u8 *buf, int buf_len) |
886 | { | 889 | { |
890 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
891 | u32 delsys = c->delivery_system; | ||
892 | u32 bw = c->bandwidth_hz; | ||
887 | struct tuner_simple_priv *priv = fe->tuner_priv; | 893 | struct tuner_simple_priv *priv = fe->tuner_priv; |
888 | u32 frequency; | 894 | u32 frequency; |
889 | 895 | ||
890 | if (buf_len < 5) | 896 | if (buf_len < 5) |
891 | return -EINVAL; | 897 | return -EINVAL; |
892 | 898 | ||
893 | frequency = simple_dvb_configure(fe, buf+1, params); | 899 | switch (delsys) { |
900 | case SYS_DVBT: | ||
901 | case SYS_DVBT2: | ||
902 | if (params->u.ofdm.bandwidth == BANDWIDTH_6_MHZ) | ||
903 | bw = 6000000; | ||
904 | if (params->u.ofdm.bandwidth == BANDWIDTH_7_MHZ) | ||
905 | bw = 7000000; | ||
906 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | ||
907 | bw = 8000000; | ||
908 | break; | ||
909 | default: | ||
910 | break; | ||
911 | } | ||
912 | frequency = simple_dvb_configure(fe, buf+1, delsys, params->frequency, bw); | ||
894 | if (frequency == 0) | 913 | if (frequency == 0) |
895 | return -EINVAL; | 914 | return -EINVAL; |
896 | 915 | ||
@@ -906,7 +925,12 @@ static int simple_dvb_calc_regs(struct dvb_frontend *fe, | |||
906 | static int simple_dvb_set_params(struct dvb_frontend *fe, | 925 | static int simple_dvb_set_params(struct dvb_frontend *fe, |
907 | struct dvb_frontend_parameters *params) | 926 | struct dvb_frontend_parameters *params) |
908 | { | 927 | { |
928 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
929 | u32 delsys = c->delivery_system; | ||
930 | u32 bw = c->bandwidth_hz; | ||
931 | u32 freq = c->frequency; | ||
909 | struct tuner_simple_priv *priv = fe->tuner_priv; | 932 | struct tuner_simple_priv *priv = fe->tuner_priv; |
933 | u32 frequency; | ||
910 | u32 prev_freq, prev_bw; | 934 | u32 prev_freq, prev_bw; |
911 | int ret; | 935 | int ret; |
912 | u8 buf[5]; | 936 | u8 buf[5]; |
@@ -917,9 +941,14 @@ static int simple_dvb_set_params(struct dvb_frontend *fe, | |||
917 | prev_freq = priv->frequency; | 941 | prev_freq = priv->frequency; |
918 | prev_bw = priv->bandwidth; | 942 | prev_bw = priv->bandwidth; |
919 | 943 | ||
920 | ret = simple_dvb_calc_regs(fe, params, buf, 5); | 944 | frequency = simple_dvb_configure(fe, buf+1, delsys, freq, bw); |
921 | if (ret != 5) | 945 | if (frequency == 0) |
922 | goto fail; | 946 | return -EINVAL; |
947 | |||
948 | buf[0] = priv->i2c_props.addr; | ||
949 | |||
950 | priv->frequency = frequency; | ||
951 | priv->bandwidth = bw; | ||
923 | 952 | ||
924 | /* put analog demod in standby when tuning digital */ | 953 | /* put analog demod in standby when tuning digital */ |
925 | if (fe->ops.analog_ops.standby) | 954 | if (fe->ops.analog_ops.standby) |