You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.6 KiB
93 lines
2.6 KiB
5 years ago
|
From 0d3b277d19137c4a0fdadfd1381f1c66515d1b0c Mon Sep 17 00:00:00 2001
|
||
|
From: Athanasios Oikonomou <athoik@gmail.com>
|
||
|
Date: Mon, 8 Feb 2016 22:14:31 +0200
|
||
|
Subject: [PATCH] STV: Add SNR/Signal report parameters
|
||
|
|
||
|
|
||
|
diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c
|
||
|
index 264c4b8..12fd3d0 100644
|
||
|
--- a/drivers/media/dvb-frontends/stv090x.c
|
||
|
+++ b/drivers/media/dvb-frontends/stv090x.c
|
||
|
@@ -41,6 +41,18 @@
|
||
|
static unsigned int verbose;
|
||
|
module_param(verbose, int, 0644);
|
||
|
|
||
|
+/* define how SNR measurement is reported */
|
||
|
+static int esno;
|
||
|
+module_param(esno, int, 0644);
|
||
|
+MODULE_PARM_DESC(esno, "SNR is reported in 0:Percentage, "\
|
||
|
+ "1:(EsNo dB)*10 (default:0)");
|
||
|
+
|
||
|
+/* define how signal measurement is reported */
|
||
|
+static int dbm;
|
||
|
+module_param(dbm, int, 0644);
|
||
|
+MODULE_PARM_DESC(dbm, "Signal is reported in 0:Percentage, "\
|
||
|
+ "1:-1*dBm (default:0)");
|
||
|
+
|
||
|
/* internal params node */
|
||
|
struct stv090x_dev {
|
||
|
/* pointer for internal params, one for each pair of demods */
|
||
|
@@ -3693,7 +3705,10 @@ static int stv090x_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
|
||
|
str = 0;
|
||
|
else if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read)
|
||
|
str = -100;
|
||
|
- *strength = (str + 100) * 0xFFFF / 100;
|
||
|
+ if (dbm)
|
||
|
+ *strength = -str;
|
||
|
+ else
|
||
|
+ *strength = (str + 100) * 0xFFFF / 100;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
@@ -3704,8 +3719,7 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr)
|
||
|
u32 reg_0, reg_1, reg, i;
|
||
|
s32 val_0, val_1, val = 0;
|
||
|
u8 lock_f;
|
||
|
- s32 div;
|
||
|
- u32 last;
|
||
|
+ s32 snr;
|
||
|
|
||
|
switch (state->delsys) {
|
||
|
case STV090x_DVBS2:
|
||
|
@@ -3722,10 +3736,14 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr)
|
||
|
msleep(1);
|
||
|
}
|
||
|
val /= 16;
|
||
|
- last = ARRAY_SIZE(stv090x_s2cn_tab) - 1;
|
||
|
- div = stv090x_s2cn_tab[0].read -
|
||
|
- stv090x_s2cn_tab[last].read;
|
||
|
- *cnr = 0xFFFF - ((val * 0xFFFF) / div);
|
||
|
+ snr = stv090x_table_lookup(stv090x_s2cn_tab,
|
||
|
+ ARRAY_SIZE(stv090x_s2cn_tab) - 1, val);
|
||
|
+ if (snr < 0) snr = 0;
|
||
|
+ if (snr > 200) snr = 200;
|
||
|
+ if (esno)
|
||
|
+ *cnr = snr;
|
||
|
+ else
|
||
|
+ *cnr = snr * 0xFFFF / 200;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
@@ -3744,10 +3762,14 @@ static int stv090x_read_cnr(struct dvb_frontend *fe, u16 *cnr)
|
||
|
msleep(1);
|
||
|
}
|
||
|
val /= 16;
|
||
|
- last = ARRAY_SIZE(stv090x_s1cn_tab) - 1;
|
||
|
- div = stv090x_s1cn_tab[0].read -
|
||
|
- stv090x_s1cn_tab[last].read;
|
||
|
- *cnr = 0xFFFF - ((val * 0xFFFF) / div);
|
||
|
+ snr = stv090x_table_lookup(stv090x_s1cn_tab,
|
||
|
+ ARRAY_SIZE(stv090x_s1cn_tab) - 1, val);
|
||
|
+ if (snr < 0) snr = 0;
|
||
|
+ if (snr > 200) snr = 200;
|
||
|
+ if (esno)
|
||
|
+ *cnr = snr;
|
||
|
+ else
|
||
|
+ *cnr = snr * 0xFFFF / 200;
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
--
|
||
|
2.1.4
|
||
|
|