summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/frontends/dib3000mb.c
diff options
context:
space:
mode:
authorPatrick Boettcher <devnull@localhost>2004-09-28 19:39:06 +0000
committerPatrick Boettcher <devnull@localhost>2004-09-28 19:39:06 +0000
commitd8b8880215760f30390a9797537f75dbefd4a556 (patch)
treec1ffc8fcb377455ac6fffe441d5e17faf8d9c8a6 /linux/drivers/media/dvb/frontends/dib3000mb.c
parent00da2badce9a5354c4315b2805e62fb1f77edf63 (diff)
downloadmediapointer-dvb-s2-d8b8880215760f30390a9797537f75dbefd4a556.tar.gz
mediapointer-dvb-s2-d8b8880215760f30390a9797537f75dbefd4a556.tar.bz2
- signal strength and snr calculations code included, but not activate. log10 is missing
Diffstat (limited to 'linux/drivers/media/dvb/frontends/dib3000mb.c')
-rw-r--r--linux/drivers/media/dvb/frontends/dib3000mb.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/linux/drivers/media/dvb/frontends/dib3000mb.c b/linux/drivers/media/dvb/frontends/dib3000mb.c
index e93123e1b..1af977839 100644
--- a/linux/drivers/media/dvb/frontends/dib3000mb.c
+++ b/linux/drivers/media/dvb/frontends/dib3000mb.c
@@ -17,6 +17,8 @@
* Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
* sources, on which this driver (and the dvb-dibusb) are based.
*
+ * $Id $Id: dib3000mb.c,v 1.8 2004/09/28 19:39:06 pmp Exp $$
+ *
* see Documentation/dvb/README.dibusb for more information
*
*/
@@ -569,8 +571,8 @@ static int dib3000mb_set_frontend(struct dib3000mb_state *state,
wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_OFF);
while ((search_state = dib3000mb_fe_read_search_status(state)) < 0);
-
- return search_state ? 0 : -EINVAL;
+ deb_info("search_state after autosearch %d\n",search_state);
+ return search_state ? 0 : -EINVAL;
} else {
wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_CTRL);
wr(DIB3000MB_REG_RESTART,DIB3000MB_RESTART_OFF);
@@ -697,26 +699,66 @@ static int dib3000mb_read_ber(struct dib3000mb_state *state,u32 *ber)
((rd(DIB3000MB_REG_BER_MSB) << 16) | rd(DIB3000MB_REG_BER_LSB) );
return 0;
}
+/*
+ * Amaury:
+ * signal strength is measured with dBm (power compared to mW)
+ * the standard range is -90dBm(low power) to -10 dBm (strong power),
+ * but the calibration is done for -100 dBm to 0dBm
+ */
+#define DIB3000MB_AGC_REF_dBm -14
+#define DIB3000MB_GAIN_SLOPE_dBm 100
+#define DIB3000MB_GAIN_DELTA_dBm -2
static int dib3000mb_read_signal_strength(struct dib3000mb_state *state, u16 *strength)
{
- *strength = rd(DIB3000MB_REG_SIGNAL_POWER);
+/* TODO log10
+ u16 sigpow = rd(DIB3000MB_REG_SIGNAL_POWER),
+ n_agc_power = rd(DIB3000MB_REG_AGC_POWER),
+ rf_power = rd(DIB3000MB_REG_RF_POWER);
+ double rf_power_dBm, ad_power_dBm, minar_power_dBm;
+
+ if (n_agc_power == 0 )
+ n_agc_power = 1 ;
+
+ ad_power_dBm = 10 * log10 ( (float)n_agc_power / (float)(1<<16) );
+ minor_power_dBm = ad_power_dBm - DIB3000MB_AGC_REF_dBm;
+ rf_power_dBm = (-DIB3000MB_GAIN_SLOPE_dBm * (float)rf_power / (float)(1<<16) +
+ DIB3000MB_GAIN_DELTA_dBm) + minor_power_dBm;
+ // relative rf_power
+ *strength = (u16) ((rf_power_dBm + 100) / 100 * 0xffff);
+*/
+ *strength = rd(DIB3000MB_REG_SIGNAL_POWER) * 0xffff / 0x170;
return 0;
}
+/*
+ * Amaury:
+ * snr is the signal quality measured in dB.
+ * snr = 10*log10(signal power / noise power)
+ * the best quality is near 35dB (cable transmission & good modulator)
+ * the minimum without errors depend of transmission parameters
+ * some indicative values are given in en300744 Annex A
+ * ex : 16QAM 2/3 (Gaussian) = 11.1 dB
+ *
+ * If SNR is above 20dB, BER should be always 0.
+ * choose 0dB as the minimum
+ */
static int dib3000mb_read_snr(struct dib3000mb_state *state,u16 *snr)
{
short sigpow = rd(DIB3000MB_REG_SIGNAL_POWER);
int icipow = ((rd(DIB3000MB_REG_NOISE_POWER_MSB) & 0xff) << 16) |
rd(DIB3000MB_REG_NOISE_POWER_LSB);
+/*
+ float snr_dBm=0;
+
+ if (sigpow > 0 && icipow > 0)
+ snr_dBm = 10.0 * log10( (float) (sigpow<<8) / (float)icipow ) ;
+ else if (sigpow > 0)
+ snr_dBm = 35;
- deb_info("sigpow: %d, icipow: %d\n",sigpow,icipow);
-
- if (sigpow > 0 && icipow > 0) {
- *snr = (sigpow << 8 / icipow);
- } else
- snr = 0;
-
+ *snr = (u16) ((snr_dBm / 35) * 0xffff);
+*/
+ *snr = (sigpow<<8) / (icipow > 0 ? icipow : 1);
return 0;
}