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 23 24 #define OFDM_PHY 1 25 #define MIXED_PHY 2 26 #define CCK_PHY 3 27 28 #define NumRates (13) 29 30 // slot time for 11g 31 #define SHORT_SLOT_TIME 9 32 #define NON_SHORT_SLOT_TIME 20 33 34 #define RTL8711_RF_MAX_SENS 6 35 #define RTL8711_RF_DEF_SENS 4 36 37 // 38 // We now define the following channels as the max channels in each channel plan. 39 // 2G, total 14 chnls 40 // {1,2,3,4,5,6,7,8,9,10,11,12,13,14} 41 // 5G, total 24 chnls 42 // {36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,149,153,157,161,165} 43 #define MAX_CHANNEL_NUM_2G 14 44 #define MAX_CHANNEL_NUM_5G 24 45 #define MAX_CHANNEL_NUM 38//14+24 46 47 #define CENTER_CH_2G_NUM 14 48 #define CENTER_CH_5G_20M_NUM 28 /* 20M center channels */ 49 #define CENTER_CH_5G_40M_NUM 14 /* 40M center channels */ 50 #define CENTER_CH_5G_80M_NUM 7 /* 80M center channels */ 51 #define CENTER_CH_5G_ALL_NUM (CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM + CENTER_CH_5G_80M_NUM) 52 53 extern u8 center_ch_5g_20m[CENTER_CH_5G_20M_NUM]; 54 extern u8 center_ch_5g_40m[CENTER_CH_5G_40M_NUM]; 55 extern u8 center_ch_5g_80m[CENTER_CH_5G_80M_NUM]; 56 extern u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM]; 57 58 u8 center_chs_5g_num(u8 bw); 59 u8 center_chs_5g(u8 bw, u8 id); 60 61 //#define NUM_REGULATORYS 21 62 #define NUM_REGULATORYS 1 63 64 //Country codes 65 #define USA 0x555320 66 #define EUROPE 0x1 //temp, should be provided later 67 #define JAPAN 0x2 //temp, should be provided later 68 69 struct regulatory_class { 70 u32 starting_freq; //MHz, 71 u8 channel_set[MAX_CHANNEL_NUM]; 72 u8 channel_cck_power[MAX_CHANNEL_NUM];//dbm 73 u8 channel_ofdm_power[MAX_CHANNEL_NUM];//dbm 74 u8 txpower_limit; //dbm 75 u8 channel_spacing; //MHz 76 u8 modem; 77 }; 78 79 typedef enum _CAPABILITY{ 80 cESS = 0x0001, 81 cIBSS = 0x0002, 82 cPollable = 0x0004, 83 cPollReq = 0x0008, 84 cPrivacy = 0x0010, 85 cShortPreamble = 0x0020, 86 cPBCC = 0x0040, 87 cChannelAgility = 0x0080, 88 cSpectrumMgnt = 0x0100, 89 cQos = 0x0200, // For HCCA, use with CF-Pollable and CF-PollReq 90 cShortSlotTime = 0x0400, 91 cAPSD = 0x0800, 92 cRM = 0x1000, // RRM (Radio Request Measurement) 93 cDSSS_OFDM = 0x2000, 94 cDelayedBA = 0x4000, 95 cImmediateBA = 0x8000, 96 }CAPABILITY, *PCAPABILITY; 97 98 enum _REG_PREAMBLE_MODE{ 99 PREAMBLE_LONG = 1, 100 PREAMBLE_AUTO = 2, 101 PREAMBLE_SHORT = 3, 102 }; 103 104 105 enum _RTL8712_RF_MIMO_CONFIG_{ 106 RTL8712_RFCONFIG_1T=0x10, 107 RTL8712_RFCONFIG_2T=0x20, 108 RTL8712_RFCONFIG_1R=0x01, 109 RTL8712_RFCONFIG_2R=0x02, 110 RTL8712_RFCONFIG_1T1R=0x11, 111 RTL8712_RFCONFIG_1T2R=0x12, 112 RTL8712_RFCONFIG_TURBO=0x92, 113 RTL8712_RFCONFIG_2T2R=0x22 114 }; 115 116 typedef enum _RF_PATH { 117 RF_PATH_A = 0, 118 RF_PATH_B = 1, 119 RF_PATH_C = 2, 120 RF_PATH_D = 3, 121 } RF_PATH, *PRF_PATH; 122 123 #define rf_path_char(path) (((path) >= RF_PATH_MAX) ? 'X' : 'A' + (path)) 124 125 // Bandwidth Offset 126 #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 127 #define HAL_PRIME_CHNL_OFFSET_LOWER 1 128 #define HAL_PRIME_CHNL_OFFSET_UPPER 2 129 130 typedef enum _BAND_TYPE { 131 BAND_ON_2_4G = 0, 132 BAND_ON_5G = 1, 133 BAND_ON_BOTH = 2, 134 BAND_MAX = 3, 135 } BAND_TYPE, *PBAND_TYPE; 136 137 extern const char * const _band_str[]; 138 #define band_str(band) (((band) >= BAND_MAX) ? _band_str[BAND_MAX] : _band_str[(band)]) 139 140 extern const u8 _band_to_band_cap[]; 141 #define band_to_band_cap(band) (((band) >= BAND_MAX) ? _band_to_band_cap[BAND_MAX] : _band_to_band_cap[(band)]) 142 143 // Represent Channel Width in HT Capabilities 144 // 145 typedef enum _CHANNEL_WIDTH{ 146 CHANNEL_WIDTH_20 = 0, 147 CHANNEL_WIDTH_40 = 1, 148 CHANNEL_WIDTH_80 = 2, 149 CHANNEL_WIDTH_160 = 3, 150 CHANNEL_WIDTH_80_80 = 4, 151 CHANNEL_WIDTH_MAX = 5, 152 }CHANNEL_WIDTH, *PCHANNEL_WIDTH; 153 154 extern const char * const _ch_width_str[]; 155 #define ch_width_str(bw) (((bw) >= CHANNEL_WIDTH_MAX) ? _ch_width_str[CHANNEL_WIDTH_MAX] : _ch_width_str[(bw)]) 156 157 extern const u8 _ch_width_to_bw_cap[]; 158 #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)]) 159 160 // 161 // Represent Extention Channel Offset in HT Capabilities 162 // This is available only in 40Mhz mode. 163 // 164 typedef enum _EXTCHNL_OFFSET{ 165 EXTCHNL_OFFSET_NO_EXT = 0, 166 EXTCHNL_OFFSET_UPPER = 1, 167 EXTCHNL_OFFSET_NO_DEF = 2, 168 EXTCHNL_OFFSET_LOWER = 3, 169 }EXTCHNL_OFFSET, *PEXTCHNL_OFFSET; 170 171 typedef enum _VHT_DATA_SC{ 172 VHT_DATA_SC_DONOT_CARE = 0, 173 VHT_DATA_SC_20_UPPER_OF_80MHZ = 1, 174 VHT_DATA_SC_20_LOWER_OF_80MHZ = 2, 175 VHT_DATA_SC_20_UPPERST_OF_80MHZ = 3, 176 VHT_DATA_SC_20_LOWEST_OF_80MHZ = 4, 177 VHT_DATA_SC_20_RECV1 = 5, 178 VHT_DATA_SC_20_RECV2 = 6, 179 VHT_DATA_SC_20_RECV3 = 7, 180 VHT_DATA_SC_20_RECV4 = 8, 181 VHT_DATA_SC_40_UPPER_OF_80MHZ = 9, 182 VHT_DATA_SC_40_LOWER_OF_80MHZ = 10, 183 }VHT_DATA_SC, *PVHT_DATA_SC_E; 184 185 typedef enum _PROTECTION_MODE{ 186 PROTECTION_MODE_AUTO = 0, 187 PROTECTION_MODE_FORCE_ENABLE = 1, 188 PROTECTION_MODE_FORCE_DISABLE = 2, 189 }PROTECTION_MODE, *PPROTECTION_MODE; 190 191 typedef enum _RT_RF_TYPE_DEFINITION 192 { 193 RF_1T2R = 0, 194 RF_2T4R = 1, 195 RF_2T2R = 2, 196 RF_1T1R = 3, 197 RF_2T2R_GREEN = 4, 198 RF_2T3R = 5, 199 RF_3T3R = 6, 200 RF_3T4R = 7, 201 RF_4T4R = 8, 202 203 RF_MAX_TYPE = 0xF, /* u1Byte */ 204 }RT_RF_TYPE_DEF_E; 205 206 int rtw_ch2freq(int chan); 207 int rtw_freq2ch(int freq); 208 bool rtw_chbw_to_freq_range(u8 ch, u8 bw, u8 offset, u32 *hi, u32 *lo); 209 210 #define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC+M.2) */ 211 #define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */ 212 #define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */ 213 #define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */ 214 #define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC+M.2) */ 215 #define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC+M.2) */ 216 #define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */ 217 #define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC+M.2) */ 218 219 #define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF) 220 221 struct country_chplan { 222 char alpha2[2]; 223 u8 chplan; 224 #ifdef CONFIG_80211AC_VHT 225 u8 en_11ac; 226 #endif 227 #if RTW_DEF_MODULE_REGULATORY_CERT 228 u8 def_module_flags; /* RTW_MODULE_RTLXXX */ 229 #endif 230 }; 231 232 #ifdef CONFIG_80211AC_VHT 233 #define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->en_11ac) 234 #else 235 #define COUNTRY_CHPLAN_EN_11AC(_ent) 0 236 #endif 237 238 #if RTW_DEF_MODULE_REGULATORY_CERT 239 #define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) ((_ent)->def_module_flags) 240 #else 241 #define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) 0 242 #endif 243 244 const struct country_chplan *rtw_get_chplan_from_country(const char *country_code); 245 246 #define BB_GAIN_2G 0 247 #ifdef CONFIG_IEEE80211_BAND_5GHZ 248 #define BB_GAIN_5GLB1 1 249 #define BB_GAIN_5GLB2 2 250 #define BB_GAIN_5GMB1 3 251 #define BB_GAIN_5GMB2 4 252 #define BB_GAIN_5GHB 5 253 #endif 254 255 #ifdef CONFIG_IEEE80211_BAND_5GHZ 256 #define BB_GAIN_NUM 6 257 #else 258 #define BB_GAIN_NUM 1 259 #endif 260 261 int rtw_ch_to_bb_gain_sel(int ch); 262 void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset); 263 void rtw_rf_apply_tx_gain_offset(_adapter *adapter, u8 ch); 264 265 bool rtw_is_dfs_range(u32 hi, u32 lo); 266 bool rtw_is_dfs_ch(u8 ch, u8 bw, u8 offset); 267 bool rtw_is_long_cac_range(u32 hi, u32 lo); 268 bool rtw_is_long_cac_ch(u8 ch, u8 bw, u8 offset); 269 270 #endif //_RTL8711_RF_H_ 271 272