rtw_rf.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __RTW_RF_H_
  21. #define __RTW_RF_H_
  22. #define NumRates (13)
  23. /* slot time for 11g */
  24. #define SHORT_SLOT_TIME 9
  25. #define NON_SHORT_SLOT_TIME 20
  26. #define CENTER_CH_2G_40M_NUM 9
  27. #define CENTER_CH_2G_NUM 14
  28. #define CENTER_CH_5G_20M_NUM 28 /* 20M center channels */
  29. #define CENTER_CH_5G_40M_NUM 14 /* 40M center channels */
  30. #define CENTER_CH_5G_80M_NUM 7 /* 80M center channels */
  31. #define CENTER_CH_5G_160M_NUM 3 /* 160M center channels */
  32. #define CENTER_CH_5G_ALL_NUM (CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM + CENTER_CH_5G_80M_NUM)
  33. #define MAX_CHANNEL_NUM_2G CENTER_CH_2G_NUM
  34. #define MAX_CHANNEL_NUM_5G CENTER_CH_5G_20M_NUM
  35. #define MAX_CHANNEL_NUM (MAX_CHANNEL_NUM_2G + MAX_CHANNEL_NUM_5G)
  36. extern u8 center_ch_2g[CENTER_CH_2G_NUM];
  37. extern u8 center_ch_2g_40m[CENTER_CH_2G_40M_NUM];
  38. u8 center_chs_2g_num(u8 bw);
  39. u8 center_chs_2g(u8 bw, u8 id);
  40. extern u8 center_ch_5g_20m[CENTER_CH_5G_20M_NUM];
  41. extern u8 center_ch_5g_40m[CENTER_CH_5G_40M_NUM];
  42. extern u8 center_ch_5g_20m_40m[CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM];
  43. extern u8 center_ch_5g_80m[CENTER_CH_5G_80M_NUM];
  44. extern u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM];
  45. u8 center_chs_5g_num(u8 bw);
  46. u8 center_chs_5g(u8 bw, u8 id);
  47. u8 rtw_get_scch_by_cch_offset(u8 cch, u8 bw, u8 offset);
  48. u8 rtw_get_op_chs_by_cch_bw(u8 cch, u8 bw, u8 **op_chs, u8 *op_ch_num);
  49. u8 rtw_get_ch_group(u8 ch, u8 *group, u8 *cck_group);
  50. typedef enum _CAPABILITY {
  51. cESS = 0x0001,
  52. cIBSS = 0x0002,
  53. cPollable = 0x0004,
  54. cPollReq = 0x0008,
  55. cPrivacy = 0x0010,
  56. cShortPreamble = 0x0020,
  57. cPBCC = 0x0040,
  58. cChannelAgility = 0x0080,
  59. cSpectrumMgnt = 0x0100,
  60. cQos = 0x0200, /* For HCCA, use with CF-Pollable and CF-PollReq */
  61. cShortSlotTime = 0x0400,
  62. cAPSD = 0x0800,
  63. cRM = 0x1000, /* RRM (Radio Request Measurement) */
  64. cDSSS_OFDM = 0x2000,
  65. cDelayedBA = 0x4000,
  66. cImmediateBA = 0x8000,
  67. } CAPABILITY, *PCAPABILITY;
  68. enum _REG_PREAMBLE_MODE {
  69. PREAMBLE_LONG = 1,
  70. PREAMBLE_AUTO = 2,
  71. PREAMBLE_SHORT = 3,
  72. };
  73. typedef enum _RF_PATH {
  74. RF_PATH_A = 0,
  75. RF_PATH_B = 1,
  76. RF_PATH_C = 2,
  77. RF_PATH_D = 3,
  78. } RF_PATH, *PRF_PATH;
  79. #define rf_path_char(path) (((path) >= RF_PATH_MAX) ? 'X' : 'A' + (path))
  80. /* Bandwidth Offset */
  81. #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
  82. #define HAL_PRIME_CHNL_OFFSET_LOWER 1
  83. #define HAL_PRIME_CHNL_OFFSET_UPPER 2
  84. typedef enum _BAND_TYPE {
  85. BAND_ON_2_4G = 0,
  86. BAND_ON_5G = 1,
  87. BAND_ON_BOTH = 2,
  88. BAND_MAX = 3,
  89. } BAND_TYPE, *PBAND_TYPE;
  90. extern const char *const _band_str[];
  91. #define band_str(band) (((band) >= BAND_MAX) ? _band_str[BAND_MAX] : _band_str[(band)])
  92. extern const u8 _band_to_band_cap[];
  93. #define band_to_band_cap(band) (((band) >= BAND_MAX) ? _band_to_band_cap[BAND_MAX] : _band_to_band_cap[(band)])
  94. /* Represent Channel Width in HT Capabilities
  95. * */
  96. typedef enum _CHANNEL_WIDTH {
  97. CHANNEL_WIDTH_20 = 0,
  98. CHANNEL_WIDTH_40 = 1,
  99. CHANNEL_WIDTH_80 = 2,
  100. CHANNEL_WIDTH_160 = 3,
  101. CHANNEL_WIDTH_80_80 = 4,
  102. CHANNEL_WIDTH_MAX = 5,
  103. } CHANNEL_WIDTH, *PCHANNEL_WIDTH;
  104. extern const char *const _ch_width_str[];
  105. #define ch_width_str(bw) (((bw) >= CHANNEL_WIDTH_MAX) ? _ch_width_str[CHANNEL_WIDTH_MAX] : _ch_width_str[(bw)])
  106. extern const u8 _ch_width_to_bw_cap[];
  107. #define ch_width_to_bw_cap(bw) (((bw) >= CHANNEL_WIDTH_MAX) ? _ch_width_to_bw_cap[CHANNEL_WIDTH_MAX] : _ch_width_to_bw_cap[(bw)])
  108. /*
  109. * Represent Extention Channel Offset in HT Capabilities
  110. * This is available only in 40Mhz mode.
  111. * */
  112. typedef enum _EXTCHNL_OFFSET {
  113. EXTCHNL_OFFSET_NO_EXT = 0,
  114. EXTCHNL_OFFSET_UPPER = 1,
  115. EXTCHNL_OFFSET_NO_DEF = 2,
  116. EXTCHNL_OFFSET_LOWER = 3,
  117. } EXTCHNL_OFFSET, *PEXTCHNL_OFFSET;
  118. typedef enum _VHT_DATA_SC {
  119. VHT_DATA_SC_DONOT_CARE = 0,
  120. VHT_DATA_SC_20_UPPER_OF_80MHZ = 1,
  121. VHT_DATA_SC_20_LOWER_OF_80MHZ = 2,
  122. VHT_DATA_SC_20_UPPERST_OF_80MHZ = 3,
  123. VHT_DATA_SC_20_LOWEST_OF_80MHZ = 4,
  124. VHT_DATA_SC_20_RECV1 = 5,
  125. VHT_DATA_SC_20_RECV2 = 6,
  126. VHT_DATA_SC_20_RECV3 = 7,
  127. VHT_DATA_SC_20_RECV4 = 8,
  128. VHT_DATA_SC_40_UPPER_OF_80MHZ = 9,
  129. VHT_DATA_SC_40_LOWER_OF_80MHZ = 10,
  130. } VHT_DATA_SC, *PVHT_DATA_SC_E;
  131. typedef enum _PROTECTION_MODE {
  132. PROTECTION_MODE_AUTO = 0,
  133. PROTECTION_MODE_FORCE_ENABLE = 1,
  134. PROTECTION_MODE_FORCE_DISABLE = 2,
  135. } PROTECTION_MODE, *PPROTECTION_MODE;
  136. typedef enum _RT_RF_TYPE_DEFINITION {
  137. RF_1T2R = 0,
  138. RF_2T4R = 1,
  139. RF_2T2R = 2,
  140. RF_1T1R = 3,
  141. RF_2T2R_GREEN = 4,
  142. RF_2T3R = 5,
  143. RF_3T3R = 6,
  144. RF_3T4R = 7,
  145. RF_4T4R = 8,
  146. RF_TYPE_AUTO,
  147. } RT_RF_TYPE_DEF_E;
  148. #define RF_TYPE_VALID(rf_type) (rf_type < RF_TYPE_AUTO)
  149. extern const u8 _rf_type_to_rf_tx_cnt[];
  150. #define rf_type_to_rf_tx_cnt(rf_type) (RF_TYPE_VALID(rf_type) ? _rf_type_to_rf_tx_cnt[rf_type] : 0)
  151. extern const u8 _rf_type_to_rf_rx_cnt[];
  152. #define rf_type_to_rf_rx_cnt(rf_type) (RF_TYPE_VALID(rf_type) ? _rf_type_to_rf_rx_cnt[rf_type] : 0)
  153. int rtw_ch2freq(int chan);
  154. int rtw_freq2ch(int freq);
  155. bool rtw_chbw_to_freq_range(u8 ch, u8 bw, u8 offset, u32 *hi, u32 *lo);
  156. #define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC + M.2) */
  157. #define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */
  158. #define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */
  159. #define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */
  160. #define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC + M.2) */
  161. #define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC + M.2) */
  162. #define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */
  163. #define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC + M.2) */
  164. #define RTW_MODULE_RTL8723DE_NGFF1630 BIT8 /* RTL8723DE(NGFF1630) */
  165. #define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF)
  166. struct country_chplan {
  167. char alpha2[2];
  168. u8 chplan;
  169. #ifdef CONFIG_80211AC_VHT
  170. u8 en_11ac;
  171. #endif
  172. #if RTW_DEF_MODULE_REGULATORY_CERT
  173. u16 def_module_flags; /* RTW_MODULE_RTLXXX */
  174. #endif
  175. };
  176. #ifdef CONFIG_80211AC_VHT
  177. #define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->en_11ac)
  178. #else
  179. #define COUNTRY_CHPLAN_EN_11AC(_ent) 0
  180. #endif
  181. #if RTW_DEF_MODULE_REGULATORY_CERT
  182. #define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) ((_ent)->def_module_flags)
  183. #else
  184. #define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) 0
  185. #endif
  186. const struct country_chplan *rtw_get_chplan_from_country(const char *country_code);
  187. #define BB_GAIN_2G 0
  188. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  189. #define BB_GAIN_5GLB1 1
  190. #define BB_GAIN_5GLB2 2
  191. #define BB_GAIN_5GMB1 3
  192. #define BB_GAIN_5GMB2 4
  193. #define BB_GAIN_5GHB 5
  194. #endif
  195. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  196. #define BB_GAIN_NUM 6
  197. #else
  198. #define BB_GAIN_NUM 1
  199. #endif
  200. int rtw_ch_to_bb_gain_sel(int ch);
  201. void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset);
  202. void rtw_rf_apply_tx_gain_offset(_adapter *adapter, u8 ch);
  203. u8 rtw_is_5g_band1(u8 ch);
  204. u8 rtw_is_5g_band2(u8 ch);
  205. u8 rtw_is_5g_band3(u8 ch);
  206. u8 rtw_is_5g_band4(u8 ch);
  207. u8 rtw_is_dfs_range(u32 hi, u32 lo);
  208. u8 rtw_is_dfs_ch(u8 ch);
  209. u8 rtw_is_dfs_chbw(u8 ch, u8 bw, u8 offset);
  210. bool rtw_is_long_cac_range(u32 hi, u32 lo, u8 dfs_region);
  211. bool rtw_is_long_cac_ch(u8 ch, u8 bw, u8 offset, u8 dfs_region);
  212. #endif /* _RTL8711_RF_H_ */