Commit c2730eef authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] cinergyT2-fe: cache stats at cinergyt2_fe_read_status()

Instead of sending USB commands for every stats call, collect
them once, when status is updated. As the frontend kthread
will call it on every few seconds, the stats will still be
collected.

Besides reducing the amount of USB/I2C transfers, this also
warrants that all stats will be collected at the same time,
and makes easier to convert it to DVBv5 stats in the future.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 54d577a4
...@@ -139,6 +139,7 @@ static uint16_t compute_tps(struct dtv_frontend_properties *op) ...@@ -139,6 +139,7 @@ static uint16_t compute_tps(struct dtv_frontend_properties *op)
struct cinergyt2_fe_state { struct cinergyt2_fe_state {
struct dvb_frontend fe; struct dvb_frontend fe;
struct dvb_usb_device *d; struct dvb_usb_device *d;
struct dvbt_get_status_msg status;
}; };
static int cinergyt2_fe_read_status(struct dvb_frontend *fe, static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
...@@ -154,6 +155,8 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe, ...@@ -154,6 +155,8 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
if (ret < 0) if (ret < 0)
return ret; return ret;
state->status = result;
*status = 0; *status = 0;
if (0xffff - le16_to_cpu(result.gain) > 30) if (0xffff - le16_to_cpu(result.gain) > 30)
...@@ -177,34 +180,16 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe, ...@@ -177,34 +180,16 @@ static int cinergyt2_fe_read_status(struct dvb_frontend *fe,
static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber) static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
{ {
struct cinergyt2_fe_state *state = fe->demodulator_priv; struct cinergyt2_fe_state *state = fe->demodulator_priv;
struct dvbt_get_status_msg status;
char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
int ret;
ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status,
sizeof(status), 0);
if (ret < 0)
return ret;
*ber = le32_to_cpu(status.viterbi_error_rate); *ber = le32_to_cpu(state->status.viterbi_error_rate);
return 0; return 0;
} }
static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc) static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc)
{ {
struct cinergyt2_fe_state *state = fe->demodulator_priv; struct cinergyt2_fe_state *state = fe->demodulator_priv;
struct dvbt_get_status_msg status;
u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
int ret;
ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status, *unc = le32_to_cpu(state->status.uncorrected_block_count);
sizeof(status), 0);
if (ret < 0) {
err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n",
ret);
return ret;
}
*unc = le32_to_cpu(status.uncorrected_block_count);
return 0; return 0;
} }
...@@ -212,35 +197,16 @@ static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe, ...@@ -212,35 +197,16 @@ static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe,
u16 *strength) u16 *strength)
{ {
struct cinergyt2_fe_state *state = fe->demodulator_priv; struct cinergyt2_fe_state *state = fe->demodulator_priv;
struct dvbt_get_status_msg status;
char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
int ret;
ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, *strength = (0xffff - le16_to_cpu(state->status.gain));
sizeof(status), 0);
if (ret < 0) {
err("cinergyt2_fe_read_signal_strength() Failed!"
" (Error=%d)\n", ret);
return ret;
}
*strength = (0xffff - le16_to_cpu(status.gain));
return 0; return 0;
} }
static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr) static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
{ {
struct cinergyt2_fe_state *state = fe->demodulator_priv; struct cinergyt2_fe_state *state = fe->demodulator_priv;
struct dvbt_get_status_msg status;
char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS };
int ret;
ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, *snr = (state->status.snr << 8) | state->status.snr;
sizeof(status), 0);
if (ret < 0) {
err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret);
return ret;
}
*snr = (status.snr << 8) | status.snr;
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