diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-17 10:06:23 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-17 10:06:23 -0300 |
commit | 47a1368908d1a5cd3548d44cfa19853c26ddfeaf (patch) | |
tree | 3f6e533e608f3158b37980e1dbbafea627f3b47a /linux/drivers/media/dvb/frontends/dib7000p.c | |
parent | aeb3a788273d65fa47c79635a886bcafc7970807 (diff) | |
parent | f8c7dcdb0142ecb0a9634945df8bd9b26522f5b7 (diff) | |
download | mediapointer-dvb-s2-47a1368908d1a5cd3548d44cfa19853c26ddfeaf.tar.gz mediapointer-dvb-s2-47a1368908d1a5cd3548d44cfa19853c26ddfeaf.tar.bz2 |
merge: http://www.linuxtv.org/hg/~hverkuil/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux/drivers/media/dvb/frontends/dib7000p.c')
-rw-r--r-- | linux/drivers/media/dvb/frontends/dib7000p.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/linux/drivers/media/dvb/frontends/dib7000p.c b/linux/drivers/media/dvb/frontends/dib7000p.c index d56de75db..57bee771c 100644 --- a/linux/drivers/media/dvb/frontends/dib7000p.c +++ b/linux/drivers/media/dvb/frontends/dib7000p.c @@ -11,6 +11,7 @@ #include <linux/i2c.h> #include "compat.h" +#include "dvb_math.h" #include "dvb_frontend.h" #include "dib7000p.h" @@ -1243,7 +1244,37 @@ static int dib7000p_read_signal_strength(struct dvb_frontend *fe, u16 *strength) static int dib7000p_read_snr(struct dvb_frontend* fe, u16 *snr) { - *snr = 0x0000; + struct dib7000p_state *state = fe->demodulator_priv; + u16 val; + s32 signal_mant, signal_exp, noise_mant, noise_exp; + u32 result = 0; + + val = dib7000p_read_word(state, 479); + noise_mant = (val >> 4) & 0xff; + noise_exp = ((val & 0xf) << 2); + val = dib7000p_read_word(state, 480); + noise_exp += ((val >> 14) & 0x3); + if ((noise_exp & 0x20) != 0) + noise_exp -= 0x40; + + signal_mant = (val >> 6) & 0xFF; + signal_exp = (val & 0x3F); + if ((signal_exp & 0x20) != 0) + signal_exp -= 0x40; + + if (signal_mant != 0) + result = intlog10(2) * 10 * signal_exp + 10 * + intlog10(signal_mant); + else + result = intlog10(2) * 10 * signal_exp - 100; + + if (noise_mant != 0) + result -= intlog10(2) * 10 * noise_exp + 10 * + intlog10(noise_mant); + else + result -= intlog10(2) * 10 * noise_exp - 100; + + *snr = result / ((1 << 24) / 10); return 0; } |