diff options
author | Andreas Regel <andreas.regel@gmx.de> | 2009-11-13 16:16:44 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:41:29 -0500 |
commit | b4a4248d56a6985f5d37fc5a219ba0675fc6f503 (patch) | |
tree | fa45bffdd5547fe41ec2fec166c484a6459dbc36 /drivers/media/dvb/frontends | |
parent | b671a8d4b68626142a9a34da59c55396d2cf0ce9 (diff) |
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>
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r-- | drivers/media/dvb/frontends/stv090x.c | 33 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/stv090x_priv.h | 2 |
2 files changed, 23 insertions, 12 deletions
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index fe03bac5b2e4..8c0d351405f3 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
@@ -1485,7 +1485,7 @@ err: | |||
1485 | 1485 | ||
1486 | static int stv090x_get_agc2_min_level(struct stv090x_state *state) | 1486 | static int stv090x_get_agc2_min_level(struct stv090x_state *state) |
1487 | { | 1487 | { |
1488 | u32 agc2_min = 0, agc2 = 0, freq_init, freq_step, reg; | 1488 | u32 agc2_min = 0xffff, agc2 = 0, freq_init, freq_step, reg; |
1489 | s32 i, j, steps, dir; | 1489 | s32 i, j, steps, dir; |
1490 | 1490 | ||
1491 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) | 1491 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) |
@@ -1536,13 +1536,14 @@ static int stv090x_get_agc2_min_level(struct stv090x_state *state) | |||
1536 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */ | 1536 | if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x58) < 0) /* Demod RESET */ |
1537 | goto err; | 1537 | goto err; |
1538 | msleep(10); | 1538 | msleep(10); |
1539 | |||
1540 | agc2 = 0; | ||
1539 | for (j = 0; j < 10; j++) { | 1541 | for (j = 0; j < 10; j++) { |
1540 | agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8; | 1542 | agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | |
1541 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 1543 | STV090x_READ_DEMOD(state, AGC2I0); |
1542 | } | 1544 | } |
1543 | agc2 /= 10; | 1545 | agc2 /= 10; |
1544 | agc2_min = 0xffff; | 1546 | if (agc2 < agc2_min) |
1545 | if (agc2 < 0xffff) | ||
1546 | agc2_min = agc2; | 1547 | agc2_min = agc2; |
1547 | } | 1548 | } |
1548 | 1549 | ||
@@ -1584,6 +1585,12 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1584 | int tmg_lock = 0, i; | 1585 | int tmg_lock = 0, i; |
1585 | s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq; | 1586 | s32 tmg_cpt = 0, dir = 1, steps, cur_step = 0, freq; |
1586 | u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg; | 1587 | u32 srate_coarse = 0, agc2 = 0, car_step = 1200, reg; |
1588 | u32 agc2th; | ||
1589 | |||
1590 | if (state->dev_ver >= 0x30) | ||
1591 | agc2th = 0x2e00; | ||
1592 | else | ||
1593 | agc2th = 0x1f00; | ||
1587 | 1594 | ||
1588 | reg = STV090x_READ_DEMOD(state, DMDISTATE); | 1595 | reg = STV090x_READ_DEMOD(state, DMDISTATE); |
1589 | STV090x_SETFIELD_Px(reg, I2C_DEMOD_MODE_FIELD, 0x1f); /* Demod RESET */ | 1596 | 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) | |||
1611 | goto err; | 1618 | goto err; |
1612 | if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0) | 1619 | if (STV090x_WRITE_DEMOD(state, DMDTOM, 0x00) < 0) |
1613 | goto err; | 1620 | goto err; |
1614 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x60) < 0) | 1621 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x50) < 0) |
1615 | goto err; | 1622 | goto err; |
1616 | 1623 | ||
1617 | if (state->dev_ver >= 0x30) { | 1624 | if (state->dev_ver >= 0x30) { |
@@ -1661,14 +1668,15 @@ static u32 stv090x_srate_srch_coarse(struct stv090x_state *state) | |||
1661 | reg = STV090x_READ_DEMOD(state, DSTATUS); | 1668 | reg = STV090x_READ_DEMOD(state, DSTATUS); |
1662 | if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2) | 1669 | if (STV090x_GETFIELD_Px(reg, TMGLOCK_QUALITY_FIELD) >= 2) |
1663 | tmg_cpt++; | 1670 | tmg_cpt++; |
1664 | agc2 += STV090x_READ_DEMOD(state, AGC2I1) << 8; | 1671 | agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | |
1665 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 1672 | STV090x_READ_DEMOD(state, AGC2I0); |
1666 | } | 1673 | } |
1667 | agc2 /= 10; | 1674 | agc2 /= 10; |
1668 | srate_coarse = stv090x_get_srate(state, state->mclk); | 1675 | srate_coarse = stv090x_get_srate(state, state->mclk); |
1669 | cur_step++; | 1676 | cur_step++; |
1670 | dir *= -1; | 1677 | dir *= -1; |
1671 | if ((tmg_cpt >= 5) && (agc2 < 0x1f00) && (srate_coarse < 55000000) && (srate_coarse > 850000)) | 1678 | if ((tmg_cpt >= 5) && (agc2 < agc2th) && |
1679 | (srate_coarse < 50000000) && (srate_coarse > 850000)) | ||
1672 | tmg_lock = 1; | 1680 | tmg_lock = 1; |
1673 | else if (cur_step < steps) { | 1681 | else if (cur_step < steps) { |
1674 | if (dir > 0) | 1682 | if (dir > 0) |
@@ -1751,6 +1759,9 @@ static u32 stv090x_srate_srch_fine(struct stv090x_state *state) | |||
1751 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) | 1759 | if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0) |
1752 | goto err; | 1760 | goto err; |
1753 | 1761 | ||
1762 | if (STV090x_WRITE_DEMOD(state, AGC2REF, 0x38) < 0) | ||
1763 | goto err; | ||
1764 | |||
1754 | if (state->dev_ver >= 0x30) { | 1765 | if (state->dev_ver >= 0x30) { |
1755 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0) | 1766 | if (STV090x_WRITE_DEMOD(state, CARFREQ, 0x79) < 0) |
1756 | goto err; | 1767 | goto err; |
@@ -1908,8 +1919,8 @@ static int stv090x_blind_search(struct stv090x_state *state) | |||
1908 | cpt_fail = 0; | 1919 | cpt_fail = 0; |
1909 | agc2_ovflw = 0; | 1920 | agc2_ovflw = 0; |
1910 | for (i = 0; i < 10; i++) { | 1921 | for (i = 0; i < 10; i++) { |
1911 | agc2 = STV090x_READ_DEMOD(state, AGC2I1) << 8; | 1922 | agc2 += (STV090x_READ_DEMOD(state, AGC2I1) << 8) | |
1912 | agc2 |= STV090x_READ_DEMOD(state, AGC2I0); | 1923 | STV090x_READ_DEMOD(state, AGC2I0); |
1913 | if (agc2 >= 0xff00) | 1924 | if (agc2 >= 0xff00) |
1914 | agc2_ovflw++; | 1925 | agc2_ovflw++; |
1915 | reg = STV090x_READ_DEMOD(state, DSTATUS2); | 1926 | reg = STV090x_READ_DEMOD(state, DSTATUS2); |
diff --git a/drivers/media/dvb/frontends/stv090x_priv.h b/drivers/media/dvb/frontends/stv090x_priv.h index 5a4a01740d88..5696816b88a4 100644 --- a/drivers/media/dvb/frontends/stv090x_priv.h +++ b/drivers/media/dvb/frontends/stv090x_priv.h | |||
@@ -83,7 +83,7 @@ | |||
83 | 83 | ||
84 | #define STV090x_IQPOWER_THRESHOLD 30 | 84 | #define STV090x_IQPOWER_THRESHOLD 30 |
85 | #define STV090x_SEARCH_AGC2_TH_CUT20 700 | 85 | #define STV090x_SEARCH_AGC2_TH_CUT20 700 |
86 | #define STV090x_SEARCH_AGC2_TH_CUT30 1200 | 86 | #define STV090x_SEARCH_AGC2_TH_CUT30 1400 |
87 | 87 | ||
88 | #define STV090x_SEARCH_AGC2_TH(__ver) \ | 88 | #define STV090x_SEARCH_AGC2_TH(__ver) \ |
89 | ((__ver <= 0x20) ? \ | 89 | ((__ver <= 0x20) ? \ |