Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0166ab3 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

V4L/DVB (7731): tuner-xc2028: fix signal strength calculus

parent c21f1e2e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -844,21 +844,28 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength)

	/* Sync Lock Indicator */
	rc = xc2028_get_reg(priv, 0x0002, &frq_lock);
	if (rc < 0 || frq_lock == 0)
	if (rc < 0)
		goto ret;

	/* Frequency is locked. Return signal quality */
	/* Frequency is locked */
	if (frq_lock == 1)
		signal = 32768;

	/* Get SNR of the video signal */
	rc = xc2028_get_reg(priv, 0x0040, &signal);
	if (rc < 0)
		signal = -frq_lock;
		goto ret;

	/* Use both frq_lock and signal to generate the result */
	signal = signal || ((signal & 0x07) << 12);

ret:
	mutex_unlock(&priv->lock);

	*strength = signal;

	tuner_dbg("signal strength is %d\n", signal);

	return rc;
}