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

media: vidtv: get rid of the work queue

The dvb_frontend will already call status periodically, when
a channel is tuned. So, no need to have a work queue for
such purpose.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 3e51a496
...@@ -190,26 +190,21 @@ static void vidtv_demod_update_stats(struct dvb_frontend *fe) ...@@ -190,26 +190,21 @@ static void vidtv_demod_update_stats(struct dvb_frontend *fe)
} }
static void vidtv_demod_poll_snr_handler(struct work_struct *work) static int vidtv_demod_read_status(struct dvb_frontend *fe,
enum fe_status *status)
{ {
/* struct vidtv_demod_state *state = fe->demodulator_priv;
* periodically check the signal quality and eventually
* lose the TS lock if it dips too low
*/
struct vidtv_demod_state *state;
const struct vidtv_demod_cnr_to_qual_s *cnr2qual = NULL; const struct vidtv_demod_cnr_to_qual_s *cnr2qual = NULL;
struct vidtv_demod_config *config; struct vidtv_demod_config *config = &state->config;
u16 snr = 0; u16 snr = 0;
state = container_of(work, struct vidtv_demod_state, poll_snr.work);
config = &state->config;
/* Simulate random lost of signal due to a bad-tuned channel */ /* Simulate random lost of signal due to a bad-tuned channel */
cnr2qual = vidtv_match_cnr_s(&state->frontend); cnr2qual = vidtv_match_cnr_s(&state->frontend);
if (cnr2qual && state->tuner_cnr < cnr2qual->cnr_good && if (cnr2qual && state->tuner_cnr < cnr2qual->cnr_good &&
state->frontend.ops.tuner_ops.get_rf_strength) { state->frontend.ops.tuner_ops.get_rf_strength) {
state->frontend.ops.tuner_ops.get_rf_strength(&state->frontend, &snr); state->frontend.ops.tuner_ops.get_rf_strength(&state->frontend,
&snr);
if (snr < cnr2qual->cnr_ok) { if (snr < cnr2qual->cnr_ok) {
/* eventually lose the TS lock */ /* eventually lose the TS lock */
...@@ -229,15 +224,6 @@ static void vidtv_demod_poll_snr_handler(struct work_struct *work) ...@@ -229,15 +224,6 @@ static void vidtv_demod_poll_snr_handler(struct work_struct *work)
vidtv_demod_update_stats(&state->frontend); vidtv_demod_update_stats(&state->frontend);
schedule_delayed_work(&state->poll_snr,
msecs_to_jiffies(POLL_THRD_TIME));
}
static int vidtv_demod_read_status(struct dvb_frontend *fe,
enum fe_status *status)
{
struct vidtv_demod_state *state = fe->demodulator_priv;
*status = state->status; *status = state->status;
return 0; return 0;
...@@ -296,55 +282,12 @@ static int vidtv_demod_set_frontend(struct dvb_frontend *fe) ...@@ -296,55 +282,12 @@ static int vidtv_demod_set_frontend(struct dvb_frontend *fe)
vidtv_demod_update_stats(fe); vidtv_demod_update_stats(fe);
if (state->tuner_cnr > 0) {
schedule_delayed_work(&state->poll_snr,
msecs_to_jiffies(POLL_THRD_TIME));
state->poll_snr_thread_running = true;
}
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0); fe->ops.i2c_gate_ctrl(fe, 0);
return 0; return 0;
} }
static int vidtv_demod_sleep(struct dvb_frontend *fe)
{
struct vidtv_demod_state *state = fe->demodulator_priv;
if (state->poll_snr_thread_running) {
cancel_delayed_work_sync(&state->poll_snr);
state->poll_snr_thread_running = false;
state->poll_snr_thread_restart = true;
}
return 0;
}
static int vidtv_demod_init(struct dvb_frontend *fe)
{
struct vidtv_demod_state *state = fe->demodulator_priv;
u32 tuner_status = 0;
/*
* At resume, start the snr poll thread only if it was suspended with
* the thread running. Extra care should be taken here, as some tuner
* status change might happen at resume time (for example, due to an
* ioctl syscall to set_frontend, or due to a release syscall).
*/
fe->ops.tuner_ops.get_status(fe, &tuner_status);
if (tuner_status == TUNER_STATUS_LOCKED &&
state->poll_snr_thread_restart) {
schedule_delayed_work(&state->poll_snr,
msecs_to_jiffies(POLL_THRD_TIME));
state->poll_snr_thread_restart = false;
}
return 0;
}
/* /*
* NOTE: * NOTE:
* This is implemented here just to be used as an example for real * This is implemented here just to be used as an example for real
...@@ -375,9 +318,6 @@ static void vidtv_demod_release(struct dvb_frontend *fe) ...@@ -375,9 +318,6 @@ static void vidtv_demod_release(struct dvb_frontend *fe)
{ {
struct vidtv_demod_state *state = fe->demodulator_priv; struct vidtv_demod_state *state = fe->demodulator_priv;
if (state->poll_snr_thread_running)
cancel_delayed_work_sync(&state->poll_snr);
kfree(state); kfree(state);
} }
...@@ -423,9 +363,6 @@ static const struct dvb_frontend_ops vidtv_demod_ops = { ...@@ -423,9 +363,6 @@ static const struct dvb_frontend_ops vidtv_demod_ops = {
.release = vidtv_demod_release, .release = vidtv_demod_release,
.init = vidtv_demod_init,
.sleep = vidtv_demod_sleep,
.set_frontend = vidtv_demod_set_frontend, .set_frontend = vidtv_demod_set_frontend,
.get_frontend = vidtv_demod_get_frontend, .get_frontend = vidtv_demod_get_frontend,
...@@ -461,8 +398,6 @@ static int vidtv_demod_i2c_probe(struct i2c_client *client, ...@@ -461,8 +398,6 @@ static int vidtv_demod_i2c_probe(struct i2c_client *client,
memcpy(&state->config, config, sizeof(state->config)); memcpy(&state->config, config, sizeof(state->config));
INIT_DELAYED_WORK(&state->poll_snr, &vidtv_demod_poll_snr_handler);
state->frontend.demodulator_priv = state; state->frontend.demodulator_priv = state;
i2c_set_clientdata(client, state); i2c_set_clientdata(client, state);
......
...@@ -63,10 +63,7 @@ struct vidtv_demod_config { ...@@ -63,10 +63,7 @@ struct vidtv_demod_config {
struct vidtv_demod_state { struct vidtv_demod_state {
struct dvb_frontend frontend; struct dvb_frontend frontend;
struct vidtv_demod_config config; struct vidtv_demod_config config;
struct delayed_work poll_snr;
enum fe_status status; enum fe_status status;
u16 tuner_cnr; u16 tuner_cnr;
bool poll_snr_thread_running;
bool poll_snr_thread_restart;
}; };
#endif // VIDTV_DEMOD_H #endif // VIDTV_DEMOD_H
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