File dvb-femon-02-SNR-in-dB.patch of Package dvb

From: Jean Delvare <khali@linux-fr.org>
Subject: femon: Display SNR in dB
Patch-mainline: Submitted, no answer -- http://www.spinics.net/lists/linux-media/msg64369.html

SNR is supposed to be reported by the frontend drivers in dB, so print
it that way for drivers which implement it properly.
---
 util/femon/femon.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

--- dvb-apps-3ee111da5b3a.orig/util/femon/femon.c	2013-06-02 14:05:00.988323437 +0200
+++ dvb-apps-3ee111da5b3a/util/femon/femon.c	2013-06-02 14:05:33.560792474 +0200
@@ -102,11 +102,20 @@ int check_frontend (struct dvbfe_handle
 			fe_info.lock ? 'L' : ' ');
 
 		if (human_readable) {
-			printf ("signal %3u%% | snr %3u%% | ber %d | unc %d | ",
-				(fe_info.signal_strength * 100) / 0xffff,
-				(fe_info.snr * 100) / 0xffff,
-				fe_info.ber,
-				fe_info.ucblocks);
+			// SNR should be in units of 0.1 dB but some drivers do
+			// not follow that rule, thus this heuristic.
+			if (fe_info.snr < 1000)
+				printf ("signal %3u%% | snr %4.1fdB | ber %d | unc %d | ",
+					(fe_info.signal_strength * 100) / 0xffff,
+					fe_info.snr / 10.,
+					fe_info.ber,
+					fe_info.ucblocks);
+			else
+				printf ("signal %3u%% | snr %3u%% | ber %d | unc %d | ",
+					(fe_info.signal_strength * 100) / 0xffff,
+					(fe_info.snr * 100) / 0xffff,
+					fe_info.ber,
+					fe_info.ucblocks);
 		} else {
 			printf ("signal %04x | snr %04x | ber %08x | unc %08x | ",
 				fe_info.signal_strength,
openSUSE Build Service is sponsored by