aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/au8522_dig.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2011-10-31 08:11:00 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-07 13:19:13 -0200
commit5279b1ff3699153a53d7ca030b5fb95950001c36 (patch)
treecc56ed39e76abc728b117dc46d8a464ef5037e70 /drivers/media/dvb/frontends/au8522_dig.c
parent[media] drivers/media/video/davinci/vpbe_display.c: eliminate a null pointer dereference (diff)
downloadlinux-dev-5279b1ff3699153a53d7ca030b5fb95950001c36.tar.xz
linux-dev-5279b1ff3699153a53d7ca030b5fb95950001c36.zip
[media] au8522: Calculate signal strength shown as percentage from SNR up to 35dB
As done first in lgdt330x.c, calculate signal 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% Signed-off-by: Michael Krufky <mkrufky@kernellabs.com> Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/frontends/au8522_dig.c')
-rw-r--r--drivers/media/dvb/frontends/au8522_dig.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/media/dvb/frontends/au8522_dig.c b/drivers/media/dvb/frontends/au8522_dig.c
index 1d572940e243..5c0d3989f5bd 100644
--- a/drivers/media/dvb/frontends/au8522_dig.c
+++ b/drivers/media/dvb/frontends/au8522_dig.c
@@ -862,7 +862,36 @@ static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr)
static int au8522_read_signal_strength(struct dvb_frontend *fe,
u16 *signal_strength)
{
- return au8522_read_snr(fe, signal_strength);
+ /* 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);
+
+ *signal_strength = 0;
+
+ if (0 == ret) {
+ /* The following calculation method was chosen
+ * purely for the sake of code re-use from the
+ * other demod drivers that use this method */
+
+ /* Convert from SNR in dB * 10 to 8.24 fixed-point */
+ tmp = (snr * ((1 << 24) / 10));
+
+ /* Convert from 8.24 fixed-point to
+ * scale the range 0 - 35*2^24 into 0 - 65535*/
+ if (tmp >= 8960 * 0x10000)
+ *signal_strength = 0xffff;
+ else
+ *signal_strength = tmp / 8960;
+ }
+
+ return ret;
}
static int au8522_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)