diff mbox

[02/10] au8522: use the RF strentgh provided by the tuner

Message ID 314f7a0ded01b76e0c2ff3c1dc44c5cfd01ad445.1467240152.git.mchehab@s-opensource.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab June 29, 2016, 10:43 p.m. UTC
The usage of SNR to estimate the signal strength is a poor man's
approach. The best is to use the RF strength as measured by the
tuner. So, use it, if available.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/dvb-frontends/au8522_dig.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/dvb-frontends/au8522_dig.c b/drivers/media/dvb-frontends/au8522_dig.c
index e676b9461a59..ee14fd48c414 100644
--- a/drivers/media/dvb-frontends/au8522_dig.c
+++ b/drivers/media/dvb-frontends/au8522_dig.c
@@ -767,16 +767,30 @@  static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr)
 static int au8522_read_signal_strength(struct dvb_frontend *fe,
 				       u16 *signal_strength)
 {
-	/* borrowed from lgdt330x.c
+	u16 snr;
+	u32 tmp;
+	int ret;
+
+	/* If the tuner has RF strength, use it */
+	if (fe->ops.tuner_ops.get_rf_strength) {
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 1);
+		ret = fe->ops.tuner_ops.get_rf_strength(fe, signal_strength);
+		if (fe->ops.i2c_gate_ctrl)
+			fe->ops.i2c_gate_ctrl(fe, 0);
+		return ret;
+	}
+
+	/*
+	 * If it doen't, estimate from SNR
+	 * (borrowed from lgdt330x.c)
 	 *
 	 * Calculate strength from SNR up to 35dB
 	 * Even though the SNR can go higher than 35dB,
 	 * there is some comfort factor in having a range of
 	 * strong signals that can show at 100%
 	 */
-	u16 snr;
-	u32 tmp;
-	int ret = au8522_read_snr(fe, &snr);
+	ret = au8522_read_snr(fe, &snr);
 
 	*signal_strength = 0;