+ case signalQualitydB: /* this will move into the driver */
+ {
+ uint16_t snr=0;
+ if (ioctl(m_fd, FE_READ_SNR, &snr) < 0 && errno != ERANGE)
+ eDebug("FE_READ_SNR failed (%m)");
+ if (!strcmp(m_description, "BCM4501 (internal)"))
+ {
+ unsigned int SDS_SNRE = snr << 16;
+
+ static float SNR_COEFF[6] = {
+ 100.0 / 4194304.0,
+ -7136.0 / 4194304.0,
+ 197418.0 / 4194304.0,
+ -2602183.0 / 4194304.0,
+ 20377212.0 / 4194304.0,
+ -37791203.0 / 4194304.0,
+ };
+
+ float fval1, fval2, snr_in_db;
+ int i;
+ fval1 = 12.44714 - (2.0 * log10(SDS_SNRE / 256.0));
+ fval2 = pow(10.0, fval1)-1;
+ fval1 = 10.0 * log10(fval2);
+
+ if (fval1 < 10.0)
+ {
+ fval2 = SNR_COEFF[0];
+ for (i=0; i<6; ++i)
+ {
+ fval2 *= fval1;
+ fval2 += SNR_COEFF[i];
+ }
+ fval1 = fval2;
+ }
+ snr_in_db = fval1;
+
+ return (int)(snr_in_db * 100.0);
+ }
+ else if (strstr(m_description, "Alps BSBE1 C01A") ||
+ !strcmp(m_description, "Alps -S(STV0288)"))
+ {
+ if (snr == 0)
+ return 0;
+ else if (snr == 0xFFFF) // i think this should not happen
+ return 100*100;
+ else
+ {
+ enum { REALVAL, REGVAL };
+ const long CN_lookup[31][2] = {
+ {20,8900}, {25,8680}, {30,8420}, {35,8217}, {40,7897},
+ {50,7333}, {60,6747}, {70,6162}, {80,5580}, {90,5029},
+ {100,4529}, {110,4080}, {120,3685}, {130,3316}, {140,2982},
+ {150,2688}, {160,2418}, {170,2188}, {180,1982}, {190,1802},
+ {200,1663}, {210,1520}, {220,1400}, {230,1295}, {240,1201},
+ {250,1123}, {260,1058}, {270,1004}, {280,957}, {290,920},
+ {300,890}
+ };
+ int add=strchr(m_description, '.') ? 0xA250 : 0xA100;
+ long regval = 0xFFFF - ((snr / 3) + add), // revert some dvb api calulations to get the real register value
+ Imin=0,
+ Imax=30,
+ i;
+ if(INRANGE(CN_lookup[Imin][REGVAL],regval,CN_lookup[Imax][REGVAL]))
+ {
+ long val;
+ while((Imax-Imin)>1)
+ {
+ i=(Imax+Imin)/2;
+ if(INRANGE(CN_lookup[Imin][REGVAL],regval,CN_lookup[i][REGVAL]))
+ Imax = i;
+ else
+ Imin = i;
+ }
+ return (((regval - CN_lookup[Imin][REGVAL])
+ * (CN_lookup[Imax][REALVAL] - CN_lookup[Imin][REALVAL])
+ / (CN_lookup[Imax][REGVAL] - CN_lookup[Imin][REGVAL]))
+ + CN_lookup[Imin][REALVAL]) * 10;
+ }
+ return 100;
+ }
+ return 0;
+ }
+ else if (!strcmp(m_description, "Alps BSBE1 702A") || // some frontends with STV0299
+ !strcmp(m_description, "Alps -S") ||
+ !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);
+ } else if (!strcmp(m_description, "Alps BSBE2"))
+ {
+ return (int)((snr >> 7) * 10.0);
+ } /* else
+ eDebug("no SNR dB calculation for frontendtype %s yet", m_description); */
+ return 0x12345678;
+ }
+ case signalPower: