diff options
author | Antti Palosaari <crope@iki.fi> | 2016-08-08 20:12:00 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-09-22 09:39:36 -0400 |
commit | 91171fb63e1b09fea18465248a748c48b0d33451 (patch) | |
tree | 5fc078bfbb9eb67c97d5bba280aee015caab2dc2 | |
parent | 2832fd3177d7d988348fc1bd8031daeea89396c9 (diff) |
[media] cxd2820r: dvbv5 statistics for DVB-T2
Implement dvbv5 statistics for DVB-T2.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/dvb-frontends/cxd2820r_t2.c | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/drivers/media/dvb-frontends/cxd2820r_t2.c b/drivers/media/dvb-frontends/cxd2820r_t2.c index 14c9a26502ed..e2875f2655bd 100644 --- a/drivers/media/dvb-frontends/cxd2820r_t2.c +++ b/drivers/media/dvb-frontends/cxd2820r_t2.c | |||
@@ -286,8 +286,10 @@ error: | |||
286 | int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status) | 286 | int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status) |
287 | { | 287 | { |
288 | struct cxd2820r_priv *priv = fe->demodulator_priv; | 288 | struct cxd2820r_priv *priv = fe->demodulator_priv; |
289 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
289 | int ret; | 290 | int ret; |
290 | u8 buf[1]; | 291 | unsigned int utmp; |
292 | u8 buf[4]; | ||
291 | *status = 0; | 293 | *status = 0; |
292 | 294 | ||
293 | ret = cxd2820r_rd_reg(priv, 0x02010 , &buf[0]); | 295 | 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 | 308 | ||
307 | dev_dbg(&priv->i2c->dev, "%s: lock=%02x\n", __func__, buf[0]); | 309 | dev_dbg(&priv->i2c->dev, "%s: lock=%02x\n", __func__, buf[0]); |
308 | 310 | ||
311 | /* Signal strength */ | ||
312 | if (*status & FE_HAS_SIGNAL) { | ||
313 | unsigned int strength; | ||
314 | |||
315 | ret = cxd2820r_rd_regs(priv, 0x02026, buf, 2); | ||
316 | if (ret) | ||
317 | goto error; | ||
318 | |||
319 | utmp = buf[0] << 8 | buf[1] << 0; | ||
320 | utmp = ~utmp & 0x0fff; | ||
321 | /* Scale value to 0x0000-0xffff */ | ||
322 | strength = utmp << 4 | utmp >> 8; | ||
323 | |||
324 | c->strength.len = 1; | ||
325 | c->strength.stat[0].scale = FE_SCALE_RELATIVE; | ||
326 | c->strength.stat[0].uvalue = strength; | ||
327 | } else { | ||
328 | c->strength.len = 1; | ||
329 | c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; | ||
330 | } | ||
331 | |||
332 | /* CNR */ | ||
333 | if (*status & FE_HAS_VITERBI) { | ||
334 | unsigned int cnr; | ||
335 | |||
336 | ret = cxd2820r_rd_regs(priv, 0x02028, buf, 2); | ||
337 | if (ret) | ||
338 | goto error; | ||
339 | |||
340 | utmp = buf[0] << 8 | buf[1] << 0; | ||
341 | utmp = utmp & 0x0fff; | ||
342 | #define CXD2820R_LOG10_8_24 15151336 /* log10(8) << 24 */ | ||
343 | if (utmp) | ||
344 | cnr = div_u64((u64)(intlog10(utmp) | ||
345 | - CXD2820R_LOG10_8_24) * 10000, | ||
346 | (1 << 24)); | ||
347 | else | ||
348 | cnr = 0; | ||
349 | |||
350 | c->cnr.len = 1; | ||
351 | c->cnr.stat[0].scale = FE_SCALE_DECIBEL; | ||
352 | c->cnr.stat[0].svalue = cnr; | ||
353 | } else { | ||
354 | c->cnr.len = 1; | ||
355 | c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; | ||
356 | } | ||
357 | |||
358 | /* BER */ | ||
359 | if (*status & FE_HAS_SYNC) { | ||
360 | unsigned int post_bit_error; | ||
361 | |||
362 | ret = cxd2820r_rd_regs(priv, 0x02039, buf, 4); | ||
363 | if (ret) | ||
364 | goto error; | ||
365 | |||
366 | if ((buf[0] >> 4) & 0x01) { | ||
367 | post_bit_error = buf[0] << 24 | buf[1] << 16 | | ||
368 | buf[2] << 8 | buf[3] << 0; | ||
369 | post_bit_error &= 0x0fffffff; | ||
370 | } else { | ||
371 | post_bit_error = 0; | ||
372 | } | ||
373 | |||
374 | priv->post_bit_error += post_bit_error; | ||
375 | |||
376 | c->post_bit_error.len = 1; | ||
377 | c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; | ||
378 | c->post_bit_error.stat[0].uvalue = priv->post_bit_error; | ||
379 | } else { | ||
380 | c->post_bit_error.len = 1; | ||
381 | c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; | ||
382 | } | ||
383 | |||
309 | return ret; | 384 | return ret; |
310 | error: | 385 | error: |
311 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); | 386 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |