From a584947a2dfe3fdc9ad078488e736e91abb9eecd Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 23 Aug 2006 23:17:15 +0000 Subject: [PATCH] don't convert mw to qdbm for wl0_txpwr, set the value as-is SVN-Revision: 4647 --- openwrt/package/wificonf/wificonf.c | 63 +---------------------------- 1 file changed, 1 insertion(+), 62 deletions(-) diff --git a/openwrt/package/wificonf/wificonf.c b/openwrt/package/wificonf/wificonf.c index 335dbfc3d1..401e9049fd 100644 --- a/openwrt/package/wificonf/wificonf.c +++ b/openwrt/package/wificonf/wificonf.c @@ -104,65 +104,6 @@ static int nvram_disabled(char *name) return (nvram_match(name, "0") || nvram_match(name, "off") || nvram_match(name, "disabled") || nvram_match(name, "false") || nvram_match(name, "no") ? 1 : 0); } - -/* Quarter dBm units to mW - * Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153 - * Table is offset so the last entry is largest mW value that fits in - * a uint16. - */ - -#define QDBM_OFFSET 153 -#define QDBM_TABLE_LEN 40 - -/* Smallest mW value that will round up to the first table entry, QDBM_OFFSET. - * Value is ( mW(QDBM_OFFSET - 1) + mW(QDBM_OFFSET) ) / 2 - */ -#define QDBM_TABLE_LOW_BOUND 6493 - -/* Largest mW value that will round down to the last table entry, - * QDBM_OFFSET + QDBM_TABLE_LEN-1. - * Value is ( mW(QDBM_OFFSET + QDBM_TABLE_LEN - 1) + mW(QDBM_OFFSET + QDBM_TABLE_LEN) ) / 2. - */ -#define QDBM_TABLE_HIGH_BOUND 64938 - -static const uint16 nqdBm_to_mW_map[QDBM_TABLE_LEN] = { -/* qdBm: +0 +1 +2 +3 +4 +5 +6 +7 */ -/* 153: */ 6683, 7079, 7499, 7943, 8414, 8913, 9441, 10000, -/* 161: */ 10593, 11220, 11885, 12589, 13335, 14125, 14962, 15849, -/* 169: */ 16788, 17783, 18836, 19953, 21135, 22387, 23714, 25119, -/* 177: */ 26607, 28184, 29854, 31623, 33497, 35481, 37584, 39811, -/* 185: */ 42170, 44668, 47315, 50119, 53088, 56234, 59566, 63096 -}; - -unsigned char mw_to_qdbm(uint16 mw) -{ - char qdbm; - int offset; - uint mw_uint = mw; - uint boundary; - - /* handle boundary case */ - if (mw_uint <= 1) - return 0; - - offset = QDBM_OFFSET; - - /* move mw into the range of the table */ - while (mw_uint < QDBM_TABLE_LOW_BOUND) { - mw_uint *= 10; - offset -= 40; - } - - for (qdbm = 0; qdbm < QDBM_TABLE_LEN-1; qdbm++) { - boundary = nqdBm_to_mW_map[qdbm] + (nqdBm_to_mW_map[qdbm+1] - nqdBm_to_mW_map[qdbm])/2; - if (mw_uint < boundary) break; - } - - qdbm += (unsigned char)offset; - - return(qdbm); -} - static int bcom_ioctl(int skfd, char *ifname, int cmd, void *buf, int len) { struct ifreq ifr; @@ -397,10 +338,8 @@ static void setup_bcom(int skfd, char *ifname) if (val <= 0) val = strtol(nvram_safe_get("pa0maxpwr"),NULL,0); - if (val) { - val = mw_to_qdbm(val); + if (val) bcom_set_int(skfd, ifname, "qtxpower", val); - } /* Set other options */ val = nvram_enabled(wl_var("lazywds")); -- 2.30.2