rtl8180: improve signal reporting for rtl8185 hardware
authorJohn W. Linville <linville@tuxdriver.com>
Mon, 19 Jul 2010 20:35:20 +0000 (16:35 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 20 Jul 2010 20:53:09 +0000 (16:53 -0400)
The existing code seemed to be somewhat based on the datasheet, but
varied substantially from the vendor-provided driver.  This mirrors the
handling of the rtl8185 case from that driver, but still neglects the
specifics for the rtl8180 hardware.  Those details are a bit muddled...

Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rtl818x/rtl8180_dev.c

index 4270502..31808f9 100644 (file)
@@ -103,6 +103,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
 {
        struct rtl8180_priv *priv = dev->priv;
        unsigned int count = 32;
+       u8 signal;
 
        while (count--) {
                struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx];
@@ -130,10 +131,14 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
                        skb_put(skb, flags & 0xFFF);
 
                        rx_status.antenna = (flags2 >> 15) & 1;
-                       /* TODO: improve signal/rssi reporting */
-                       rx_status.signal = (flags2 >> 8) & 0x7F;
-                       /* XXX: is this correct? */
                        rx_status.rate_idx = (flags >> 20) & 0xF;
+                       /* TODO: improve signal/rssi reporting for !rtl8185 */
+                       signal = (flags2 >> 17) & 0x7F;
+                       if (rx_status.rate_idx > 3)
+                               signal = 90 - clamp_t(u8, signal, 25, 90);
+                       else
+                               signal = 95 - clamp_t(u8, signal, 30, 95);
+                       rx_status.signal = signal;
                        rx_status.freq = dev->conf.channel->center_freq;
                        rx_status.band = dev->conf.channel->band;
                        rx_status.mactime = le64_to_cpu(entry->tsft);