aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2011-10-31 07:12:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-07 10:20:17 -0500
commitead32d5357e4aae732ccd7427073ab4bf30d3068 (patch)
tree7607112de5d1b690751442b2d3cf5aebcb5f324a
parent19661c08fe11590e04832ed8b3cabe5e4bf11e48 (diff)
[media] s5h1411: 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>
-rw-r--r--drivers/media/dvb/frontends/s5h1411.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/drivers/media/dvb/frontends/s5h1411.c b/drivers/media/dvb/frontends/s5h1411.c
index d8adf1e32019..5fca113a2013 100644
--- a/drivers/media/dvb/frontends/s5h1411.c
+++ b/drivers/media/dvb/frontends/s5h1411.c
@@ -794,7 +794,36 @@ static int s5h1411_read_snr(struct dvb_frontend *fe, u16 *snr)
794static int s5h1411_read_signal_strength(struct dvb_frontend *fe, 794static int s5h1411_read_signal_strength(struct dvb_frontend *fe,
795 u16 *signal_strength) 795 u16 *signal_strength)
796{ 796{
797 return s5h1411_read_snr(fe, signal_strength); 797 /* borrowed from lgdt330x.c
798 *
799 * Calculate strength from SNR up to 35dB
800 * Even though the SNR can go higher than 35dB,
801 * there is some comfort factor in having a range of
802 * strong signals that can show at 100%
803 */
804 u16 snr;
805 u32 tmp;
806 int ret = s5h1411_read_snr(fe, &snr);
807
808 *signal_strength = 0;
809
810 if (0 == ret) {
811 /* The following calculation method was chosen
812 * purely for the sake of code re-use from the
813 * other demod drivers that use this method */
814
815 /* Convert from SNR in dB * 10 to 8.24 fixed-point */
816 tmp = (snr * ((1 << 24) / 10));
817
818 /* Convert from 8.24 fixed-point to
819 * scale the range 0 - 35*2^24 into 0 - 65535*/
820 if (tmp >= 8960 * 0x10000)
821 *signal_strength = 0xffff;
822 else
823 *signal_strength = tmp / 8960;
824 }
825
826 return ret;
798} 827}
799 828
800static int s5h1411_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 829static int s5h1411_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)