Commit 8393c003 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] si2168: implement ber statistics

Implement DVBv5 BER.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent e5360224
...@@ -85,7 +85,8 @@ static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status) ...@@ -85,7 +85,8 @@ static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status)
struct i2c_client *client = fe->demodulator_priv; struct i2c_client *client = fe->demodulator_priv;
struct si2168_dev *dev = i2c_get_clientdata(client); struct si2168_dev *dev = i2c_get_clientdata(client);
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret; int ret, i;
unsigned int utmp, utmp1, utmp2;
struct si2168_cmd cmd; struct si2168_cmd cmd;
*status = 0; *status = 0;
...@@ -144,6 +145,39 @@ static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status) ...@@ -144,6 +145,39 @@ static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status)
dev_dbg(&client->dev, "status=%02x args=%*ph\n", dev_dbg(&client->dev, "status=%02x args=%*ph\n",
*status, cmd.rlen, cmd.args); *status, cmd.rlen, cmd.args);
/* BER */
if (*status & FE_HAS_VITERBI) {
memcpy(cmd.args, "\x82\x00", 2);
cmd.wlen = 2;
cmd.rlen = 3;
ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
/*
* Firmware returns [0, 255] mantissa and [0, 8] exponent.
* Convert to DVB API: mantissa * 10^(8 - exponent) / 10^8
*/
utmp = clamp(8 - cmd.args[1], 0, 8);
for (i = 0, utmp1 = 1; i < utmp; i++)
utmp1 = utmp1 * 10;
utmp1 = cmd.args[2] * utmp1;
utmp2 = 100000000; /* 10^8 */
dev_dbg(&client->dev,
"post_bit_error=%u post_bit_count=%u ber=%u*10^-%u\n",
utmp1, utmp2, cmd.args[2], cmd.args[1]);
c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
c->post_bit_error.stat[0].uvalue += utmp1;
c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
c->post_bit_count.stat[0].uvalue += utmp2;
} else {
c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
return 0; return 0;
err: err:
dev_dbg(&client->dev, "failed=%d\n", ret); dev_dbg(&client->dev, "failed=%d\n", ret);
...@@ -355,6 +389,7 @@ static int si2168_init(struct dvb_frontend *fe) ...@@ -355,6 +389,7 @@ static int si2168_init(struct dvb_frontend *fe)
{ {
struct i2c_client *client = fe->demodulator_priv; struct i2c_client *client = fe->demodulator_priv;
struct si2168_dev *dev = i2c_get_clientdata(client); struct si2168_dev *dev = i2c_get_clientdata(client);
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret, len, remaining; int ret, len, remaining;
const struct firmware *fw; const struct firmware *fw;
struct si2168_cmd cmd; struct si2168_cmd cmd;
...@@ -493,10 +528,17 @@ static int si2168_init(struct dvb_frontend *fe) ...@@ -493,10 +528,17 @@ static int si2168_init(struct dvb_frontend *fe)
dev->warm = true; dev->warm = true;
warm: warm:
/* Init stats here to indicate which stats are supported */
c->cnr.len = 1;
c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_error.len = 1;
c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_count.len = 1;
c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
dev->active = true; dev->active = true;
return 0; return 0;
err_release_firmware: err_release_firmware:
release_firmware(fw); release_firmware(fw);
err: err:
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "dvb_frontend.h" #include "dvb_frontend.h"
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/i2c-mux.h> #include <linux/i2c-mux.h>
#include <linux/kernel.h>
#define SI2168_A20_FIRMWARE "dvb-demod-si2168-a20-01.fw" #define SI2168_A20_FIRMWARE "dvb-demod-si2168-a20-01.fw"
#define SI2168_A30_FIRMWARE "dvb-demod-si2168-a30-01.fw" #define SI2168_A30_FIRMWARE "dvb-demod-si2168-a30-01.fw"
......
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