summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/af9033.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-09-02 04:24:41 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-09-21 19:44:59 -0300
commit3e41313aeadfc5e3b3f827519f3840bca1b98f6d (patch)
treeb0708ecd916d4655b74f102623b21b282f337384 /drivers/media/dvb-frontends/af9033.c
parent83f1161911c5f32dc4cfa817a73ae028d32c43b7 (diff)
downloadblackbird-obmc-linux-3e41313aeadfc5e3b3f827519f3840bca1b98f6d.tar.gz
blackbird-obmc-linux-3e41313aeadfc5e3b3f827519f3840bca1b98f6d.zip
[media] af9033: implement DVBv5 statistics for CNR
Return CNR via DVBv5 statistics API. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends/af9033.c')
-rw-r--r--drivers/media/dvb-frontends/af9033.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index b9a0b009aeda..576e9b5f4bbf 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -1054,11 +1054,12 @@ static void af9033_stat_work(struct work_struct *work)
{
struct af9033_dev *dev = container_of(work, struct af9033_dev, stat_work.work);
struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
- int ret, tmp;
- u8 u8tmp;
+ int ret, tmp, i, len;
+ u8 u8tmp, buf[3];
dev_dbg(&dev->client->dev, "\n");
+ /* signal strength */
if (dev->fe_status & FE_HAS_SIGNAL) {
if (dev->is_af9035) {
ret = af9033_rd_reg(dev, 0x80004a, &u8tmp);
@@ -1078,6 +1079,55 @@ static void af9033_stat_work(struct work_struct *work)
c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
+ /* CNR */
+ if (dev->fe_status & FE_HAS_VITERBI) {
+ u32 snr_val;
+ const struct val_snr *snr_lut;
+
+ /* read value */
+ ret = af9033_rd_regs(dev, 0x80002c, buf, 3);
+ if (ret)
+ goto err;
+
+ snr_val = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0);
+
+ /* read current modulation */
+ ret = af9033_rd_reg(dev, 0x80f903, &u8tmp);
+ if (ret)
+ goto err;
+
+ switch ((u8tmp >> 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_schedule_delayed_work;
+ }
+
+ for (i = 0; i < len; i++) {
+ tmp = snr_lut[i].snr * 1000;
+ if (snr_val < snr_lut[i].val)
+ break;
+ }
+
+ c->cnr.len = 1;
+ c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+ c->cnr.stat[0].svalue = tmp;
+ } else {
+ c->cnr.len = 1;
+ c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+ }
+
+err_schedule_delayed_work:
schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
return;
err:
OpenPOWER on IntegriCloud