[adm5120] add button devices to several boards
[openwrt.git] / target / linux / generic-2.6 / patches / 903-hostap_txpower.patch
1 Index: linux-2.6.21.7/drivers/net/wireless/hostap/hostap_ap.c
2 ===================================================================
3 --- linux-2.6.21.7.orig/drivers/net/wireless/hostap/hostap_ap.c
4 +++ linux-2.6.21.7/drivers/net/wireless/hostap/hostap_ap.c
5 @@ -2346,13 +2346,13 @@ int prism2_ap_get_sta_qual(local_info_t
6 addr[count].sa_family = ARPHRD_ETHER;
7 memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
8 if (sta->last_rx_silence == 0)
9 - qual[count].qual = sta->last_rx_signal < 27 ?
10 - 0 : (sta->last_rx_signal - 27) * 92 / 127;
11 + qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
12 + 0 : (sta->last_rx_signal - 156) * 92 / 64;
13 else
14 - qual[count].qual = sta->last_rx_signal -
15 - sta->last_rx_silence - 35;
16 - qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
17 - qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
18 + qual[count].qual = (sta->last_rx_signal -
19 + sta->last_rx_silence) * 92 / 64;
20 + qual[count].level = sta->last_rx_signal;
21 + qual[count].noise = sta->last_rx_silence;
22 qual[count].updated = sta->last_rx_updated;
23
24 sta->last_rx_updated = IW_QUAL_DBM;
25 @@ -2417,13 +2417,13 @@ int prism2_ap_translate_scan(struct net_
26 memset(&iwe, 0, sizeof(iwe));
27 iwe.cmd = IWEVQUAL;
28 if (sta->last_rx_silence == 0)
29 - iwe.u.qual.qual = sta->last_rx_signal < 27 ?
30 - 0 : (sta->last_rx_signal - 27) * 92 / 127;
31 + iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
32 + 0 : (sta->last_rx_signal - 156) * 92 / 64;
33 else
34 - iwe.u.qual.qual = sta->last_rx_signal -
35 - sta->last_rx_silence - 35;
36 - iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
37 - iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
38 + iwe.u.qual.qual = (sta->last_rx_signal -
39 + sta->last_rx_silence) * 92 / 64;
40 + iwe.u.qual.level = sta->last_rx_signal;
41 + iwe.u.qual.noise = sta->last_rx_silence;
42 iwe.u.qual.updated = sta->last_rx_updated;
43 iwe.len = IW_EV_QUAL_LEN;
44 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
45 Index: linux-2.6.21.7/drivers/net/wireless/hostap/hostap_config.h
46 ===================================================================
47 --- linux-2.6.21.7.orig/drivers/net/wireless/hostap/hostap_config.h
48 +++ linux-2.6.21.7/drivers/net/wireless/hostap/hostap_config.h
49 @@ -47,4 +47,9 @@
50 */
51 /* #define PRISM2_NO_STATION_MODES */
52
53 +/* Enable TX power Setting functions
54 + * (min att = -128 , max att = 127)
55 + */
56 +#define RAW_TXPOWER_SETTING
57 +
58 #endif /* HOSTAP_CONFIG_H */
59 Index: linux-2.6.21.7/drivers/net/wireless/hostap/hostap.h
60 ===================================================================
61 --- linux-2.6.21.7.orig/drivers/net/wireless/hostap/hostap.h
62 +++ linux-2.6.21.7/drivers/net/wireless/hostap/hostap.h
63 @@ -90,6 +90,7 @@ extern const struct iw_handler_def hosta
64 extern const struct ethtool_ops prism2_ethtool_ops;
65
66 int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
67 +int hostap_restore_power(struct net_device *dev);
68
69
70 #endif /* HOSTAP_H */
71 Index: linux-2.6.21.7/drivers/net/wireless/hostap/hostap_hw.c
72 ===================================================================
73 --- linux-2.6.21.7.orig/drivers/net/wireless/hostap/hostap_hw.c
74 +++ linux-2.6.21.7/drivers/net/wireless/hostap/hostap_hw.c
75 @@ -933,6 +933,7 @@ static int hfa384x_set_rid(struct net_de
76 prism2_hw_reset(dev);
77 }
78
79 + hostap_restore_power(dev);
80 return res;
81 }
82
83 Index: linux-2.6.21.7/drivers/net/wireless/hostap/hostap_info.c
84 ===================================================================
85 --- linux-2.6.21.7.orig/drivers/net/wireless/hostap/hostap_info.c
86 +++ linux-2.6.21.7/drivers/net/wireless/hostap/hostap_info.c
87 @@ -428,6 +428,11 @@ static void handle_info_queue_linkstatus
88 }
89
90 /* Get BSSID if we have a valid AP address */
91 +
92 + if ( val == HFA384X_LINKSTATUS_CONNECTED ||
93 + val == HFA384X_LINKSTATUS_DISCONNECTED )
94 + hostap_restore_power(local->dev);
95 +
96 if (connected) {
97 netif_carrier_on(local->dev);
98 netif_carrier_on(local->ddev);
99 Index: linux-2.6.21.7/drivers/net/wireless/hostap/hostap_ioctl.c
100 ===================================================================
101 --- linux-2.6.21.7.orig/drivers/net/wireless/hostap/hostap_ioctl.c
102 +++ linux-2.6.21.7/drivers/net/wireless/hostap/hostap_ioctl.c
103 @@ -1504,23 +1504,20 @@ static int prism2_txpower_hfa386x_to_dBm
104 val = 255;
105
106 tmp = val;
107 - tmp >>= 2;
108
109 - return -12 - tmp;
110 + return tmp;
111 }
112
113 static u16 prism2_txpower_dBm_to_hfa386x(int val)
114 {
115 signed char tmp;
116
117 - if (val > 20)
118 - return 128;
119 - else if (val < -43)
120 + if (val > 127)
121 return 127;
122 + else if (val < -128)
123 + return 128;
124
125 tmp = val;
126 - tmp = -12 - tmp;
127 - tmp <<= 2;
128
129 return (unsigned char) tmp;
130 }
131 @@ -4080,3 +4077,35 @@ int hostap_ioctl(struct net_device *dev,
132
133 return ret;
134 }
135 +
136 +/* BUG FIX: Restore power setting value when lost due to F/W bug */
137 +
138 +int hostap_restore_power(struct net_device *dev)
139 +{
140 + struct hostap_interface *iface = dev->priv;
141 + local_info_t *local = iface->local;
142 +
143 + u16 val;
144 + int ret = 0;
145 +
146 + if (local->txpower_type == PRISM2_TXPOWER_OFF) {
147 + val = 0xff; /* use all standby and sleep modes */
148 + ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
149 + HFA386X_CR_A_D_TEST_MODES2,
150 + &val, NULL);
151 + }
152 +
153 +#ifdef RAW_TXPOWER_SETTING
154 + if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
155 + val = HFA384X_TEST_CFG_BIT_ALC;
156 + local->func->cmd(dev, HFA384X_CMDCODE_TEST |
157 + (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
158 + val = prism2_txpower_dBm_to_hfa386x(local->txpower);
159 + ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
160 + HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
161 + }
162 +#endif /* RAW_TXPOWER_SETTING */
163 + return (ret ? -EOPNOTSUPP : 0);
164 +}
165 +
166 +EXPORT_SYMBOL(hostap_restore_power);
This page took 0.059858 seconds and 5 git commands to generate.