From owner-freebsd-current@FreeBSD.ORG Tue Sep 30 05:55:21 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 07CB416A4B3 for ; Tue, 30 Sep 2003 05:55:21 -0700 (PDT) Received: from s1.vhost.cz (s1.vhost.cz [195.39.16.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 69E9643FE1 for ; Tue, 30 Sep 2003 05:55:19 -0700 (PDT) (envelope-from konfer@mikulas.com) Received: (qmail 7721 invoked by uid 89); 30 Sep 2003 14:55:17 +0200 Received: from unknown (HELO mikulas.com) (jiri@mikulas.com@195.122.204.155) by s1.vhost.cz with AES256-SHA encrypted SMTP; 30 Sep 2003 14:55:17 +0200 Message-ID: <3F797CE3.7060506@mikulas.com> Date: Tue, 30 Sep 2003 14:53:55 +0200 From: Jiri Mikulas User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; cs-CZ; rv:1.4) Gecko/20030710 X-Accept-Language: cs MIME-Version: 1.0 To: freebsd-current@freebsd.org Content-Type: multipart/mixed; boundary="------------040908030209040104050607" Subject: wicontrol TX patch X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2003 12:55:21 -0000 This is a multi-part message in MIME format. --------------040908030209040104050607 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Hello My questoin is about status of wicontrol TX power control in current ? Anybody planing to commit it into wicontrol ? I use modified patch from "imp" for three months it works well, but problem is, that if card is reseted by wi_reset - i guess, value from register is owerwrited by default (I think ALC also turns on) any ideas/solutions how keep this TX power value after card reset ? for this time I use cron to periodicaly refresh TX power .. sorry for my english ;) thaks for reply Jiri --------------040908030209040104050607 Content-Type: text/plain; name="wicontrol-1.37-TX.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="wicontrol-1.37-TX.diff" --- usr.sbin/wicontrol/wicontrol.c Tue Sep 30 00:55:25 2003 +++ usr.sbin/wicontrol/wicontrol.c Tue Sep 30 12:54:26 2003 @@ -1070,6 +1070,135 @@ opt); } +/* TX Power patch */ +static void +wi_setdebug(const char *iface, struct wi_req *wreq) +{ + struct ifreq ifr; + int s; + + bzero((char *)&ifr, sizeof(ifr)); + + strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); + ifr.ifr_data = (caddr_t)wreq; + + s = socket(AF_INET, SOCK_DGRAM, 0); + + if (s == -1) + err(1, "socket"); + + if (ioctl(s, SIOCSPRISM2DEBUG, &ifr) == -1) + err(1, "SIOCSPRISM2DEBUG"); + + close(s); + + return; +} + +#if 0 +static void +wi_getdebug(const char *iface, struct wi_req *wreq) +{ + struct ifreq ifr; + int s; + + bzero((char *)&ifr, sizeof(ifr)); + + strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); + ifr.ifr_data = (caddr_t)wreq; + + s = socket(AF_INET, SOCK_DGRAM, 0); + + if (s == -1) + err(1, "socket"); + + if (ioctl(s, SIOCGPRISM2DEBUG, &ifr) == -1) + err(1, "SIOCGPRISM2DEBUG"); + + close(s); + + return; +} +#endif + +/* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping.. + * This version assumes following mapping: + * CR31 is 7-bit value with -64 to 63 range. + * -64 is mapped into 20dBm and 63 into -43dBm. + * This is certainly not an exact mapping for every card, but at least + * increasing dBm value should correspond to increasing TX power. + */ + +static int +wi_txpower_to_dBm(uint16_t val) +{ + signed char tmp; + + if (val > 255) + val = 255; + + tmp = val; + tmp >>= 2; + + return -12 - tmp; +} + +#if 0 +static uint16_t +wi_dBm_to_txpower(int val) +{ + signed char tmp; + + if (val > 20) + return 128; + else if (val < -43) + return 127; + + tmp = val; + tmp = -12 - tmp; + tmp <<= 2; + + return (unsigned char) tmp; +} +#endif + +static void +wi_readpower(const char *iface) +{ + struct wi_req wreq; + + printf("reading power\n"); + + wreq.wi_type = WI_RID_MIF; + wreq.wi_val[0] = WI_HFA386X_CR_MANUAL_TX_POWER; + wreq.wi_len = 1 + 1; + + wi_getval(iface, &wreq); + printf("Value returned was 0x%x or %d dBm\n", wreq.wi_val[0], + wi_txpower_to_dBm(wreq.wi_val[0])); +} + +static void +wi_writepower(const char *iface, int power) +{ + struct wi_req wreq; + + wreq.wi_type = WI_RID_MIF; + wreq.wi_val[0] = WI_HFA386X_CR_MANUAL_TX_POWER; + wreq.wi_val[1] = power; + wreq.wi_len = 1 + 1 + 1; + wi_setval(iface, &wreq); + + wreq.wi_type = WI_DEBUG_CONFBITS; + wreq.wi_val[0] = 0; + wreq.wi_val[1] = 0x8; + wreq.wi_len = 1 + 1 + 1; + wi_setdebug(iface, &wreq); + +} + +/* TX Power patch end */ + int main(int argc, char *argv[]) { @@ -1097,8 +1226,20 @@ opterr = 1; while((ch = getopt(argc, argv, - "a:c:d:e:f:hi:k:lm:n:op:q:r:s:t:v:CF:LP:QS:T:Z")) != -1) { + /* Patched ARGS for tx power (AB added) */ + /* old: "a:c:d:e:f:hi:k:lm:n:op:q:r:s:t:v:CF:LP:QS:T:Z")) != -1) { */ + "a:c:d:e:f:hi:k:lm:n:op:q:r:s:t:v:AB:CF:LP:QS:T:Z")) != -1) { switch(ch) { + /* TX Power patch */ + case 'A': + wi_readpower(iface); + exit(0); + break; + case 'B': + wi_writepower(iface, atoi(optarg)); + exit(0); + break; + /* TX Power patch end */ case 'Z': #ifdef WICACHE wi_zerocache(iface); --------------040908030209040104050607--