diff options
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl8180_dev.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl8180_grf5101.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl8180_max2820.c | 19 | ||||
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl8180_sa2400.c | 28 | ||||
-rw-r--r-- | drivers/net/wireless/rtl818x/rtl818x.h | 1 |
5 files changed, 68 insertions, 10 deletions
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c index 31808f96a3d6..d8b186a260ed 100644 --- a/drivers/net/wireless/rtl818x/rtl8180_dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c | |||
@@ -103,7 +103,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
103 | { | 103 | { |
104 | struct rtl8180_priv *priv = dev->priv; | 104 | struct rtl8180_priv *priv = dev->priv; |
105 | unsigned int count = 32; | 105 | unsigned int count = 32; |
106 | u8 signal; | 106 | u8 signal, agc, sq; |
107 | 107 | ||
108 | while (count--) { | 108 | while (count--) { |
109 | struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx]; | 109 | struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx]; |
@@ -132,12 +132,16 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
132 | 132 | ||
133 | rx_status.antenna = (flags2 >> 15) & 1; | 133 | rx_status.antenna = (flags2 >> 15) & 1; |
134 | rx_status.rate_idx = (flags >> 20) & 0xF; | 134 | rx_status.rate_idx = (flags >> 20) & 0xF; |
135 | /* TODO: improve signal/rssi reporting for !rtl8185 */ | 135 | agc = (flags2 >> 17) & 0x7F; |
136 | signal = (flags2 >> 17) & 0x7F; | 136 | if (priv->r8185) { |
137 | if (rx_status.rate_idx > 3) | 137 | if (rx_status.rate_idx > 3) |
138 | signal = 90 - clamp_t(u8, signal, 25, 90); | 138 | signal = 90 - clamp_t(u8, agc, 25, 90); |
139 | else | 139 | else |
140 | signal = 95 - clamp_t(u8, signal, 30, 95); | 140 | signal = 95 - clamp_t(u8, agc, 30, 95); |
141 | } else { | ||
142 | sq = flags2 & 0xff; | ||
143 | signal = priv->rf->calc_rssi(agc, sq); | ||
144 | } | ||
141 | rx_status.signal = signal; | 145 | rx_status.signal = signal; |
142 | rx_status.freq = dev->conf.channel->center_freq; | 146 | rx_status.freq = dev->conf.channel->center_freq; |
143 | rx_status.band = dev->conf.channel->band; | 147 | rx_status.band = dev->conf.channel->band; |
diff --git a/drivers/net/wireless/rtl818x/rtl8180_grf5101.c b/drivers/net/wireless/rtl818x/rtl8180_grf5101.c index 947ee55f18b2..5cab9dfa8c07 100644 --- a/drivers/net/wireless/rtl818x/rtl8180_grf5101.c +++ b/drivers/net/wireless/rtl818x/rtl8180_grf5101.c | |||
@@ -69,6 +69,15 @@ static void grf5101_write_phy_antenna(struct ieee80211_hw *dev, short chan) | |||
69 | rtl8180_write_phy(dev, 0x10, ant); | 69 | rtl8180_write_phy(dev, 0x10, ant); |
70 | } | 70 | } |
71 | 71 | ||
72 | static u8 grf5101_rf_calc_rssi(u8 agc, u8 sq) | ||
73 | { | ||
74 | if (agc > 60) | ||
75 | return 65; | ||
76 | |||
77 | /* TODO(?): just return agc (or agc + 5) to avoid mult / div */ | ||
78 | return 65 * agc / 60; | ||
79 | } | ||
80 | |||
72 | static void grf5101_rf_set_channel(struct ieee80211_hw *dev, | 81 | static void grf5101_rf_set_channel(struct ieee80211_hw *dev, |
73 | struct ieee80211_conf *conf) | 82 | struct ieee80211_conf *conf) |
74 | { | 83 | { |
@@ -176,5 +185,6 @@ const struct rtl818x_rf_ops grf5101_rf_ops = { | |||
176 | .name = "GCT", | 185 | .name = "GCT", |
177 | .init = grf5101_rf_init, | 186 | .init = grf5101_rf_init, |
178 | .stop = grf5101_rf_stop, | 187 | .stop = grf5101_rf_stop, |
179 | .set_chan = grf5101_rf_set_channel | 188 | .set_chan = grf5101_rf_set_channel, |
189 | .calc_rssi = grf5101_rf_calc_rssi, | ||
180 | }; | 190 | }; |
diff --git a/drivers/net/wireless/rtl818x/rtl8180_max2820.c b/drivers/net/wireless/rtl818x/rtl8180_max2820.c index 6c825fd7f3b6..16c4655181c0 100644 --- a/drivers/net/wireless/rtl818x/rtl8180_max2820.c +++ b/drivers/net/wireless/rtl818x/rtl8180_max2820.c | |||
@@ -74,6 +74,22 @@ static void max2820_write_phy_antenna(struct ieee80211_hw *dev, short chan) | |||
74 | rtl8180_write_phy(dev, 0x10, ant); | 74 | rtl8180_write_phy(dev, 0x10, ant); |
75 | } | 75 | } |
76 | 76 | ||
77 | static u8 max2820_rf_calc_rssi(u8 agc, u8 sq) | ||
78 | { | ||
79 | bool odd; | ||
80 | |||
81 | odd = !!(agc & 1); | ||
82 | |||
83 | agc >>= 1; | ||
84 | if (odd) | ||
85 | agc += 76; | ||
86 | else | ||
87 | agc += 66; | ||
88 | |||
89 | /* TODO: change addends above to avoid mult / div below */ | ||
90 | return 65 * agc / 100; | ||
91 | } | ||
92 | |||
77 | static void max2820_rf_set_channel(struct ieee80211_hw *dev, | 93 | static void max2820_rf_set_channel(struct ieee80211_hw *dev, |
78 | struct ieee80211_conf *conf) | 94 | struct ieee80211_conf *conf) |
79 | { | 95 | { |
@@ -148,5 +164,6 @@ const struct rtl818x_rf_ops max2820_rf_ops = { | |||
148 | .name = "Maxim", | 164 | .name = "Maxim", |
149 | .init = max2820_rf_init, | 165 | .init = max2820_rf_init, |
150 | .stop = max2820_rf_stop, | 166 | .stop = max2820_rf_stop, |
151 | .set_chan = max2820_rf_set_channel | 167 | .set_chan = max2820_rf_set_channel, |
168 | .calc_rssi = max2820_rf_calc_rssi, | ||
152 | }; | 169 | }; |
diff --git a/drivers/net/wireless/rtl818x/rtl8180_sa2400.c b/drivers/net/wireless/rtl818x/rtl8180_sa2400.c index cea4e0ccb92d..d064fcc5ec08 100644 --- a/drivers/net/wireless/rtl818x/rtl8180_sa2400.c +++ b/drivers/net/wireless/rtl818x/rtl8180_sa2400.c | |||
@@ -76,6 +76,31 @@ static void sa2400_write_phy_antenna(struct ieee80211_hw *dev, short chan) | |||
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | static u8 sa2400_rf_rssi_map[] = { | ||
80 | 0x64, 0x64, 0x63, 0x62, 0x61, 0x60, 0x5f, 0x5e, | ||
81 | 0x5d, 0x5c, 0x5b, 0x5a, 0x57, 0x54, 0x52, 0x50, | ||
82 | 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x41, 0x3f, | ||
83 | 0x3c, 0x3a, 0x37, 0x36, 0x36, 0x1c, 0x1c, 0x1b, | ||
84 | 0x1b, 0x1a, 0x1a, 0x19, 0x19, 0x18, 0x18, 0x17, | ||
85 | 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13, | ||
86 | 0x13, 0x12, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0f, | ||
87 | 0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b, | ||
88 | 0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07, | ||
89 | 0x07, 0x06, 0x06, 0x05, 0x04, 0x03, 0x02, | ||
90 | }; | ||
91 | |||
92 | static u8 sa2400_rf_calc_rssi(u8 agc, u8 sq) | ||
93 | { | ||
94 | if (sq == 0x80) | ||
95 | return 1; | ||
96 | |||
97 | if (sq > 78) | ||
98 | return 32; | ||
99 | |||
100 | /* TODO: recalc sa2400_rf_rssi_map to avoid mult / div */ | ||
101 | return 65 * sa2400_rf_rssi_map[sq] / 100; | ||
102 | } | ||
103 | |||
79 | static void sa2400_rf_set_channel(struct ieee80211_hw *dev, | 104 | static void sa2400_rf_set_channel(struct ieee80211_hw *dev, |
80 | struct ieee80211_conf *conf) | 105 | struct ieee80211_conf *conf) |
81 | { | 106 | { |
@@ -198,5 +223,6 @@ const struct rtl818x_rf_ops sa2400_rf_ops = { | |||
198 | .name = "Philips", | 223 | .name = "Philips", |
199 | .init = sa2400_rf_init, | 224 | .init = sa2400_rf_init, |
200 | .stop = sa2400_rf_stop, | 225 | .stop = sa2400_rf_stop, |
201 | .set_chan = sa2400_rf_set_channel | 226 | .set_chan = sa2400_rf_set_channel, |
227 | .calc_rssi = sa2400_rf_calc_rssi, | ||
202 | }; | 228 | }; |
diff --git a/drivers/net/wireless/rtl818x/rtl818x.h b/drivers/net/wireless/rtl818x/rtl818x.h index 8522490d2e29..22d938414f0d 100644 --- a/drivers/net/wireless/rtl818x/rtl818x.h +++ b/drivers/net/wireless/rtl818x/rtl818x.h | |||
@@ -193,6 +193,7 @@ struct rtl818x_rf_ops { | |||
193 | void (*stop)(struct ieee80211_hw *); | 193 | void (*stop)(struct ieee80211_hw *); |
194 | void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *); | 194 | void (*set_chan)(struct ieee80211_hw *, struct ieee80211_conf *); |
195 | void (*conf_erp)(struct ieee80211_hw *, struct ieee80211_bss_conf *); | 195 | void (*conf_erp)(struct ieee80211_hw *, struct ieee80211_bss_conf *); |
196 | u8 (*calc_rssi)(u8 agc, u8 sq); | ||
196 | }; | 197 | }; |
197 | 198 | ||
198 | /** | 199 | /** |