001-fix-txpower.patch 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. diff -Naur hostap-driver-0.3.7/driver/modules/hostap.c hostap-driver-0.3.7-patched/driver/modules/hostap.c
  2. --- hostap-driver-0.3.7/driver/modules/hostap.c 2004-08-28 06:26:46.000000000 +0300
  3. +++ hostap-driver-0.3.7-patched/driver/modules/hostap.c 2005-04-20 17:20:56.000000000 +0300
  4. @@ -1164,6 +1164,36 @@
  5. return ret;
  6. }
  7. +/* BUG FIX: Restore power setting value when lost due to F/W bug */
  8. +
  9. +int hostap_restore_power(struct net_device *dev)
  10. +{
  11. + struct hostap_interface *iface = dev->priv;
  12. + local_info_t *local = iface->local;
  13. +
  14. + u16 val;
  15. + int ret = 0;
  16. +
  17. + if (local->txpower_type == PRISM2_TXPOWER_OFF) {
  18. + val = 0xff; /* use all standby and sleep modes */
  19. + ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  20. + HFA386X_CR_A_D_TEST_MODES2,
  21. + &val, NULL);
  22. + }
  23. +
  24. +#ifdef RAW_TXPOWER_SETTING
  25. + if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
  26. + val = HFA384X_TEST_CFG_BIT_ALC;
  27. + local->func->cmd(dev, HFA384X_CMDCODE_TEST |
  28. + (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
  29. + val = prism2_txpower_dBm_to_hfa386x(local->txpower);
  30. + ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
  31. + HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
  32. + }
  33. +#endif /* RAW_TXPOWER_SETTING */
  34. + return (ret ? -EOPNOTSUPP : 0);
  35. +}
  36. +
  37. struct proc_dir_entry *hostap_proc;
  38. @@ -1214,6 +1244,7 @@
  39. EXPORT_SYMBOL(hostap_set_hostapd_sta);
  40. EXPORT_SYMBOL(hostap_add_interface);
  41. EXPORT_SYMBOL(hostap_remove_interface);
  42. +EXPORT_SYMBOL(hostap_restore_power);
  43. EXPORT_SYMBOL(prism2_update_comms_qual);
  44. module_init(hostap_init);
  45. diff -Naur hostap-driver-0.3.7/driver/modules/hostap.h hostap-driver-0.3.7-patched/driver/modules/hostap.h
  46. --- hostap-driver-0.3.7/driver/modules/hostap.h 2003-11-30 04:14:26.000000000 +0200
  47. +++ hostap-driver-0.3.7-patched/driver/modules/hostap.h 2005-04-20 17:21:23.000000000 +0300
  48. @@ -36,6 +36,7 @@
  49. const char *prefix, const char *name);
  50. void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
  51. int remove_from_list);
  52. +int hostap_restore_power(struct net_device *dev);
  53. int prism2_update_comms_qual(struct net_device *dev);
  54. int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u8 stype,
  55. u8 *body, size_t bodylen);
  56. diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ap.c hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c
  57. --- hostap-driver-0.3.7/driver/modules/hostap_ap.c 2005-01-24 04:52:00.000000000 +0200
  58. +++ hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c 2005-04-21 20:06:12.000000000 +0300
  59. @@ -2346,13 +2346,13 @@
  60. addr[count].sa_family = ARPHRD_ETHER;
  61. memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
  62. if (sta->last_rx_silence == 0)
  63. - qual[count].qual = sta->last_rx_signal < 27 ?
  64. - 0 : (sta->last_rx_signal - 27) * 92 / 127;
  65. + qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
  66. + 0 : (sta->last_rx_signal - 156) * 92 / 64;
  67. else
  68. - qual[count].qual = sta->last_rx_signal -
  69. - sta->last_rx_silence - 35;
  70. - qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
  71. - qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
  72. + qual[count].qual = (sta->last_rx_signal -
  73. + sta->last_rx_silence) * 92 / 64;
  74. + qual[count].level = sta->last_rx_signal;
  75. + qual[count].noise = sta->last_rx_silence;
  76. qual[count].updated = sta->last_rx_updated;
  77. sta->last_rx_updated = 0;
  78. @@ -2413,13 +2413,13 @@
  79. memset(&iwe, 0, sizeof(iwe));
  80. iwe.cmd = IWEVQUAL;
  81. if (sta->last_rx_silence == 0)
  82. - iwe.u.qual.qual = sta->last_rx_signal < 27 ?
  83. - 0 : (sta->last_rx_signal - 27) * 92 / 127;
  84. + iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
  85. + 0 : (sta->last_rx_signal - 156) * 92 / 64;
  86. else
  87. - iwe.u.qual.qual = sta->last_rx_signal -
  88. - sta->last_rx_silence - 35;
  89. - iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
  90. - iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
  91. + iwe.u.qual.qual = (sta->last_rx_signal -
  92. + sta->last_rx_silence) * 92 / 64;
  93. + iwe.u.qual.level = sta->last_rx_signal;
  94. + iwe.u.qual.noise = sta->last_rx_silence;
  95. iwe.u.qual.updated = sta->last_rx_updated;
  96. iwe.len = IW_EV_QUAL_LEN;
  97. current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
  98. diff -Naur hostap-driver-0.3.7/driver/modules/hostap_config.h hostap-driver-0.3.7-patched/driver/modules/hostap_config.h
  99. --- hostap-driver-0.3.7/driver/modules/hostap_config.h 2005-02-12 18:12:56.000000000 +0200
  100. +++ hostap-driver-0.3.7-patched/driver/modules/hostap_config.h 2005-04-20 17:25:23.000000000 +0300
  101. @@ -94,6 +94,12 @@
  102. */
  103. /* #define PRISM2_NO_STATION_MODES */
  104. +/* Enable TX power Setting functions
  105. + * (min att = -128 , max att = 127)
  106. + */
  107. +
  108. +#define RAW_TXPOWER_SETTING
  109. +
  110. /* Use Linux crypto API instead of own encryption implementation whenever
  111. * possible. */
  112. /* #define HOSTAP_USE_CRYPTO_API */
  113. diff -Naur hostap-driver-0.3.7/driver/modules/hostap_hw.c hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c
  114. --- hostap-driver-0.3.7/driver/modules/hostap_hw.c 2005-02-05 09:20:09.000000000 +0200
  115. +++ hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c 2005-04-20 17:25:55.000000000 +0300
  116. @@ -1039,6 +1039,7 @@
  117. dev->name, local->fragm_threshold);
  118. }
  119. + hostap_restore_power(dev);
  120. return res;
  121. }
  122. diff -Naur hostap-driver-0.3.7/driver/modules/hostap_info.c hostap-driver-0.3.7-patched/driver/modules/hostap_info.c
  123. --- hostap-driver-0.3.7/driver/modules/hostap_info.c 2004-02-29 20:05:44.000000000 +0200
  124. +++ hostap-driver-0.3.7-patched/driver/modules/hostap_info.c 2005-04-20 17:26:36.000000000 +0300
  125. @@ -418,6 +418,11 @@
  126. }
  127. /* Get BSSID if we have a valid AP address */
  128. +
  129. + if ( val == HFA384X_LINKSTATUS_CONNECTED ||
  130. + val == HFA384X_LINKSTATUS_DISCONNECTED )
  131. + hostap_restore_power(local->dev);
  132. +
  133. if (connected) {
  134. netif_carrier_on(local->dev);
  135. netif_carrier_on(local->ddev);
  136. diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ioctl.c hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c
  137. --- hostap-driver-0.3.7/driver/modules/hostap_ioctl.c 2004-11-22 08:03:05.000000000 +0200
  138. +++ hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c 2005-04-20 17:42:41.000000000 +0300
  139. @@ -1453,23 +1453,20 @@
  140. val = 255;
  141. tmp = val;
  142. - tmp >>= 2;
  143. - return -12 - tmp;
  144. + return tmp;
  145. }
  146. static u16 prism2_txpower_dBm_to_hfa386x(int val)
  147. {
  148. signed char tmp;
  149. - if (val > 20)
  150. - return 128;
  151. - else if (val < -43)
  152. + if (val > 127)
  153. return 127;
  154. + else if (val < -128)
  155. + return 128;
  156. tmp = val;
  157. - tmp = -12 - tmp;
  158. - tmp <<= 2;
  159. return (unsigned char) tmp;
  160. }