diff options
author | Antti Palosaari <crope@iki.fi> | 2012-04-01 12:50:02 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-04-09 14:44:45 -0300 |
commit | e898ef627214627883ed950ef3da5fa5788beb41 (patch) | |
tree | 9d67ebd21a4eddb62f5248d8ea44200c6c4e8c62 /drivers/media/dvb/frontends/af9033.c | |
parent | 3a871ca270545194887ddae726b51f1e2bf45f32 (diff) | |
download | op-kernel-dev-e898ef627214627883ed950ef3da5fa5788beb41.zip op-kernel-dev-e898ef627214627883ed950ef3da5fa5788beb41.tar.gz |
[media] af9033: implement .read_snr()
Returns values as 0.1 dB resolution as preferred nowadays.
Actual resolution is 1 dB.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/af9033.c')
-rw-r--r-- | drivers/media/dvb/frontends/af9033.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/media/dvb/frontends/af9033.c b/drivers/media/dvb/frontends/af9033.c index 9ade510..40ef4b1 100644 --- a/drivers/media/dvb/frontends/af9033.c +++ b/drivers/media/dvb/frontends/af9033.c @@ -540,9 +540,56 @@ err: static int af9033_read_snr(struct dvb_frontend *fe, u16 *snr) { - *snr = 0; + struct af9033_state *state = fe->demodulator_priv; + int ret, i, len; + u8 buf[3], tmp; + u32 snr_val; + const struct val_snr *uninitialized_var(snr_lut); + + /* read value */ + ret = af9033_rd_regs(state, 0x80002c, buf, 3); + if (ret < 0) + goto err; + + snr_val = (buf[2] << 16) | (buf[1] << 8) | buf[0]; + + /* read current modulation */ + ret = af9033_rd_reg(state, 0x80f903, &tmp); + if (ret < 0) + goto err; + + switch ((tmp >> 0) & 3) { + case 0: + len = ARRAY_SIZE(qpsk_snr_lut); + snr_lut = qpsk_snr_lut; + break; + case 1: + len = ARRAY_SIZE(qam16_snr_lut); + snr_lut = qam16_snr_lut; + break; + case 2: + len = ARRAY_SIZE(qam64_snr_lut); + snr_lut = qam64_snr_lut; + break; + default: + goto err; + } + + for (i = 0; i < len; i++) { + tmp = snr_lut[i].snr; + + if (snr_val < snr_lut[i].val) + break; + } + + *snr = tmp * 10; /* dB/10 */ return 0; + +err: + pr_debug("%s: failed=%d\n", __func__, ret); + + return ret; } static int af9033_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |