X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4c2cba9ccb6f754aac9378e2fc2c7b546e6d589c..7e94237a4e4ee40e1dff230d1760dcaaba3d90e8:/lib/dvb/frontend.cpp diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 27ea66ec..b25794f8 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -695,6 +695,12 @@ void eDVBFrontend::timeout() #define INRANGE(X,Y,Z) (((X<=Y) && (Y<=Z))||((Z<=Y) && (Y<=X)) ? 1 : 0) +/* unsigned 32 bit division */ +static inline uint32_t fe_udiv(uint32_t a, uint32_t b) +{ + return (a + b / 2) / b; +} + int eDVBFrontend::readFrontendData(int type) { switch(type) @@ -728,7 +734,7 @@ int eDVBFrontend::readFrontendData(int type) eDebug("FE_READ_SNR failed (%m)"); if (!strcmp(m_description, "BCM4501 (internal)")) { - unsigned int SDS_SNRE = snr << 16; + float SDS_SNRE = snr << 16; float snr_in_db; if (parm_u_qpsk_fec_inner <= FEC_AUTO) // DVB-S1 / QPSK @@ -748,7 +754,7 @@ int eDVBFrontend::readFrontendData(int type) if (fval1 < 10.0) { fval2 = SNR_COEFF[0]; - for (int i=0; i<6; ++i) + for (int i=1; i<6; ++i) { fval2 *= fval1; fval2 += SNR_COEFF[i]; @@ -781,7 +787,7 @@ int eDVBFrontend::readFrontendData(int type) snr_in_db = fval1; } #endif - return (int)(snr_in_db * 100.0); + return (int)(snr_in_db * 100); } else if (strstr(m_description, "Alps BSBE1 C01A") || !strcmp(m_description, "Alps -S(STV0288)")) @@ -831,12 +837,30 @@ int eDVBFrontend::readFrontendData(int type) !strcmp(m_description, "Philips -S") || !strcmp(m_description, "LG -S") ) { - float snr_in_db=(snr-39075)/1764.7; - return (int)(snr_in_db * 100.0); + return (int)((snr-39075)/17.647); } else if (!strcmp(m_description, "Alps BSBE2")) { - return (int)((snr >> 7) * 10.0); - } /* else + return (int)((snr >> 7) * 10); + } else if (!strcmp(m_description, "Philips CU1216Mk3")) + { + int mse = (~snr) & 0xFF; + switch (parm_u_qam_modulation) { + case QAM_16: return fe_udiv(1950000, (32 * mse) + 138) + 1000; + case QAM_32: return fe_udiv(2150000, (40 * mse) + 500) + 1350; + case QAM_64: return fe_udiv(2100000, (40 * mse) + 500) + 1250; + case QAM_128: return fe_udiv(1850000, (38 * mse) + 400) + 1380; + case QAM_256: return fe_udiv(1800000, (100 * mse) + 40) + 2030; + default: break; + } + return 0; + } else if (!strcmp(m_description, "Philips TU1216")) + { + snr = 0xFF - (snr & 0xFF); + if (snr != 0) + return 10 * (int)(-100 * (log10(snr) - log10(255))); + return 0; + } +/* else eDebug("no SNR dB calculation for frontendtype %s yet", m_description); */ return 0x12345678; } @@ -1014,22 +1038,19 @@ void fillDictWithSatelliteData(ePyObject dict, const FRONTENDPARAMETERS &parm, e break; } PutToDict(dict, "rolloff", tmp); - if (parm_u_qpsk_fec_inner > FEC_S2_QPSK_9_10) + switch(parm_inversion & 0x30) { - switch(parm_inversion & 0x30) - { - case 0: // pilot off - tmp = "PILOT_OFF"; - break; - case 0x10: // pilot on - tmp = "PILOT_ON"; - break; - case 0x20: // pilot auto - tmp = "PILOT_AUTO"; - break; - } - PutToDict(dict, "pilot", tmp); + case 0: // pilot off + tmp = "PILOT_OFF"; + break; + case 0x10: // pilot on + tmp = "PILOT_ON"; + break; + case 0x20: // pilot auto + tmp = "PILOT_AUTO"; + break; } + PutToDict(dict, "pilot", tmp); tmp = "DVB-S2"; } else @@ -1310,7 +1331,7 @@ void eDVBFrontend::getTransponderData(ePyObject dest, bool original) { const FRONTENDPARAMETERS &parm = original || m_simulate ? this->parm : front; const char *tmp = "INVERSION_AUTO"; - switch(parm_inversion) + switch(parm_inversion & 3) { case INVERSION_ON: tmp = "INVERSION_ON"; @@ -1916,10 +1937,10 @@ RESULT eDVBFrontend::prepare_sat(const eDVBFrontendParametersSatellite &feparm, return -EINVAL; } parm_inversion |= (feparm.rolloff << 2); // Hack.. we use bit 2..3 of inversion param for rolloff + parm_inversion |= (feparm.pilot << 4); // Hack.. we use bit 4..5 of inversion param for pilot if (feparm.modulation == eDVBFrontendParametersSatellite::Modulation::M8PSK) { parm_u_qpsk_fec_inner = (fe_code_rate_t)((int)parm_u_qpsk_fec_inner+9); // 8PSK fec driver values are decimal 9 bigger - parm_inversion |= (feparm.pilot << 4); // Hack.. we use bit 4..5 of inversion param for pilot } } #endif