Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164110
b: refs/heads/master
c: ef80196
h: refs/heads/master
v: v3
  • Loading branch information
Olivier Grenie authored and Mauro Carvalho Chehab committed Sep 19, 2009
1 parent 006278b commit 522fd33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 74b76f213640b4ebde9134d94a8013dbfecfcd93
refs/heads/master: ef80196490d6533e74a49509112804aa88a21c6f
33 changes: 32 additions & 1 deletion trunk/drivers/media/dvb/frontends/dib7000p.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/i2c.h>

#include "dvb_math.h"
#include "dvb_frontend.h"

#include "dib7000p.h"
Expand Down Expand Up @@ -1217,7 +1218,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;
}

Expand Down

0 comments on commit 522fd33

Please sign in to comment.