summaryrefslogtreecommitdiff
path: root/drivers/media/dvb-frontends
diff options
context:
space:
mode:
authorMatthias Schwarzott <zzam@gentoo.org>2017-11-05 09:25:10 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-12 05:52:59 -0500
commite9c7d19a3894554c4ebb14513e4da6eb89b91a6a (patch)
treeaba49cb6e309ab8a4cdab35d30035d33888bd0be /drivers/media/dvb-frontends
parent2e687a6d3da813dea908e55bef325526ce644fea (diff)
media: si2165: Add DVBv3 wrapper for ber statistics
Add read_ber function that reads from property cache to support DVBv3. The implementation is inspired by the cx24120 driver. Signed-off-by: Matthias Schwarzott <zzam@gentoo.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r--drivers/media/dvb-frontends/si2165.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index ceb5a2bb0dea..2ad6409dd6b1 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -57,6 +57,9 @@ struct si2165_state {
u32 sys_clk;
u32 adc_clk;
+ /* DVBv3 stats */
+ u64 ber_prev;
+
bool has_dvbc;
bool has_dvbt;
bool firmware_loaded;
@@ -757,6 +760,12 @@ static int si2165_read_status(struct dvb_frontend *fe, enum fe_status *status)
c->post_bit_error.stat[0].uvalue = 0;
c->post_bit_count.stat[0].uvalue = 0;
+ /*
+ * reset DVBv3 value to deliver a good result
+ * for the first call
+ */
+ state->ber_prev = 0;
+
} else {
ret = si2165_readreg8(state, REG_BER_AVAIL, &u8tmp);
if (ret < 0)
@@ -805,6 +814,22 @@ static int si2165_read_snr(struct dvb_frontend *fe, u16 *snr)
return 0;
}
+static int si2165_read_ber(struct dvb_frontend *fe, u32 *ber)
+{
+ struct si2165_state *state = fe->demodulator_priv;
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
+ if (c->post_bit_error.stat[0].scale != FE_SCALE_COUNTER) {
+ *ber = 0;
+ return 0;
+ }
+
+ *ber = c->post_bit_error.stat[0].uvalue - state->ber_prev;
+ state->ber_prev = c->post_bit_error.stat[0].uvalue;
+
+ return 0;
+}
+
static int si2165_set_oversamp(struct si2165_state *state, u32 dvb_rate)
{
u64 oversamp;
@@ -1123,6 +1148,7 @@ static const struct dvb_frontend_ops si2165_ops = {
.set_frontend = si2165_set_frontend,
.read_status = si2165_read_status,
.read_snr = si2165_read_snr,
+ .read_ber = si2165_read_ber,
};
static int si2165_probe(struct i2c_client *client,