Commit 3e41313a authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] af9033: implement DVBv5 statistics for CNR

Return CNR via DVBv5 statistics API.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 83f11619
...@@ -1054,11 +1054,12 @@ static void af9033_stat_work(struct work_struct *work) ...@@ -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 af9033_dev *dev = container_of(work, struct af9033_dev, stat_work.work);
struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache;
int ret, tmp; int ret, tmp, i, len;
u8 u8tmp; u8 u8tmp, buf[3];
dev_dbg(&dev->client->dev, "\n"); dev_dbg(&dev->client->dev, "\n");
/* signal strength */
if (dev->fe_status & FE_HAS_SIGNAL) { if (dev->fe_status & FE_HAS_SIGNAL) {
if (dev->is_af9035) { if (dev->is_af9035) {
ret = af9033_rd_reg(dev, 0x80004a, &u8tmp); ret = af9033_rd_reg(dev, 0x80004a, &u8tmp);
...@@ -1078,6 +1079,55 @@ static void af9033_stat_work(struct work_struct *work) ...@@ -1078,6 +1079,55 @@ static void af9033_stat_work(struct work_struct *work)
c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 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)); schedule_delayed_work(&dev->stat_work, msecs_to_jiffies(2000));
return; return;
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment