aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2012-02-12 13:03:03 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-03-08 06:54:42 -0500
commit06302ffbb470359c8cbcf1ee8b057d6930300f90 (patch)
treed2f8ad2bf7b0bf2650eecc1d9643c94464f07944 /drivers
parent6c5637e4eda58292f7d9ee6ee0b1f9aa4b0a7e7f (diff)
[media] cx22702: Fix signal strength
The signal strength value returned is not quite correct, it decreases when I increase the gain of my antenna, and vice versa. It also doesn't span over the whole 0x0000-0xffff range. Compute a value which at least increases when signal strength increases, and spans the whole allowed range. In practice I get 67% with my antenna fully amplified and 51% with no amplification. This is close enough to what I get on my other DVB-T adapter with the same antenna. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/frontends/cx22702.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index faba82485086..edc8eafc5c09 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -502,10 +502,26 @@ static int cx22702_read_signal_strength(struct dvb_frontend *fe,
502 u16 *signal_strength) 502 u16 *signal_strength)
503{ 503{
504 struct cx22702_state *state = fe->demodulator_priv; 504 struct cx22702_state *state = fe->demodulator_priv;
505 u8 reg23;
505 506
506 u16 rs_ber; 507 /*
507 rs_ber = cx22702_readreg(state, 0x23); 508 * Experience suggests that the strength signal register works as
508 *signal_strength = (rs_ber << 8) | rs_ber; 509 * follows:
510 * - In the absence of signal, value is 0xff.
511 * - In the presence of a weak signal, bit 7 is set, not sure what
512 * the lower 7 bits mean.
513 * - In the presence of a strong signal, the register holds a 7-bit
514 * value (bit 7 is cleared), with greater values standing for
515 * weaker signals.
516 */
517 reg23 = cx22702_readreg(state, 0x23);
518 if (reg23 & 0x80) {
519 *signal_strength = 0;
520 } else {
521 reg23 = ~reg23 & 0x7f;
522 /* Scale to 16 bit */
523 *signal_strength = (reg23 << 9) | (reg23 << 2) | (reg23 >> 5);
524 }
509 525
510 return 0; 526 return 0;
511} 527}