903-hostap_txpower.patch 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. diff -Nur linux-2.6.17/drivers/net/wireless/hostap/hostap_ap.c linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_ap.c
  2. --- linux-2.6.17/drivers/net/wireless/hostap/hostap_ap.c 2006-06-18 04:49:35.000000000 +0300
  3. +++ linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_ap.c 2006-12-10 19:13:33.000000000 +0200
  4. @@ -2345,13 +2345,13 @@
  5. addr[count].sa_family = ARPHRD_ETHER;
  6. memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
  7. if (sta->last_rx_silence == 0)
  8. - qual[count].qual = sta->last_rx_signal < 27 ?
  9. - 0 : (sta->last_rx_signal - 27) * 92 / 127;
  10. + qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
  11. + 0 : (sta->last_rx_signal - 156) * 92 / 64;
  12. else
  13. - qual[count].qual = sta->last_rx_signal -
  14. - sta->last_rx_silence - 35;
  15. - qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
  16. - qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
  17. + qual[count].qual = (sta->last_rx_signal -
  18. + sta->last_rx_silence) * 92 / 64;
  19. + qual[count].level = sta->last_rx_signal;
  20. + qual[count].noise = sta->last_rx_silence;
  21. qual[count].updated = sta->last_rx_updated;
  22. sta->last_rx_updated = IW_QUAL_DBM;
  23. @@ -2416,13 +2416,13 @@
  24. memset(&iwe, 0, sizeof(iwe));
  25. iwe.cmd = IWEVQUAL;
  26. if (sta->last_rx_silence == 0)
  27. - iwe.u.qual.qual = sta->last_rx_signal < 27 ?
  28. - 0 : (sta->last_rx_signal - 27) * 92 / 127;
  29. + iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
  30. + 0 : (sta->last_rx_signal - 156) * 92 / 64;
  31. else
  32. - iwe.u.qual.qual = sta->last_rx_signal -
  33. - sta->last_rx_silence - 35;
  34. - iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
  35. - iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
  36. + iwe.u.qual.qual = (sta->last_rx_signal -
  37. + sta->last_rx_silence) * 92 / 64;
  38. + iwe.u.qual.level = sta->last_rx_signal;
  39. + iwe.u.qual.noise = sta->last_rx_silence;
  40. iwe.u.qual.updated = sta->last_rx_updated;
  41. iwe.len = IW_EV_QUAL_LEN;
  42. current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
  43. diff -Nur linux-2.6.17/drivers/net/wireless/hostap/hostap_config.h linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_config.h
  44. --- linux-2.6.17/drivers/net/wireless/hostap/hostap_config.h 2006-06-18 04:49:35.000000000 +0300
  45. +++ linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_config.h 2006-12-10 19:13:33.000000000 +0200
  46. @@ -47,4 +47,9 @@
  47. */
  48. /* #define PRISM2_NO_STATION_MODES */
  49. +/* Enable TX power Setting functions
  50. + * (min att = -128 , max att = 127)
  51. + */
  52. +#define RAW_TXPOWER_SETTING
  53. +
  54. #endif /* HOSTAP_CONFIG_H */
  55. diff -Nur linux-2.6.17/drivers/net/wireless/hostap/hostap.h linux-2.6.17-patched/drivers/net/wireless/hostap/hostap.h
  56. --- linux-2.6.17/drivers/net/wireless/hostap/hostap.h 2006-06-18 04:49:35.000000000 +0300
  57. +++ linux-2.6.17-patched/drivers/net/wireless/hostap/hostap.h 2006-12-10 19:20:00.000000000 +0200
  58. @@ -89,6 +89,7 @@
  59. extern struct ethtool_ops prism2_ethtool_ops;
  60. int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
  61. +int hostap_restore_power(struct net_device *dev);
  62. #endif /* HOSTAP_H */
  63. diff -Nur linux-2.6.17/drivers/net/wireless/hostap/hostap_hw.c linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_hw.c
  64. --- linux-2.6.17/drivers/net/wireless/hostap/hostap_hw.c 2006-06-18 04:49:35.000000000 +0300
  65. +++ linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_hw.c 2006-12-10 19:13:33.000000000 +0200
  66. @@ -1043,6 +1043,7 @@
  67. dev->name, local->fragm_threshold);
  68. }
  69. + hostap_restore_power(dev);
  70. return res;
  71. }
  72. diff -Nur linux-2.6.17/drivers/net/wireless/hostap/hostap_info.c linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_info.c
  73. --- linux-2.6.17/drivers/net/wireless/hostap/hostap_info.c 2006-06-18 04:49:35.000000000 +0300
  74. +++ linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_info.c 2006-12-10 19:13:33.000000000 +0200
  75. @@ -429,6 +429,11 @@
  76. }
  77. /* Get BSSID if we have a valid AP address */
  78. +
  79. + if ( val == HFA384X_LINKSTATUS_CONNECTED ||
  80. + val == HFA384X_LINKSTATUS_DISCONNECTED )
  81. + hostap_restore_power(local->dev);
  82. +
  83. if (connected) {
  84. netif_carrier_on(local->dev);
  85. netif_carrier_on(local->ddev);
  86. diff -Nur linux-2.6.17/drivers/net/wireless/hostap/hostap_ioctl.c linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_ioctl.c
  87. --- linux-2.6.17/drivers/net/wireless/hostap/hostap_ioctl.c 2006-06-18 04:49:35.000000000 +0300
  88. +++ linux-2.6.17-patched/drivers/net/wireless/hostap/hostap_ioctl.c 2006-12-10 21:21:03.000000000 +0200
  89. @@ -1506,23 +1506,20 @@
  90. val = 255;
  91. tmp = val;
  92. - tmp >>= 2;
  93. - return -12 - tmp;
  94. + return tmp;
  95. }
  96. static u16 prism2_txpower_dBm_to_hfa386x(int val)
  97. {
  98. signed char tmp;
  99. - if (val > 20)
  100. - return 128;
  101. - else if (val < -43)
  102. + if (val > 127)
  103. return 127;
  104. + else if (val < -128)
  105. + return 128;
  106. tmp = val;
  107. - tmp = -12 - tmp;
  108. - tmp <<= 2;
  109. return (unsigned char) tmp;
  110. }
  111. @@ -4086,3 +4083,35 @@
  112. return ret;
  113. }
  114. +
  115. +/* BUG FIX: Restore power setting value when lost due to F/W bug */
  116. +
  117. +int hostap_restore_power(struct net_device *dev)
  118. +{
  119. + struct hostap_interface *iface = dev->priv;
  120. + local_info_t *local = iface->local;
  121. +
  122. + u16 val;
  123. + int ret = 0;
  124. +
  125. + if (local->txpower_type == PRISM2_TXPOWER_OFF) {
  126. + val = 0xff; /* use all standby and sleep modes */
  127. + ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  128. + HFA386X_CR_A_D_TEST_MODES2,
  129. + &val, NULL);
  130. + }
  131. +
  132. +#ifdef RAW_TXPOWER_SETTING
  133. + if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
  134. + val = HFA384X_TEST_CFG_BIT_ALC;
  135. + local->func->cmd(dev, HFA384X_CMDCODE_TEST |
  136. + (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
  137. + val = prism2_txpower_dBm_to_hfa386x(local->txpower);
  138. + ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  139. + HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
  140. + }
  141. +#endif /* RAW_TXPOWER_SETTING */
  142. + return (ret ? -EOPNOTSUPP : 0);
  143. +}
  144. +
  145. +EXPORT_SYMBOL(hostap_restore_power);