750-hostap_txpower.patch 5.1 KB

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