V4L/DVB (13355): stv090x: fixes calculation of AGC2 and uses a different AGC2 threshold for cut 3 chips
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>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
b671a8d4b6
commit
b4a4248d56
@@ -1485,7 +1485,7 @@ err:
|
|||||||
|
|
||||||
static int stv090x_get_agc2_min_level(struct stv090x_state *state)
|
static int stv090x_get_agc2_min_level(struct stv090x_state *state)
|
||||||
{
|
{
|
||||||
u32 agc2_min = 0, agc2 = 0, freq_init, freq_step, reg;
|
u32 agc2_min = 0xffff, agc2 = 0, freq_init, freq_step, reg;
|
||||||
s32 i, j, steps, dir;
|
s32 i, j, steps, dir;
|
||||||
|
|
||||||
if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
|
if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
|
||||||
@@ -1536,13 +1536,14 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state)
|
|||||||
if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */
|
if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */
|
||||||
goto err;
|
goto err;
|
||||||
msleep(10);
|
msleep(10);
|
||||||
|
|
||||||
|
agc2 = 0;
|
||||||
for (j = 0; j < 10; j++) {
|
for (j = 0; j < 10; j++) {
|
||||||
agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8;
|
agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) |
|
||||||
agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
|
STV090x_READ_DEMOD(state, AGC2I0);
|
||||||
}
|
}
|
||||||
agc2 /= 10;
|
agc2 /= 10;
|
||||||
agc2_min = 0xffff;
|
if (agc2 < agc2_min)
|
||||||
if (agc2 < 0xffff)
|
|
||||||
agc2_min = agc2;
|
agc2_min = agc2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1584,6 +1585,12 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
|
|||||||
int tmg_lock = 0, i;
|
int tmg_lock = 0, i;
|
||||||
s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq;
|
s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq;
|
||||||
u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg;
|
u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg;
|
||||||
|
u32 agc2th;
|
||||||
|
|
||||||
|
if (state->dev_ver >= 0x30)
|
||||||
|
agc2th = 0x2e00;
|
||||||
|
else
|
||||||
|
agc2th = 0x1f00;
|
||||||
|
|
||||||
reg = STV090x_READ_DEMOD(state, DMDISTATE);
|
reg = STV090x_READ_DEMOD(state, DMDISTATE);
|
||||||
STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */
|
STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */
|
||||||
@@ -1611,7 +1618,7 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
|
|||||||
goto err;
|
goto err;
|
||||||
if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0)
|
if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x60) < 0)
|
if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x50) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (state->dev_ver >= 0x30) {
|
if (state->dev_ver >= 0x30) {
|
||||||
@@ -1661,14 +1668,15 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
|
|||||||
reg = STV090x_READ_DEMOD(state, DSTATUS);
|
reg = STV090x_READ_DEMOD(state, DSTATUS);
|
||||||
if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2)
|
if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2)
|
||||||
tmg_cpt++;
|
tmg_cpt++;
|
||||||
agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8;
|
agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) |
|
||||||
agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
|
STV090x_READ_DEMOD(state, AGC2I0);
|
||||||
}
|
}
|
||||||
agc2 /= 10;
|
agc2 /= 10;
|
||||||
srate_coarse = stv090x_get_srate(state, state->mclk);
|
srate_coarse = stv090x_get_srate(state, state->mclk);
|
||||||
cur_step++;
|
cur_step++;
|
||||||
dir *= -1;
|
dir *= -1;
|
||||||
if ((tmg_cpt >= 5) && (agc2 < 0x1f00) && (srate_coarse < 55000000) && (srate_coarse > 850000))
|
if ((tmg_cpt >= 5) && (agc2 < agc2th) &&
|
||||||
|
(srate_coarse < 50000000) && (srate_coarse > 850000))
|
||||||
tmg_lock = 1;
|
tmg_lock = 1;
|
||||||
else if (cur_step < steps) {
|
else if (cur_step < steps) {
|
||||||
if (dir > 0)
|
if (dir > 0)
|
||||||
@@ -1751,6 +1759,9 @@ static u32 stv090x_srate_srch_fine(struct stv090x_state *state)
|
|||||||
if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
|
if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
if (state->dev_ver >= 0x30) {
|
if (state->dev_ver >= 0x30) {
|
||||||
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0)
|
if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
@@ -1908,8 +1919,8 @@ static int stv090x_blind_search(struct stv090x_state *state)
|
|||||||
cpt_fail = 0;
|
cpt_fail = 0;
|
||||||
agc2_ovflw = 0;
|
agc2_ovflw = 0;
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8;
|
agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) |
|
||||||
agc2 |= STV090x_READ_DEMOD(state, AGC2I0);
|
STV090x_READ_DEMOD(state, AGC2I0);
|
||||||
if (agc2 >= 0xff00)
|
if (agc2 >= 0xff00)
|
||||||
agc2_ovflw++;
|
agc2_ovflw++;
|
||||||
reg = STV090x_READ_DEMOD(state, DSTATUS2);
|
reg = STV090x_READ_DEMOD(state, DSTATUS2);
|
||||||
|
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
#define STV090x_IQPOWER_THRESHOLD 30
|
#define STV090x_IQPOWER_THRESHOLD 30
|
||||||
#define STV090x_SEARCH_AGC2_TH_CUT20 700
|
#define STV090x_SEARCH_AGC2_TH_CUT20 700
|
||||||
#define STV090x_SEARCH_AGC2_TH_CUT30 1200
|
#define STV090x_SEARCH_AGC2_TH_CUT30 1400
|
||||||
|
|
||||||
#define STV090x_SEARCH_AGC2_TH(__ver) \
|
#define STV090x_SEARCH_AGC2_TH(__ver) \
|
||||||
((__ver <= 0x20) ? \
|
((__ver <= 0x20) ? \
|
||||||
|
Reference in New Issue
Block a user