Commit 80e9710b authored by Jemma Denson's avatar Jemma Denson Committed by Mauro Carvalho Chehab

[media] cx24120: Convert ucblocks to dvbv5 stats

DVBv3 is a legacy API. Drivers should use DVBv5, in order to support
modern applications. So, implement UCB using dvbv5.
Signed-off-by: default avatarJemma Denson <jdenson@gmail.com>
Signed-off-by: default avatarPatrick Boettcher <patrick.boettcher@posteo.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent fc443284
...@@ -151,9 +151,12 @@ struct cx24120_state { ...@@ -151,9 +151,12 @@ struct cx24120_state {
fe_status_t fe_status; fe_status_t fe_status;
/* ber stats calulations */ /* ber stats calulations */
u32 bitrate;
u32 berw_usecs; u32 berw_usecs;
u32 ber_prev; u32 ber_prev;
u32 per_prev;
unsigned long ber_jiffies_stats; unsigned long ber_jiffies_stats;
unsigned long per_jiffies_stats;
}; };
/* Command message to firmware */ /* Command message to firmware */
...@@ -612,7 +615,7 @@ static void cx24120_get_stats(struct cx24120_state *state) ...@@ -612,7 +615,7 @@ static void cx24120_get_stats(struct cx24120_state *state)
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct cx24120_cmd cmd; struct cx24120_cmd cmd;
int ret, cnr, msecs; int ret, cnr, msecs;
u16 sig; u16 sig, ucb;
u32 ber; u32 ber;
dev_dbg(&state->i2c->dev, "\n"); dev_dbg(&state->i2c->dev, "\n");
...@@ -678,7 +681,20 @@ static void cx24120_get_stats(struct cx24120_state *state) ...@@ -678,7 +681,20 @@ static void cx24120_get_stats(struct cx24120_state *state)
c->post_bit_count.stat[0].uvalue += CX24120_BER_WSIZE; c->post_bit_count.stat[0].uvalue += CX24120_BER_WSIZE;
} }
/* FIXME: add UCB */ /* UCB */
if (time_after(jiffies, state->per_jiffies_stats)) {
state->per_jiffies_stats = jiffies + msecs_to_jiffies(1000);
ucb = cx24120_readreg(state, CX24120_REG_UCB_H) << 8;
ucb |= cx24120_readreg(state, CX24120_REG_UCB_L);
dev_dbg(&state->i2c->dev, "ucblocks = %d\n", ucb);
c->block_error.stat[0].scale = FE_SCALE_COUNTER;
c->block_error.stat[0].uvalue += ucb;
c->block_count.stat[0].scale = FE_SCALE_COUNTER;
c->block_count.stat[0].uvalue += state->bitrate / 8 / 208;
}
} }
static void cx24120_set_clock_ratios(struct dvb_frontend *fe); static void cx24120_set_clock_ratios(struct dvb_frontend *fe);
...@@ -813,22 +829,23 @@ void cx24120_calculate_ber_window(struct cx24120_state *state, u32 rate) ...@@ -813,22 +829,23 @@ void cx24120_calculate_ber_window(struct cx24120_state *state, u32 rate)
{ {
struct dvb_frontend *fe = &state->frontend; struct dvb_frontend *fe = &state->frontend;
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
u64 bitrate, tmp; u64 tmp;
/* /*
* Calculate bitrate from rate in the clock ratios table. * Calculate bitrate from rate in the clock ratios table.
* This isn't *exactly* right but close enough. * This isn't *exactly* right but close enough.
*/ */
bitrate = (u64)c->symbol_rate * rate; tmp = (u64)c->symbol_rate * rate;
do_div(bitrate, 256); do_div(tmp, 256);
state->bitrate = tmp;
/* usecs per ber window */ /* usecs per ber window */
tmp = 1000000ULL * CX24120_BER_WSIZE; tmp = 1000000ULL * CX24120_BER_WSIZE;
do_div(tmp, bitrate); do_div(tmp, state->bitrate);
state->berw_usecs = tmp; state->berw_usecs = tmp;
dev_dbg(&state->i2c->dev, "bitrate: %llu, berw_usecs: %u\n", dev_dbg(&state->i2c->dev, "bitrate: %u, berw_usecs: %u\n",
bitrate, state->berw_usecs); state->bitrate, state->berw_usecs);
} }
/* /*
...@@ -1432,6 +1449,11 @@ static int cx24120_init(struct dvb_frontend *fe) ...@@ -1432,6 +1449,11 @@ static int cx24120_init(struct dvb_frontend *fe)
c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->post_bit_count.len = 1; c->post_bit_count.len = 1;
c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->block_error.len = 1;
c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
c->block_count.len = 1;
c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
state->cold_init = 1; state->cold_init = 1;
return 0; return 0;
...@@ -1503,11 +1525,16 @@ static void cx24120_release(struct dvb_frontend *fe) ...@@ -1503,11 +1525,16 @@ static void cx24120_release(struct dvb_frontend *fe)
static int cx24120_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) static int cx24120_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{ {
struct cx24120_state *state = fe->demodulator_priv; struct cx24120_state *state = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
if (c->block_error.stat[0].scale != FE_SCALE_COUNTER) {
*ucblocks = 0;
return 0;
}
*ucblocks = (cx24120_readreg(state, CX24120_REG_UCB_H) << 8) | *ucblocks = c->block_error.stat[0].uvalue - state->per_prev;
cx24120_readreg(state, CX24120_REG_UCB_L); state->per_prev = c->block_error.stat[0].uvalue;
dev_dbg(&state->i2c->dev, "ucblocks = %d\n", *ucblocks);
return 0; return 0;
} }
......
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