summaryrefslogtreecommitdiff
path: root/drivers/media/tuners/r820t.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2013-04-08 01:12:56 +0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-04-17 04:20:12 +0400
commitf8fde0e045aeac4417b09bef01b3ada74a4cbc80 (patch)
tree20421fa889615a116ad574585707b40733a63107 /drivers/media/tuners/r820t.c
parent6889ab2a25cf39a048edc69b4d61884b8b4da6b0 (diff)
downloadlinux-f8fde0e045aeac4417b09bef01b3ada74a4cbc80.tar.xz
[media] r820t: Give a better estimation of the signal strength
Instead of a binary signal strength measure, use the tuner gain to obtain a better estimation of the signal strength. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Tested-by: Antti Palosaari <crope@iki.fi>
Diffstat (limited to 'drivers/media/tuners/r820t.c')
-rw-r--r--drivers/media/tuners/r820t.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 7e02920f385a..ed9cd6569548 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1082,6 +1082,18 @@ static int r820t_set_tv_standard(struct r820t_priv *priv,
return 0;
}
+static int r820t_read_gain(struct r820t_priv *priv)
+{
+ u8 data[4];
+ int rc;
+
+ rc = r820_read(priv, 0x00, data, sizeof(data));
+ if (rc < 0)
+ return rc;
+
+ return ((data[3] & 0x0f) << 1) + ((data[3] & 0xf0) >> 4);
+}
+
static int generic_set_freq(struct dvb_frontend *fe,
u32 freq /* in HZ */,
unsigned bw,
@@ -1353,11 +1365,23 @@ static int r820t_set_params(struct dvb_frontend *fe)
static int r820t_signal(struct dvb_frontend *fe, u16 *strength)
{
struct r820t_priv *priv = fe->tuner_priv;
+ int rc = 0;
- if (priv->has_lock)
- *strength = 0xffff;
- else
+ if (priv->has_lock) {
+ rc = r820t_read_gain(priv);
+ if (rc < 0)
+ return rc;
+
+ /* A higher gain at LNA means a lower signal strength */
+ *strength = (45 - rc) << 4 | 0xff;
+ } else {
*strength = 0;
+ }
+
+ tuner_dbg("%s: %s, gain=%d strength=%d\n",
+ __func__,
+ priv->has_lock ? "PLL locked" : "no signal",
+ rc, *strength);
return 0;
}