1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
28 #define b_mode_rate_num 4
29 #define g_mode_rate_num 8
32 /* slot time for 11g */
33 #define SHORT_SLOT_TIME 9
34 #define NON_SHORT_SLOT_TIME 20
36 #define RTL8711_RF_MAX_SENS 6
37 #define RTL8711_RF_DEF_SENS 4
40 * We now define the following channels as the max channels in each channel plan.
42 * {1,2,3,4,5,6,7,8,9,10,11,12,13,14}
44 * {36,40,44,48,52,56,60,64,100,104,108,112,116,120,124,128,132,136,140,144,149,153,157,161,165}
46 #define MAX_CHANNEL_NUM_2G 14
47 #define MAX_CHANNEL_NUM_5G 25
48 #define MAX_CHANNEL_NUM (MAX_CHANNEL_NUM_2G + MAX_CHANNEL_NUM_5G)
50 #define CENTER_CH_2G_40M_NUM 9
51 #define CENTER_CH_2G_NUM 14
52 #define CENTER_CH_5G_20M_NUM 28 /* 20M center channels */
53 #define CENTER_CH_5G_40M_NUM 14 /* 40M center channels */
54 #define CENTER_CH_5G_80M_NUM 7 /* 80M center channels */
55 #define CENTER_CH_5G_160M_NUM 3 /* 160M center channels */
56 #define CENTER_CH_5G_ALL_NUM (CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM + CENTER_CH_5G_80M_NUM)
58 extern u8 center_ch_2g[CENTER_CH_2G_NUM];
59 extern u8 center_ch_2g_40m[CENTER_CH_2G_40M_NUM];
61 u8 center_chs_2g_num(u8 bw);
62 u8 center_chs_2g(u8 bw, u8 id);
64 extern u8 center_ch_5g_20m[CENTER_CH_5G_20M_NUM];
65 extern u8 center_ch_5g_40m[CENTER_CH_5G_40M_NUM];
66 extern u8 center_ch_5g_20m_40m[CENTER_CH_5G_20M_NUM + CENTER_CH_5G_40M_NUM];
67 extern u8 center_ch_5g_80m[CENTER_CH_5G_80M_NUM];
68 extern u8 center_ch_5g_all[CENTER_CH_5G_ALL_NUM];
70 u8 center_chs_5g_num(u8 bw);
71 u8 center_chs_5g(u8 bw, u8 id);
73 u8 rtw_get_scch_by_cch_offset(u8 cch, u8 bw, u8 offset);
75 u8 rtw_get_op_chs_by_cch_bw(u8 cch, u8 bw, u8 **op_chs, u8 *op_ch_num);
77 u8 rtw_get_ch_group(u8 ch, u8 *group, u8 *cck_group);
79 /* #define NUM_REGULATORYS 21 */
80 #define NUM_REGULATORYS 1
84 #define EUROPE 0x1 /* temp, should be provided later */
85 #define JAPAN 0x2 /* temp, should be provided later */
87 struct regulatory_class {
88 u32 starting_freq; /* MHz, */
89 u8 channel_set[MAX_CHANNEL_NUM];
90 u8 channel_cck_power[MAX_CHANNEL_NUM];/* dbm */
91 u8 channel_ofdm_power[MAX_CHANNEL_NUM];/* dbm */
92 u8 txpower_limit; /* dbm */
93 u8 channel_spacing; /* MHz */
97 typedef enum _CAPABILITY {
103 cShortPreamble = 0x0020,
105 cChannelAgility = 0x0080,
106 cSpectrumMgnt = 0x0100,
107 cQos = 0x0200, /* For HCCA, use with CF-Pollable and CF-PollReq */
108 cShortSlotTime = 0x0400,
110 cRM = 0x1000, /* RRM (Radio Request Measurement) */
113 cImmediateBA = 0x8000,
114 } CAPABILITY, *PCAPABILITY;
116 enum _REG_PREAMBLE_MODE {
123 enum _RTL8712_RF_MIMO_CONFIG_ {
124 RTL8712_RFCONFIG_1T = 0x10,
125 RTL8712_RFCONFIG_2T = 0x20,
126 RTL8712_RFCONFIG_1R = 0x01,
127 RTL8712_RFCONFIG_2R = 0x02,
128 RTL8712_RFCONFIG_1T1R = 0x11,
129 RTL8712_RFCONFIG_1T2R = 0x12,
130 RTL8712_RFCONFIG_TURBO = 0x92,
131 RTL8712_RFCONFIG_2T2R = 0x22
134 typedef enum _RF_PATH {
139 } RF_PATH, *PRF_PATH;
141 #define rf_path_char(path) (((path) >= RF_PATH_MAX) ? 'X' : 'A' + (path))
143 /* Bandwidth Offset */
144 #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
145 #define HAL_PRIME_CHNL_OFFSET_LOWER 1
146 #define HAL_PRIME_CHNL_OFFSET_UPPER 2
148 typedef enum _BAND_TYPE {
153 } BAND_TYPE, *PBAND_TYPE;
155 extern const char *const _band_str[];
156 #define band_str(band) (((band) >= BAND_MAX) ? _band_str[BAND_MAX] : _band_str[(band)])
158 extern const u8 _band_to_band_cap[];
159 #define band_to_band_cap(band) (((band) >= BAND_MAX) ? _band_to_band_cap[BAND_MAX] : _band_to_band_cap[(band)])
161 /* Represent Channel Width in HT Capabilities
163 typedef enum _CHANNEL_WIDTH {
164 CHANNEL_WIDTH_20 = 0,
165 CHANNEL_WIDTH_40 = 1,
166 CHANNEL_WIDTH_80 = 2,
167 CHANNEL_WIDTH_160 = 3,
168 CHANNEL_WIDTH_80_80 = 4,
169 CHANNEL_WIDTH_MAX = 5,
170 } CHANNEL_WIDTH, *PCHANNEL_WIDTH;
172 extern const char *const _ch_width_str[];
173 #define ch_width_str(bw) (((bw) >= CHANNEL_WIDTH_MAX) ? _ch_width_str[CHANNEL_WIDTH_MAX] : _ch_width_str[(bw)])
175 extern const u8 _ch_width_to_bw_cap[];
176 #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)])
179 * Represent Extention Channel Offset in HT Capabilities
180 * This is available only in 40Mhz mode.
182 typedef enum _EXTCHNL_OFFSET {
183 EXTCHNL_OFFSET_NO_EXT = 0,
184 EXTCHNL_OFFSET_UPPER = 1,
185 EXTCHNL_OFFSET_NO_DEF = 2,
186 EXTCHNL_OFFSET_LOWER = 3,
187 } EXTCHNL_OFFSET, *PEXTCHNL_OFFSET;
189 typedef enum _VHT_DATA_SC {
190 VHT_DATA_SC_DONOT_CARE = 0,
191 VHT_DATA_SC_20_UPPER_OF_80MHZ = 1,
192 VHT_DATA_SC_20_LOWER_OF_80MHZ = 2,
193 VHT_DATA_SC_20_UPPERST_OF_80MHZ = 3,
194 VHT_DATA_SC_20_LOWEST_OF_80MHZ = 4,
195 VHT_DATA_SC_20_RECV1 = 5,
196 VHT_DATA_SC_20_RECV2 = 6,
197 VHT_DATA_SC_20_RECV3 = 7,
198 VHT_DATA_SC_20_RECV4 = 8,
199 VHT_DATA_SC_40_UPPER_OF_80MHZ = 9,
200 VHT_DATA_SC_40_LOWER_OF_80MHZ = 10,
201 } VHT_DATA_SC, *PVHT_DATA_SC_E;
203 typedef enum _PROTECTION_MODE {
204 PROTECTION_MODE_AUTO = 0,
205 PROTECTION_MODE_FORCE_ENABLE = 1,
206 PROTECTION_MODE_FORCE_DISABLE = 2,
207 } PROTECTION_MODE, *PPROTECTION_MODE;
209 typedef enum _RT_RF_TYPE_DEFINITION {
220 RF_MAX_TYPE = 0xF, /* u1Byte */
223 int rtw_ch2freq(int chan);
224 int rtw_freq2ch(int freq);
225 bool rtw_chbw_to_freq_range(u8 ch, u8 bw, u8 offset, u32 *hi, u32 *lo);
227 #define RTW_MODULE_RTL8821AE_HMC_M2 BIT0 /* RTL8821AE(HMC + M.2) */
228 #define RTW_MODULE_RTL8821AU BIT1 /* RTL8821AU */
229 #define RTW_MODULE_RTL8812AENF_NGFF BIT2 /* RTL8812AENF(8812AE+8761)_NGFF */
230 #define RTW_MODULE_RTL8812AEBT_HMC BIT3 /* RTL8812AEBT(8812AE+8761)_HMC */
231 #define RTW_MODULE_RTL8188EE_HMC_M2 BIT4 /* RTL8188EE(HMC + M.2) */
232 #define RTW_MODULE_RTL8723BE_HMC_M2 BIT5 /* RTL8723BE(HMC + M.2) */
233 #define RTW_MODULE_RTL8723BS_NGFF1216 BIT6 /* RTL8723BS(NGFF1216) */
234 #define RTW_MODULE_RTL8192EEBT_HMC_M2 BIT7 /* RTL8192EEBT(8192EE+8761AU)_(HMC + M.2) */
236 #define IS_ALPHA2_NO_SPECIFIED(_alpha2) ((*((u16 *)(_alpha2))) == 0xFFFF)
238 struct country_chplan {
241 #ifdef CONFIG_80211AC_VHT
244 #if RTW_DEF_MODULE_REGULATORY_CERT
245 u8 def_module_flags; /* RTW_MODULE_RTLXXX */
249 #ifdef CONFIG_80211AC_VHT
250 #define COUNTRY_CHPLAN_EN_11AC(_ent) ((_ent)->en_11ac)
252 #define COUNTRY_CHPLAN_EN_11AC(_ent) 0
255 #if RTW_DEF_MODULE_REGULATORY_CERT
256 #define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) ((_ent)->def_module_flags)
258 #define COUNTRY_CHPLAN_DEF_MODULE_FALGS(_ent) 0
261 const struct country_chplan *rtw_get_chplan_from_country(const char *country_code);
264 #ifdef CONFIG_IEEE80211_BAND_5GHZ
265 #define BB_GAIN_5GLB1 1
266 #define BB_GAIN_5GLB2 2
267 #define BB_GAIN_5GMB1 3
268 #define BB_GAIN_5GMB2 4
269 #define BB_GAIN_5GHB 5
272 #ifdef CONFIG_IEEE80211_BAND_5GHZ
273 #define BB_GAIN_NUM 6
275 #define BB_GAIN_NUM 1
278 int rtw_ch_to_bb_gain_sel(int ch);
279 void rtw_rf_set_tx_gain_offset(_adapter *adapter, u8 path, s8 offset);
280 void rtw_rf_apply_tx_gain_offset(_adapter *adapter, u8 ch);
282 bool rtw_is_dfs_range(u32 hi, u32 lo);
283 bool rtw_is_dfs_ch(u8 ch, u8 bw, u8 offset);
284 bool rtw_is_long_cac_range(u32 hi, u32 lo, u8 dfs_region);
285 bool rtw_is_long_cac_ch(u8 ch, u8 bw, u8 offset, u8 dfs_region);
287 #endif /* _RTL8711_RF_H_ */