[PATCH] dvb: frontend: mt352: fix signal strength reading
authorBarry Scott <barry.scott@onelan.co.uk>
Fri, 9 Sep 2005 20:02:29 +0000 (13:02 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 9 Sep 2005 20:57:37 +0000 (13:57 -0700)
Fix two problems with the signal strength value in the mt352.c frontend:
1. the 4 most significant bits are zeroed - shift and mask wrong way round
2. need to align the 12 bits from the registers at the top of the 16 bit
   returned value - otherwise the range is not 0 to 0xffff its 0xf000 to 0xffff

Signed-off-by: Barry Scott <barry.scott@onelan.co.uk>
Signed-off-by: Johannes Stezenbach <js@linuxtv.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/media/dvb/frontends/mt352.c

index d32dc4de9e7f1fafd539e7e9de758705760b3613..cc1bc0edd65e7d14424744985cc83c89a0b054ae 100644 (file)
@@ -462,9 +462,11 @@ static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 {
        struct mt352_state* state = fe->demodulator_priv;
 
-       u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) |
-                     (mt352_read_register(state, AGC_GAIN_0));
+       /* align the 12 bit AGC gain with the most significant bits */
+       u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) |
+               (mt352_read_register(state, AGC_GAIN_0) << 4);
 
+       /* inverse of gain is signal strength */
        *strength = ~signal;
        return 0;
 }