Commit 7903fbe3 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

media: af9013: change lock detection slightly

Whilst rewritten largely, the basic logic remains same with one
exception: do not return immediately on success case. We are going to
add statistics that function and cannot return too early.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 35ecf2b4
...@@ -752,45 +752,44 @@ static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status) ...@@ -752,45 +752,44 @@ static int af9013_read_status(struct dvb_frontend *fe, enum fe_status *status)
struct af9013_state *state = fe->demodulator_priv; struct af9013_state *state = fe->demodulator_priv;
struct i2c_client *client = state->client; struct i2c_client *client = state->client;
int ret; int ret;
unsigned int utmp; unsigned int utmp, utmp1;
/* /*
* Return status from the cache if it is younger than 2000ms with the * Return status from the cache if it is younger than 2000ms with the
* exception of last tune is done during 4000ms. * exception of last tune is done during 4000ms.
*/ */
if (time_is_after_jiffies( if (time_is_after_jiffies(state->read_status_jiffies + msecs_to_jiffies(2000)) &&
state->read_status_jiffies + msecs_to_jiffies(2000)) && time_is_before_jiffies(state->set_frontend_jiffies + msecs_to_jiffies(4000))) {
time_is_before_jiffies( *status = state->fe_status;
state->set_frontend_jiffies + msecs_to_jiffies(4000))
) {
*status = state->fe_status;
return 0;
} else { } else {
*status = 0; /* MPEG2 lock */
} ret = regmap_read(state->regmap, 0xd507, &utmp);
if (ret)
goto err;
/* MPEG2 lock */ if ((utmp >> 6) & 0x01) {
ret = regmap_read(state->regmap, 0xd507, &utmp); utmp1 = FE_HAS_SIGNAL | FE_HAS_CARRIER |
if (ret) FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
goto err; } else {
/* TPS lock */
ret = regmap_read(state->regmap, 0xd330, &utmp);
if (ret)
goto err;
if ((utmp >> 6) & 0x01) if ((utmp >> 3) & 0x01)
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | utmp1 = FE_HAS_SIGNAL | FE_HAS_CARRIER |
FE_HAS_SYNC | FE_HAS_LOCK; FE_HAS_VITERBI;
else
utmp1 = 0;
}
if (!*status) { dev_dbg(&client->dev, "fe_status %02x\n", utmp1);
/* TPS lock */
ret = regmap_read(state->regmap, 0xd330, &utmp);
if (ret)
goto err;
if ((utmp >> 3) & 0x01) state->read_status_jiffies = jiffies;
*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
FE_HAS_VITERBI;
}
state->fe_status = *status; state->fe_status = utmp1;
state->read_status_jiffies = jiffies; *status = utmp1;
}
return 0; return 0;
err: err:
......
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