diff --git a/frontends/cxd2843.c b/frontends/cxd2843.c index 7ec11ee..d7014e7 100644 --- a/frontends/cxd2843.c +++ b/frontends/cxd2843.c @@ -35,8 +35,11 @@ #include #include "dvb_frontend.h" +#include "dvb_math.h" #include "cxd2843.h" +#define Log10x100(x) ((s32)(((((u64) intlog2(x) * 0x1e1a5e2e) >> 47 ) + 1) >> 1)) + #define USE_ALGO 1 enum demod_type { CXD2843, CXD2837, CXD2838 }; @@ -1504,52 +1507,6 @@ static int read_signal_strength(struct dvb_frontend *fe, u16 *strength) return 0; } -static s32 Log10x100(u32 x) -{ - static u32 LookupTable[100] = { - 101157945, 103514217, 105925373, 108392691, 110917482, - 113501082, 116144861, 118850223, 121618600, 124451461, - 127350308, 130316678, 133352143, 136458314, 139636836, - 142889396, 146217717, 149623566, 153108746, 156675107, - 160324539, 164058977, 167880402, 171790839, 175792361, - 179887092, 184077200, 188364909, 192752491, 197242274, - 201836636, 206538016, 211348904, 216271852, 221309471, - 226464431, 231739465, 237137371, 242661010, 248313311, - 254097271, 260015956, 266072506, 272270131, 278612117, - 285101827, 291742701, 298538262, 305492111, 312607937, - 319889511, 327340695, 334965439, 342767787, 350751874, - 358921935, 367282300, 375837404, 384591782, 393550075, - 402717034, 412097519, 421696503, 431519077, 441570447, - 451855944, 462381021, 473151259, 484172368, 495450191, - 506990708, 518800039, 530884444, 543250331, 555904257, - 568852931, 582103218, 595662144, 609536897, 623734835, - 638263486, 653130553, 668343918, 683911647, 699841996, - 716143410, 732824533, 749894209, 767361489, 785235635, - 803526122, 822242650, 841395142, 860993752, 881048873, - 901571138, 922571427, 944060876, 966050879, 988553095, - }; - s32 y; - int i; - - if (x == 0) - return 0; - y = 800; - if (x >= 1000000000) { - x /= 10; - y += 100; - } - - while (x < 100000000) { - x *= 10; - y -= 100; - } - i = 0; - while (i < 100 && x > LookupTable[i]) - i += 1; - y += i; - return y; -} - #if 0 static void GetPLPIds(struct cxd_state *state, u32 nValues, u8 *Values, u32 *Returned)