All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] xc5000: add support to return RF strength
@ 2016-06-29 22:43 Mauro Carvalho Chehab
  2016-06-29 22:43 ` [PATCH 02/10] au8522: use the RF strentgh provided by the tuner Mauro Carvalho Chehab
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Mauro Carvalho Chehab @ 2016-06-29 22:43 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab

The xc5000 tuner is able to return the gain used to adjust the
signal level. With that, it can return an estimation of the
signal strength. So, add support for it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
 drivers/media/tuners/xc5000.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index e6e5e90d8d95..91ad392eb60c 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -569,6 +569,26 @@ static int xc_get_totalgain(struct xc5000_priv *priv, u16 *totalgain)
 	return xc5000_readreg(priv, XREG_TOTALGAIN, totalgain);
 }
 
+static int xc5000_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
+{
+	struct xc5000_priv *priv = fe->tuner_priv;
+	int ret;
+	u16 gain = 0;
+
+	*strength = 0;
+
+	ret = xc_get_totalgain(priv, &gain);
+	if (ret < 0)
+		return ret;
+
+	*strength = 65535 - gain;
+
+	dprintk(1, "Signal strength = 0x%04x (gain = 0x%04x)\n",
+		*strength, gain);
+
+	return 0;
+}
+
 static u16 wait_for_lock(struct xc5000_priv *priv)
 {
 	u16 lock_state = 0;
@@ -706,9 +726,10 @@ static void xc_debug_dump(struct xc5000_priv *priv)
 	xc_get_analogsnr(priv,  &snr);
 	dprintk(1, "*** Unweighted analog SNR = %d dB\n", snr & 0x3f);
 
+	// With au0828, signal strength is given by (aprox) = 30-gain dBm
 	xc_get_totalgain(priv,  &totalgain);
-	dprintk(1, "*** Total gain = %d.%d dB\n", totalgain / 256,
-		(totalgain % 256) * 100 / 256);
+	dprintk(1, "*** Total gain = %d.%d dB (0x%04x)\n", totalgain / 256,
+		(totalgain % 256) * 100 / 256, totalgain);
 
 	if (priv->pll_register_no) {
 		xc5000_readreg(priv, priv->pll_register_no, &regval);
@@ -1390,7 +1411,8 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
 	.get_frequency	   = xc5000_get_frequency,
 	.get_if_frequency  = xc5000_get_if_frequency,
 	.get_bandwidth	   = xc5000_get_bandwidth,
-	.get_status	   = xc5000_get_status
+	.get_status	   = xc5000_get_status,
+	.get_rf_strength   = xc5000_get_rf_strength
 };
 
 struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-06-30 15:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 22:43 [PATCH 01/10] xc5000: add support to return RF strength Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 02/10] au8522: use the RF strentgh provided by the tuner Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 03/10] au8522: add support for dvbv5 statistics API Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 04/10] au8522: reorder functions to avoid a forward declaration Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 05/10] au8522: remove au8522_read_ber() ops Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 06/10] au8522: show signal strength in dBm, for devices with xc5000 Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 07/10] lgdt3306a: Expose SNR via dvbv5 stats Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 08/10] dvb_frontend: create a new ops to help returning signals in dB Mauro Carvalho Chehab
2016-06-30 13:48   ` Steven Toth
2016-06-30 15:01     ` Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 09/10] au8522/xc5000: use the new get_rf_attenuation() ops Mauro Carvalho Chehab
2016-06-29 22:43 ` [PATCH 10/10] lgdt3306a: better handle RF fake strength Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.