diff options
author | Andreas Regel <andreas.regel@gmx.de> | 2009-04-23 13:56:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:40 -0400 |
commit | 2f5914be7c2277cf19699e437cf2c6c15556a085 (patch) | |
tree | 1e9c67c57f78e9fd49cfd9b0bd186908384048bc /drivers/media/dvb/frontends/stv090x.c | |
parent | 64104dc9014d717335ed8ff987feaec1b17c1cd5 (diff) |
V4L/DVB (11595): stv090x: fixes a few bugs
This patch fixes:
* Cut revision was read too late
* Missing increment
* wrong return value
* mismatched entries
Signed-off-by: Andreas Regel <andreas.regel@gmx.de>
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/stv090x.c')
-rw-r--r-- | drivers/media/dvb/frontends/stv090x.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index 3601132778e3..004b774f561c 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
@@ -1943,6 +1943,7 @@ static int stv090x_get_loop_params(struct stv090x_state *state, s32 *freq_inc, s | |||
1943 | 1943 | ||
1944 | srate = state->srate; | 1944 | srate = state->srate; |
1945 | car_max = state->search_range / 1000; | 1945 | car_max = state->search_range / 1000; |
1946 | car_max += car_max / 10; | ||
1946 | car_max = 65536 * (car_max / 2); | 1947 | car_max = 65536 * (car_max / 2); |
1947 | car_max /= (state->mclk / 1000); | 1948 | car_max /= (state->mclk / 1000); |
1948 | 1949 | ||
@@ -2003,6 +2004,7 @@ static int stv090x_chk_signal(struct stv090x_state *state) | |||
2003 | 2004 | ||
2004 | offst_car = STV090x_READ_DEMOD(state, CFR2) << 8; | 2005 | offst_car = STV090x_READ_DEMOD(state, CFR2) << 8; |
2005 | offst_car |= STV090x_READ_DEMOD(state, CFR1); | 2006 | offst_car |= STV090x_READ_DEMOD(state, CFR1); |
2007 | offst_car = comp2(offst_car, 16); | ||
2006 | 2008 | ||
2007 | agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8; | 2009 | agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8; |
2008 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 2010 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); |
@@ -2065,6 +2067,9 @@ static int stv090x_search_car_loop(struct stv090x_state *state, s32 inc, s32 tim | |||
2065 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x1); | 2067 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x1); |
2066 | if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) | 2068 | if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) |
2067 | goto err; | 2069 | goto err; |
2070 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 0x0); | ||
2071 | if (STV090x_WRITE_DEMOD(state, TSCFGH, reg) < 0) | ||
2072 | goto err; | ||
2068 | } | 2073 | } |
2069 | 2074 | ||
2070 | if (zigzag) { | 2075 | if (zigzag) { |
@@ -2076,6 +2081,8 @@ static int stv090x_search_car_loop(struct stv090x_state *state, s32 inc, s32 tim | |||
2076 | offst_freq += 2 * inc; | 2081 | offst_freq += 2 * inc; |
2077 | } | 2082 | } |
2078 | 2083 | ||
2084 | cpt_step++; | ||
2085 | |||
2079 | lock = stv090x_get_dmdlock(state, timeout); | 2086 | lock = stv090x_get_dmdlock(state, timeout); |
2080 | no_signal = stv090x_chk_signal(state); | 2087 | no_signal = stv090x_chk_signal(state); |
2081 | 2088 | ||
@@ -2149,7 +2156,7 @@ static int stv090x_sw_algo(struct stv090x_state *state) | |||
2149 | if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x68) < 0) | 2156 | if (STV090x_WRITE_DEMOD(state, CORRELABS, 0x68) < 0) |
2150 | goto err; | 2157 | goto err; |
2151 | } | 2158 | } |
2152 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, 0x69) < 0) | 2159 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, 0xc9) < 0) |
2153 | goto err; | 2160 | goto err; |
2154 | zigzag = 0; | 2161 | zigzag = 0; |
2155 | break; | 2162 | break; |
@@ -2310,7 +2317,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st | |||
2310 | if (state->algo == STV090x_BLIND_SEARCH) { | 2317 | if (state->algo == STV090x_BLIND_SEARCH) { |
2311 | tmg = STV090x_READ_DEMOD(state, TMGREG2); | 2318 | tmg = STV090x_READ_DEMOD(state, TMGREG2); |
2312 | STV090x_WRITE_DEMOD(state, SFRSTEP, 0x5c); | 2319 | STV090x_WRITE_DEMOD(state, SFRSTEP, 0x5c); |
2313 | while ((i <= 50) && (!tmg) && (tmg != 0xff)) { | 2320 | while ((i <= 50) && (tmg != 0) && (tmg != 0xff)) { |
2314 | tmg = STV090x_READ_DEMOD(state, TMGREG2); | 2321 | tmg = STV090x_READ_DEMOD(state, TMGREG2); |
2315 | msleep(5); | 2322 | msleep(5); |
2316 | i += 5; | 2323 | i += 5; |
@@ -2347,7 +2354,7 @@ static enum stv090x_signal_state stv090x_get_sig_params(struct stv090x_state *st | |||
2347 | stv090x_i2c_gate_ctrl(fe, 0); | 2354 | stv090x_i2c_gate_ctrl(fe, 0); |
2348 | 2355 | ||
2349 | if (abs(offst_freq) <= ((state->search_range / 2000) + 500)) | 2356 | if (abs(offst_freq) <= ((state->search_range / 2000) + 500)) |
2350 | return STV090x_RANGEOK; | 2357 | return STV090x_RANGEOK; |
2351 | else if (abs(offst_freq) <= (stv090x_car_width(state->srate, state->rolloff) / 2000)) | 2358 | else if (abs(offst_freq) <= (stv090x_car_width(state->srate, state->rolloff) / 2000)) |
2352 | return STV090x_RANGEOK; | 2359 | return STV090x_RANGEOK; |
2353 | else | 2360 | else |
@@ -2569,8 +2576,8 @@ static int stv090x_optimize_track(struct stv090x_state *state) | |||
2569 | 2576 | ||
2570 | case STV090x_DVBS2: | 2577 | case STV090x_DVBS2: |
2571 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); | 2578 | reg = STV090x_READ_DEMOD(state, DMDCFGMD); |
2572 | STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 1); | 2579 | STV090x_SETFIELD_Px(reg, DVBS1_ENABLE_FIELD, 0); |
2573 | STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 0); | 2580 | STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1); |
2574 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | 2581 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) |
2575 | goto err; | 2582 | goto err; |
2576 | if (STV090x_WRITE_DEMOD(state, ACLC, 0) < 0) | 2583 | if (STV090x_WRITE_DEMOD(state, ACLC, 0) < 0) |
@@ -3115,7 +3122,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3115 | if ((signal_state == STV090x_NODATA) && (!no_signal)) { | 3122 | if ((signal_state == STV090x_NODATA) && (!no_signal)) { |
3116 | if (state->dev_ver <= 0x11) { | 3123 | if (state->dev_ver <= 0x11) { |
3117 | reg = STV090x_READ_DEMOD(state, DMDSTATE); | 3124 | reg = STV090x_READ_DEMOD(state, DMDSTATE); |
3118 | if (((STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD)) == STV090x_DVBS2) && (state->inversion == INVERSION_AUTO)) | 3125 | if (((STV090x_GETFIELD_Px(reg, HEADER_MODE_FIELD)) == STV090x_DVBS1) && (state->inversion == INVERSION_AUTO)) |
3119 | signal_state = stv090x_acq_fixs1(state); | 3126 | signal_state = stv090x_acq_fixs1(state); |
3120 | } | 3127 | } |
3121 | } | 3128 | } |
@@ -3139,7 +3146,7 @@ static enum dvbfe_search stv090x_search(struct dvb_frontend *fe, struct dvb_fron | |||
3139 | state->fec = STV090x_PRERR; | 3146 | state->fec = STV090x_PRERR; |
3140 | state->search_range = 2000000; | 3147 | state->search_range = 2000000; |
3141 | 3148 | ||
3142 | if (!stv090x_algo(state)) { | 3149 | if (stv090x_algo(state) == STV090x_RANGEOK) { |
3143 | dprintk(FE_DEBUG, 1, "Search success!"); | 3150 | dprintk(FE_DEBUG, 1, "Search success!"); |
3144 | return DVBFE_ALGO_SEARCH_SUCCESS; | 3151 | return DVBFE_ALGO_SEARCH_SUCCESS; |
3145 | } else { | 3152 | } else { |
@@ -3949,12 +3956,13 @@ static int stv090x_setup(struct dvb_frontend *fe) | |||
3949 | msleep(5); | 3956 | msleep(5); |
3950 | 3957 | ||
3951 | /* write initval */ | 3958 | /* write initval */ |
3959 | dprintk(FE_DEBUG, 1, "Setting up initial values"); | ||
3952 | for (i = 0; i < t1_size; i++) { | 3960 | for (i = 0; i < t1_size; i++) { |
3953 | dprintk(FE_DEBUG, 1, "Setting up initial values"); | ||
3954 | if (stv090x_write_reg(state, stv090x_initval[i].addr, stv090x_initval[i].data) < 0) | 3961 | if (stv090x_write_reg(state, stv090x_initval[i].addr, stv090x_initval[i].data) < 0) |
3955 | goto err; | 3962 | goto err; |
3956 | } | 3963 | } |
3957 | 3964 | ||
3965 | state->dev_ver = stv090x_read_reg(state, STV090x_MID); | ||
3958 | if (state->dev_ver >= 0x20) { | 3966 | if (state->dev_ver >= 0x20) { |
3959 | if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c) < 0) | 3967 | if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c) < 0) |
3960 | goto err; | 3968 | goto err; |
@@ -4047,7 +4055,6 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, | |||
4047 | dprintk(FE_ERROR, 1, "Error waking device"); | 4055 | dprintk(FE_ERROR, 1, "Error waking device"); |
4048 | goto error; | 4056 | goto error; |
4049 | } | 4057 | } |
4050 | state->dev_ver = stv090x_read_reg(state, STV090x_MID); | ||
4051 | 4058 | ||
4052 | dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x\n", | 4059 | dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x\n", |
4053 | state->device == STV0900 ? "STV0900" : "STV0903", | 4060 | state->device == STV0900 ? "STV0900" : "STV0903", |