diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-07 17:12:56 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-16 20:20:12 -0400 |
commit | f8fde0e045aeac4417b09bef01b3ada74a4cbc80 (patch) | |
tree | 20421fa889615a116ad574585707b40733a63107 /drivers/media/tuners | |
parent | 6889ab2a25cf39a048edc69b4d61884b8b4da6b0 (diff) |
[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')
-rw-r--r-- | drivers/media/tuners/r820t.c | 30 |
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, | |||
1082 | return 0; | 1082 | return 0; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | static int r820t_read_gain(struct r820t_priv *priv) | ||
1086 | { | ||
1087 | u8 data[4]; | ||
1088 | int rc; | ||
1089 | |||
1090 | rc = r820_read(priv, 0x00, data, sizeof(data)); | ||
1091 | if (rc < 0) | ||
1092 | return rc; | ||
1093 | |||
1094 | return ((data[3] & 0x0f) << 1) + ((data[3] & 0xf0) >> 4); | ||
1095 | } | ||
1096 | |||
1085 | static int generic_set_freq(struct dvb_frontend *fe, | 1097 | static int generic_set_freq(struct dvb_frontend *fe, |
1086 | u32 freq /* in HZ */, | 1098 | u32 freq /* in HZ */, |
1087 | unsigned bw, | 1099 | unsigned bw, |
@@ -1353,11 +1365,23 @@ static int r820t_set_params(struct dvb_frontend *fe) | |||
1353 | static int r820t_signal(struct dvb_frontend *fe, u16 *strength) | 1365 | static int r820t_signal(struct dvb_frontend *fe, u16 *strength) |
1354 | { | 1366 | { |
1355 | struct r820t_priv *priv = fe->tuner_priv; | 1367 | struct r820t_priv *priv = fe->tuner_priv; |
1368 | int rc = 0; | ||
1356 | 1369 | ||
1357 | if (priv->has_lock) | 1370 | if (priv->has_lock) { |
1358 | *strength = 0xffff; | 1371 | rc = r820t_read_gain(priv); |
1359 | else | 1372 | if (rc < 0) |
1373 | return rc; | ||
1374 | |||
1375 | /* A higher gain at LNA means a lower signal strength */ | ||
1376 | *strength = (45 - rc) << 4 | 0xff; | ||
1377 | } else { | ||
1360 | *strength = 0; | 1378 | *strength = 0; |
1379 | } | ||
1380 | |||
1381 | tuner_dbg("%s: %s, gain=%d strength=%d\n", | ||
1382 | __func__, | ||
1383 | priv->has_lock ? "PLL locked" : "no signal", | ||
1384 | rc, *strength); | ||
1361 | 1385 | ||
1362 | return 0; | 1386 | return 0; |
1363 | } | 1387 | } |