Commit 91171fb6 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] cxd2820r: dvbv5 statistics for DVB-T2

Implement dvbv5 statistics for DVB-T2.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 2832fd31
...@@ -286,8 +286,10 @@ int cxd2820r_get_frontend_t2(struct dvb_frontend *fe, ...@@ -286,8 +286,10 @@ int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status) int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status)
{ {
struct cxd2820r_priv *priv = fe->demodulator_priv; struct cxd2820r_priv *priv = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret; int ret;
u8 buf[1]; unsigned int utmp;
u8 buf[4];
*status = 0; *status = 0;
ret = cxd2820r_rd_reg(priv, 0x02010 , &buf[0]); ret = cxd2820r_rd_reg(priv, 0x02010 , &buf[0]);
...@@ -306,6 +308,79 @@ int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status) ...@@ -306,6 +308,79 @@ int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status)
dev_dbg(&priv->i2c->dev, "%s: lock=%02x\n", __func__, buf[0]); dev_dbg(&priv->i2c->dev, "%s: lock=%02x\n", __func__, buf[0]);
/* Signal strength */
if (*status & FE_HAS_SIGNAL) {
unsigned int strength;
ret = cxd2820r_rd_regs(priv, 0x02026, buf, 2);
if (ret)
goto error;
utmp = buf[0] << 8 | buf[1] << 0;
utmp = ~utmp & 0x0fff;
/* Scale value to 0x0000-0xffff */
strength = utmp << 4 | utmp >> 8;
c->strength.len = 1;
c->strength.stat[0].scale = FE_SCALE_RELATIVE;
c->strength.stat[0].uvalue = strength;
} else {
c->strength.len = 1;
c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
/* CNR */
if (*status & FE_HAS_VITERBI) {
unsigned int cnr;
ret = cxd2820r_rd_regs(priv, 0x02028, buf, 2);
if (ret)
goto error;
utmp = buf[0] << 8 | buf[1] << 0;
utmp = utmp & 0x0fff;
#define CXD2820R_LOG10_8_24 15151336 /* log10(8) << 24 */
if (utmp)
cnr = div_u64((u64)(intlog10(utmp)
- CXD2820R_LOG10_8_24) * 10000,
(1 << 24));
else
cnr = 0;
c->cnr.len = 1;
c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
c->cnr.stat[0].svalue = cnr;
} else {
c->cnr.len = 1;
c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
/* BER */
if (*status & FE_HAS_SYNC) {
unsigned int post_bit_error;
ret = cxd2820r_rd_regs(priv, 0x02039, buf, 4);
if (ret)
goto error;
if ((buf[0] >> 4) & 0x01) {
post_bit_error = buf[0] << 24 | buf[1] << 16 |
buf[2] << 8 | buf[3] << 0;
post_bit_error &= 0x0fffffff;
} else {
post_bit_error = 0;
}
priv->post_bit_error += post_bit_error;
c->post_bit_error.len = 1;
c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
c->post_bit_error.stat[0].uvalue = priv->post_bit_error;
} else {
c->post_bit_error.len = 1;
c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
return ret; return ret;
error: error:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
......
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