sync with latest madwifi snapshot, refresh patches, add tpc fix by mdtaylor (should...
[openwrt-10.03/.git] / package / madwifi / patches / 125-tpc_PR_1435.patch
1 Index: madwifi-ng-r2568-20070710/ath/if_ath.c
2 ===================================================================
3 --- madwifi-ng-r2568-20070710.orig/ath/if_ath.c 2007-07-11 22:59:42.904293522 +0200
4 +++ madwifi-ng-r2568-20070710/ath/if_ath.c      2007-07-11 22:59:44.052358947 +0200
5 @@ -273,9 +273,7 @@
6  static char *autocreate = NULL;
7  static char *ratectl = DEF_RATE_CTL;
8  static int rfkill = 0;
9 -#ifdef ATH_CAP_TPC
10  static int tpc = 0;
11 -#endif
12  static int countrycode = -1;
13  static int outdoor = -1;
14  static int xchanmode = -1;
15 @@ -533,12 +531,6 @@
16                 rfkill ? "on" : "off");
17         ath_hal_setrfsilent(ah, rfkill);
18  
19 -#ifdef ATH_CAP_TPC
20 -       printk(KERN_INFO "ath_pci: ath_pci: switching per-packet transmit power control %s\n",
21 -               tpc ? "on" : "off");
22 -       ath_hal_settpc(ah, tpc);
23 -#endif
24 -
25         /*
26          * Setup rate tables for all potential media types.
27          */
28 @@ -818,11 +810,18 @@
29          */
30  #ifdef ATH_CAP_TPC
31         sc->sc_hastpc = ath_hal_hastpc(ah);
32 -       if (sc->sc_hastpc || ath_hal_hastxpowlimit(ah))
33 +       if(tpc && !sc->sc_hastpc) {
34 +               printk(KERN_WARNING "ath_pci: WARNING: per-packet transmit power control was requested, but is not supported by the hardware.\n");
35 +               tpc = 0;
36 +       }
37 +       printk(KERN_INFO "ath_pci: switching per-packet transmit power control %s\n",
38 +               tpc ? "on" : "off");
39 +       ath_hal_settpc(ah, tpc);
40  #else
41         sc->sc_hastpc = 0;
42 -       if (ath_hal_hastxpowlimit(ah))
43 +       tpc = 0; /* TPC is always zero, when compiled without ATH_CAP_TPC */
44  #endif
45 +       if (sc->sc_hastpc || ath_hal_hastxpowlimit(ah))
46                 ic->ic_caps |= IEEE80211_C_TXPMGT;
47  
48         /*
49 @@ -1836,7 +1835,7 @@
50         ath_stop_locked(dev);
51  
52  #ifdef ATH_CAP_TPC
53 -       /* Re-enable after suspend (?) */
54 +       /* Re-enable after suspend */
55         ath_hal_settpc(ah, tpc);
56  #endif
57  
58 @@ -8787,26 +8786,17 @@
59          * Search for the VAP that needs a txpow change, if any
60          */
61         TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
62 -#ifdef ATH_CAP_TPC
63 -               if (ic->ic_newtxpowlimit == vap->iv_bss->ni_txpower) {
64 +               if (!tpc || ic->ic_newtxpowlimit >= vap->iv_bss->ni_txpower) {
65                         vap->iv_bss->ni_txpower = clamped_txpow;
66                         ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, set_node_txpower, &clamped_txpow);
67                 }
68 -#else
69 -               vap->iv_bss->ni_txpower = clamped_txpow;
70 -               ieee80211_iterate_nodes(&vap->iv_ic->ic_sta, set_node_txpower, &clamped_txpow);
71 -#endif
72         }
73  
74         ic->ic_newtxpowlimit = sc->sc_curtxpow = clamped_txpow;
75  
76 -#ifdef ATH_CAP_TPC
77 -       if (ic->ic_newtxpowlimit >= txpowlimit)
78 -               ath_hal_settxpowlimit(ah, ic->ic_newtxpowlimit);
79 -#else
80 -       if (ic->ic_newtxpowlimit != txpowlimit)
81 +       if ((tpc && ic->ic_newtxpowlimit >= txpowlimit) ||
82 +           (ic->ic_newtxpowlimit != txpowlimit))
83                 ath_hal_settxpowlimit(ah, ic->ic_newtxpowlimit);
84 -#endif
85  }
86  
87