diff options
author | Antti Palosaari <crope@iki.fi> | 2010-10-07 15:34:55 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:17:55 -0400 |
commit | 9e35cd222bc913f34b8f69e2b41daa7aa041d79a (patch) | |
tree | d8384021c5c301b1d672524acbd400c566306072 /drivers/media/dvb | |
parent | edb709b61abd3ba475e59d1ad81aab21ad025db6 (diff) |
[media] af9013: cache some reg values to reduce reg reads
Demod + tuner specific RF AGC and IF AGC limit values are read from demod
memory in every signal strength query. Cache those to reduce I2C traffic.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r-- | drivers/media/dvb/frontends/af9013.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c index 6a205e68fde7..e2a95c07bab4 100644 --- a/drivers/media/dvb/frontends/af9013.c +++ b/drivers/media/dvb/frontends/af9013.c | |||
@@ -42,6 +42,8 @@ struct af9013_state { | |||
42 | 42 | ||
43 | struct af9013_config config; | 43 | struct af9013_config config; |
44 | 44 | ||
45 | /* tuner/demod RF and IF AGC limits used for signal strength calc */ | ||
46 | u8 signal_strength_en, rf_50, rf_80, if_50, if_80; | ||
45 | u16 signal_strength; | 47 | u16 signal_strength; |
46 | u32 ber; | 48 | u32 ber; |
47 | u32 ucblocks; | 49 | u32 ucblocks; |
@@ -963,45 +965,31 @@ static int af9013_update_signal_strength(struct dvb_frontend *fe) | |||
963 | { | 965 | { |
964 | struct af9013_state *state = fe->demodulator_priv; | 966 | struct af9013_state *state = fe->demodulator_priv; |
965 | int ret; | 967 | int ret; |
966 | u8 tmp0; | 968 | u8 rf_gain, if_gain; |
967 | u8 rf_gain, rf_50, rf_80, if_gain, if_50, if_80; | ||
968 | int signal_strength; | 969 | int signal_strength; |
969 | 970 | ||
970 | deb_info("%s\n", __func__); | 971 | deb_info("%s\n", __func__); |
971 | 972 | ||
972 | state->signal_strength = 0; | 973 | if (state->signal_strength_en) { |
973 | |||
974 | ret = af9013_read_reg_bits(state, 0x9bee, 0, 1, &tmp0); | ||
975 | if (ret) | ||
976 | goto error; | ||
977 | if (tmp0) { | ||
978 | ret = af9013_read_reg(state, 0x9bbd, &rf_50); | ||
979 | if (ret) | ||
980 | goto error; | ||
981 | ret = af9013_read_reg(state, 0x9bd0, &rf_80); | ||
982 | if (ret) | ||
983 | goto error; | ||
984 | ret = af9013_read_reg(state, 0x9be2, &if_50); | ||
985 | if (ret) | ||
986 | goto error; | ||
987 | ret = af9013_read_reg(state, 0x9be4, &if_80); | ||
988 | if (ret) | ||
989 | goto error; | ||
990 | ret = af9013_read_reg(state, 0xd07c, &rf_gain); | 974 | ret = af9013_read_reg(state, 0xd07c, &rf_gain); |
991 | if (ret) | 975 | if (ret) |
992 | goto error; | 976 | goto error; |
993 | ret = af9013_read_reg(state, 0xd07d, &if_gain); | 977 | ret = af9013_read_reg(state, 0xd07d, &if_gain); |
994 | if (ret) | 978 | if (ret) |
995 | goto error; | 979 | goto error; |
996 | signal_strength = (0xffff / (9 * (rf_50 + if_50) - \ | 980 | signal_strength = (0xffff / \ |
997 | 11 * (rf_80 + if_80))) * (10 * (rf_gain + if_gain) - \ | 981 | (9 * (state->rf_50 + state->if_50) - \ |
998 | 11 * (rf_80 + if_80)); | 982 | 11 * (state->rf_80 + state->if_80))) * \ |
983 | (10 * (rf_gain + if_gain) - \ | ||
984 | 11 * (state->rf_80 + state->if_80)); | ||
999 | if (signal_strength < 0) | 985 | if (signal_strength < 0) |
1000 | signal_strength = 0; | 986 | signal_strength = 0; |
1001 | else if (signal_strength > 0xffff) | 987 | else if (signal_strength > 0xffff) |
1002 | signal_strength = 0xffff; | 988 | signal_strength = 0xffff; |
1003 | 989 | ||
1004 | state->signal_strength = signal_strength; | 990 | state->signal_strength = signal_strength; |
991 | } else { | ||
992 | state->signal_strength = 0; | ||
1005 | } | 993 | } |
1006 | 994 | ||
1007 | error: | 995 | error: |
@@ -1306,6 +1294,27 @@ static int af9013_init(struct dvb_frontend *fe) | |||
1306 | if (ret) | 1294 | if (ret) |
1307 | goto error; | 1295 | goto error; |
1308 | 1296 | ||
1297 | /* read values needed for signal strength calculation */ | ||
1298 | ret = af9013_read_reg_bits(state, 0x9bee, 0, 1, | ||
1299 | &state->signal_strength_en); | ||
1300 | if (ret) | ||
1301 | goto error; | ||
1302 | |||
1303 | if (state->signal_strength_en) { | ||
1304 | ret = af9013_read_reg(state, 0x9bbd, &state->rf_50); | ||
1305 | if (ret) | ||
1306 | goto error; | ||
1307 | ret = af9013_read_reg(state, 0x9bd0, &state->rf_80); | ||
1308 | if (ret) | ||
1309 | goto error; | ||
1310 | ret = af9013_read_reg(state, 0x9be2, &state->if_50); | ||
1311 | if (ret) | ||
1312 | goto error; | ||
1313 | ret = af9013_read_reg(state, 0x9be4, &state->if_80); | ||
1314 | if (ret) | ||
1315 | goto error; | ||
1316 | } | ||
1317 | |||
1309 | error: | 1318 | error: |
1310 | return ret; | 1319 | return ret; |
1311 | } | 1320 | } |