Root/package/system/hostap-driver/patches/001-fix-txpower.patch

1diff -Naur hostap-driver-0.3.7/driver/modules/hostap.c hostap-driver-0.3.7-patched/driver/modules/hostap.c
2--- hostap-driver-0.3.7/driver/modules/hostap.c 2004-08-28 06:26:46.000000000 +0300
3+++ hostap-driver-0.3.7-patched/driver/modules/hostap.c 2005-04-20 17:20:56.000000000 +0300
4@@ -1164,6 +1164,36 @@
5     return ret;
6 }
7 
8+/* BUG FIX: Restore power setting value when lost due to F/W bug */
9+
10+int hostap_restore_power(struct net_device *dev)
11+{
12+ struct hostap_interface *iface = dev->priv;
13+ local_info_t *local = iface->local;
14+
15+ u16 val;
16+ int ret = 0;
17+
18+ if (local->txpower_type == PRISM2_TXPOWER_OFF) {
19+ val = 0xff; /* use all standby and sleep modes */
20+ ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
21+ HFA386X_CR_A_D_TEST_MODES2,
22+ &val, NULL);
23+ }
24+
25+#ifdef RAW_TXPOWER_SETTING
26+ if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
27+ val = HFA384X_TEST_CFG_BIT_ALC;
28+ local->func->cmd(dev, HFA384X_CMDCODE_TEST |
29+ (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
30+ val = prism2_txpower_dBm_to_hfa386x(local->txpower);
31+ ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
32+ HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
33+ }
34+#endif /* RAW_TXPOWER_SETTING */
35+ return (ret ? -EOPNOTSUPP : 0);
36+}
37+
38 
39 struct proc_dir_entry *hostap_proc;
40 
41@@ -1214,6 +1244,7 @@
42 EXPORT_SYMBOL(hostap_set_hostapd_sta);
43 EXPORT_SYMBOL(hostap_add_interface);
44 EXPORT_SYMBOL(hostap_remove_interface);
45+EXPORT_SYMBOL(hostap_restore_power);
46 EXPORT_SYMBOL(prism2_update_comms_qual);
47 
48 module_init(hostap_init);
49diff -Naur hostap-driver-0.3.7/driver/modules/hostap.h hostap-driver-0.3.7-patched/driver/modules/hostap.h
50--- hostap-driver-0.3.7/driver/modules/hostap.h 2003-11-30 04:14:26.000000000 +0200
51+++ hostap-driver-0.3.7-patched/driver/modules/hostap.h 2005-04-20 17:21:23.000000000 +0300
52@@ -36,6 +36,7 @@
53                      const char *prefix, const char *name);
54 void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
55                  int remove_from_list);
56+int hostap_restore_power(struct net_device *dev);
57 int prism2_update_comms_qual(struct net_device *dev);
58 int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u8 stype,
59              u8 *body, size_t bodylen);
60diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ap.c hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c
61--- hostap-driver-0.3.7/driver/modules/hostap_ap.c 2005-01-24 04:52:00.000000000 +0200
62+++ hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c 2005-04-21 20:06:12.000000000 +0300
63@@ -2346,13 +2346,13 @@
64         addr[count].sa_family = ARPHRD_ETHER;
65         memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
66         if (sta->last_rx_silence == 0)
67- qual[count].qual = sta->last_rx_signal < 27 ?
68- 0 : (sta->last_rx_signal - 27) * 92 / 127;
69+ qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
70+ 0 : (sta->last_rx_signal - 156) * 92 / 64;
71         else
72- qual[count].qual = sta->last_rx_signal -
73- sta->last_rx_silence - 35;
74- qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
75- qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
76+ qual[count].qual = (sta->last_rx_signal -
77+ sta->last_rx_silence) * 92 / 64;
78+ qual[count].level = sta->last_rx_signal;
79+ qual[count].noise = sta->last_rx_silence;
80         qual[count].updated = sta->last_rx_updated;
81 
82         sta->last_rx_updated = 0;
83@@ -2413,13 +2413,13 @@
84         memset(&iwe, 0, sizeof(iwe));
85         iwe.cmd = IWEVQUAL;
86         if (sta->last_rx_silence == 0)
87- iwe.u.qual.qual = sta->last_rx_signal < 27 ?
88- 0 : (sta->last_rx_signal - 27) * 92 / 127;
89+ iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
90+ 0 : (sta->last_rx_signal - 156) * 92 / 64;
91         else
92- iwe.u.qual.qual = sta->last_rx_signal -
93- sta->last_rx_silence - 35;
94- iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
95- iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
96+ iwe.u.qual.qual = (sta->last_rx_signal -
97+ sta->last_rx_silence) * 92 / 64;
98+ iwe.u.qual.level = sta->last_rx_signal;
99+ iwe.u.qual.noise = sta->last_rx_silence;
100         iwe.u.qual.updated = sta->last_rx_updated;
101         iwe.len = IW_EV_QUAL_LEN;
102         current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
103diff -Naur hostap-driver-0.3.7/driver/modules/hostap_config.h hostap-driver-0.3.7-patched/driver/modules/hostap_config.h
104--- hostap-driver-0.3.7/driver/modules/hostap_config.h 2005-02-12 18:12:56.000000000 +0200
105+++ hostap-driver-0.3.7-patched/driver/modules/hostap_config.h 2005-04-20 17:25:23.000000000 +0300
106@@ -94,6 +94,12 @@
107  */
108 /* #define PRISM2_NO_STATION_MODES */
109 
110+/* Enable TX power Setting functions
111+ * (min att = -128 , max att = 127)
112+ */
113+
114+#define RAW_TXPOWER_SETTING
115+
116 /* Use Linux crypto API instead of own encryption implementation whenever
117  * possible. */
118 /* #define HOSTAP_USE_CRYPTO_API */
119diff -Naur hostap-driver-0.3.7/driver/modules/hostap_hw.c hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c
120--- hostap-driver-0.3.7/driver/modules/hostap_hw.c 2005-02-05 09:20:09.000000000 +0200
121+++ hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c 2005-04-20 17:25:55.000000000 +0300
122@@ -1039,6 +1039,7 @@
123                dev->name, local->fragm_threshold);
124     }
125 
126+ hostap_restore_power(dev);
127     return res;
128 }
129 
130diff -Naur hostap-driver-0.3.7/driver/modules/hostap_info.c hostap-driver-0.3.7-patched/driver/modules/hostap_info.c
131--- hostap-driver-0.3.7/driver/modules/hostap_info.c 2004-02-29 20:05:44.000000000 +0200
132+++ hostap-driver-0.3.7-patched/driver/modules/hostap_info.c 2005-04-20 17:26:36.000000000 +0300
133@@ -418,6 +418,11 @@
134     }
135 
136     /* Get BSSID if we have a valid AP address */
137+
138+ if ( val == HFA384X_LINKSTATUS_CONNECTED ||
139+ val == HFA384X_LINKSTATUS_DISCONNECTED )
140+ hostap_restore_power(local->dev);
141+
142     if (connected) {
143         netif_carrier_on(local->dev);
144         netif_carrier_on(local->ddev);
145diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ioctl.c hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c
146--- hostap-driver-0.3.7/driver/modules/hostap_ioctl.c 2004-11-22 08:03:05.000000000 +0200
147+++ hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c 2005-04-20 17:42:41.000000000 +0300
148@@ -1453,23 +1453,20 @@
149         val = 255;
150 
151     tmp = val;
152- tmp >>= 2;
153 
154- return -12 - tmp;
155+ return tmp;
156 }
157 
158 static u16 prism2_txpower_dBm_to_hfa386x(int val)
159 {
160     signed char tmp;
161 
162- if (val > 20)
163- return 128;
164- else if (val < -43)
165+ if (val > 127)
166         return 127;
167+ else if (val < -128)
168+ return 128;
169 
170     tmp = val;
171- tmp = -12 - tmp;
172- tmp <<= 2;
173 
174     return (unsigned char) tmp;
175 }
176

Archive Download this file



interactive