diff options
author | Antti Palosaari <crope@iki.fi> | 2014-12-09 06:49:44 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-02-02 14:54:35 -0500 |
commit | 871f70252b6fef738cda1834200d25e343ce4825 (patch) | |
tree | dc106198c47a96c0b00e8484bc52fe4a6d3715f0 | |
parent | 47b4dbfff1f31686ac74aae7c69dec23b36005d9 (diff) |
[media] rtl2830: implement DVBv5 signal strength statistics
Estimate signal strength from IF AGC.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/dvb-frontends/rtl2830.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c index c484634a9fc9..641047b89e05 100644 --- a/drivers/media/dvb-frontends/rtl2830.c +++ b/drivers/media/dvb-frontends/rtl2830.c | |||
@@ -246,6 +246,8 @@ static int rtl2830_init(struct dvb_frontend *fe) | |||
246 | goto err; | 246 | goto err; |
247 | 247 | ||
248 | /* init stats here in order signal app which stats are supported */ | 248 | /* init stats here in order signal app which stats are supported */ |
249 | c->strength.len = 1; | ||
250 | c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; | ||
249 | c->cnr.len = 1; | 251 | c->cnr.len = 1; |
250 | c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; | 252 | c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
251 | /* start statistics polling */ | 253 | /* start statistics polling */ |
@@ -693,6 +695,28 @@ static void rtl2830_stat_work(struct work_struct *work) | |||
693 | 695 | ||
694 | dev_dbg(&client->dev, "\n"); | 696 | dev_dbg(&client->dev, "\n"); |
695 | 697 | ||
698 | /* signal strength */ | ||
699 | if (dev->fe_status & FE_HAS_SIGNAL) { | ||
700 | struct {signed int x:14; } s; | ||
701 | |||
702 | /* read IF AGC */ | ||
703 | ret = rtl2830_rd_regs(client, 0x359, buf, 2); | ||
704 | if (ret) | ||
705 | goto err; | ||
706 | |||
707 | u16tmp = buf[0] << 8 | buf[1] << 0; | ||
708 | u16tmp &= 0x3fff; /* [13:0] */ | ||
709 | tmp = s.x = u16tmp; /* 14-bit bin to 2 complement */ | ||
710 | u16tmp = clamp_val(-4 * tmp + 32767, 0x0000, 0xffff); | ||
711 | |||
712 | dev_dbg(&client->dev, "IF AGC=%d\n", tmp); | ||
713 | |||
714 | c->strength.stat[0].scale = FE_SCALE_RELATIVE; | ||
715 | c->strength.stat[0].uvalue = u16tmp; | ||
716 | } else { | ||
717 | c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; | ||
718 | } | ||
719 | |||
696 | /* CNR */ | 720 | /* CNR */ |
697 | if (dev->fe_status & FE_HAS_VITERBI) { | 721 | if (dev->fe_status & FE_HAS_VITERBI) { |
698 | unsigned hierarchy, constellation; | 722 | unsigned hierarchy, constellation; |