diff options
author | Antti Palosaari <crope@iki.fi> | 2012-05-18 14:17:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-20 09:24:12 -0400 |
commit | 78e750754bf0cc86d36149536bc7f3382710a2ee (patch) | |
tree | ef21dffd397bde6a0277d0e0d4757c5cefd5f0c9 /drivers/media | |
parent | 525ffc19b992f5d6a25413c36ba543a82585ed89 (diff) |
[media] rtl2830: implement .read_signal_strength()
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/frontends/rtl2830.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/media/dvb/frontends/rtl2830.c b/drivers/media/dvb/frontends/rtl2830.c index 266098656c48..6e4029de3c73 100644 --- a/drivers/media/dvb/frontends/rtl2830.c +++ b/drivers/media/dvb/frontends/rtl2830.c | |||
@@ -474,8 +474,29 @@ static int rtl2830_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
474 | 474 | ||
475 | static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | 475 | static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
476 | { | 476 | { |
477 | *strength = 0; | 477 | struct rtl2830_priv *priv = fe->demodulator_priv; |
478 | int ret; | ||
479 | u8 buf[2]; | ||
480 | u16 if_agc_raw, if_agc; | ||
481 | |||
482 | ret = rtl2830_rd_regs(priv, 0x359, buf, 2); | ||
483 | if (ret) | ||
484 | goto err; | ||
485 | |||
486 | if_agc_raw = (buf[0] << 8 | buf[1]) & 0x3fff; | ||
487 | |||
488 | if (if_agc_raw & (1 << 9)) | ||
489 | if_agc = -(~(if_agc_raw - 1) & 0x1ff); | ||
490 | else | ||
491 | if_agc = if_agc_raw; | ||
492 | |||
493 | *strength = (u8) (55 - if_agc / 182); | ||
494 | *strength |= *strength << 8; | ||
495 | |||
478 | return 0; | 496 | return 0; |
497 | err: | ||
498 | dbg("%s: failed=%d", __func__, ret); | ||
499 | return ret; | ||
479 | } | 500 | } |
480 | 501 | ||
481 | static struct dvb_frontend_ops rtl2830_ops; | 502 | static struct dvb_frontend_ops rtl2830_ops; |