Commit 90acb85f authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] tuner-xc2028: Fix signal strength report

There are several bugs at the signal strength algorithm:

	- It is using logical OR, instead of bit OR;
	- It doesn't wait up to 18 ms as it should;
	- the strength range is not ok.

Rework on it, in order to make it work.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 030755bd
...@@ -903,7 +903,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) ...@@ -903,7 +903,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
{ {
struct xc2028_data *priv = fe->tuner_priv; struct xc2028_data *priv = fe->tuner_priv;
u16 frq_lock, signal = 0; u16 frq_lock, signal = 0;
int rc; int rc, i;
tuner_dbg("%s called\n", __func__); tuner_dbg("%s called\n", __func__);
...@@ -914,21 +914,28 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) ...@@ -914,21 +914,28 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
/* Sync Lock Indicator */ /* Sync Lock Indicator */
rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock); for (i = 0; i < 3; i++) {
if (rc < 0) rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock);
goto ret; if (rc < 0)
goto ret;
/* Frequency is locked */ if (frq_lock)
if (frq_lock == 1) break;
signal = 1 << 11; msleep(6);
}
/* Frequency was not locked */
if (frq_lock == 2)
goto ret;
/* Get SNR of the video signal */ /* Get SNR of the video signal */
rc = xc2028_get_reg(priv, XREG_SNR, &signal); rc = xc2028_get_reg(priv, XREG_SNR, &signal);
if (rc < 0) if (rc < 0)
goto ret; goto ret;
/* Use both frq_lock and signal to generate the result */ /* Signal level is 3 bits only */
signal = signal || ((signal & 0x07) << 12);
signal = ((1 << 12) - 1) | ((signal & 0x07) << 12);
ret: ret:
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
......
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