1
2
3
4
5
6
7
8#include "odm_precomp.h"
9
10static const u16 dB_Invert_Table[8][12] = {
11 {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4},
12 {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16},
13 {18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63},
14 {71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251},
15 {282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000},
16 {1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981},
17 {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125,
18 15849},
19 {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119,
20 56234, 65535}
21 };
22
23
24
25u32 OFDMSwingTable[OFDM_TABLE_SIZE] = {
26 0x7f8001fe,
27 0x788001e2,
28 0x71c001c7,
29 0x6b8001ae,
30 0x65400195,
31 0x5fc0017f,
32 0x5a400169,
33 0x55400155,
34 0x50800142,
35 0x4c000130,
36 0x47c0011f,
37 0x43c0010f,
38 0x40000100,
39 0x3c8000f2,
40 0x390000e4,
41 0x35c000d7,
42 0x32c000cb,
43 0x300000c0,
44 0x2d4000b5,
45 0x2ac000ab,
46 0x288000a2,
47 0x26000098,
48 0x24000090,
49 0x22000088,
50 0x20000080,
51 0x1e400079,
52 0x1c800072,
53 0x1b00006c,
54 0x19800066,
55 0x18000060,
56 0x16c0005b,
57 0x15800056,
58 0x14400051,
59 0x1300004c,
60 0x12000048,
61 0x11000044,
62 0x10000040,
63};
64
65u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = {
66 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
67 {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
68 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
69 {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
70 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
71 {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
72 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
73 {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
74 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
75 {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
76 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
77 {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
78 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
79 {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
80 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
81 {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
82 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
83 {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
84 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
85 {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
86 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
87 {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
88 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01},
89 {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01},
90 {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01},
91 {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01},
92 {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01},
93 {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},
94 {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01},
95 {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01},
96 {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01},
97 {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01},
98 {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}
99};
100
101u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = {
102 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00},
103 {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
104 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
105 {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00},
106 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
107 {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00},
108 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
109 {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
110 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
111 {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
112 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
113 {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
114 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
115 {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
116 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
117 {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
118 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
119 {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
120 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
121 {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
122 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
123 {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
124 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00},
125 {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
126 {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
127 {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00},
128 {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
129 {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
130 {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
131 {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
132 {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
133 {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
134 {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
135};
136
137u32 OFDMSwingTable_New[OFDM_TABLE_SIZE] = {
138 0x0b40002d,
139 0x0c000030,
140 0x0cc00033,
141 0x0d800036,
142 0x0e400039,
143 0x0f00003c,
144 0x10000040,
145 0x11000044,
146 0x12000048,
147 0x1300004c,
148 0x14400051,
149 0x15800056,
150 0x16c0005b,
151 0x18000060,
152 0x19800066,
153 0x1b00006c,
154 0x1c800072,
155 0x1e400079,
156 0x20000080,
157 0x22000088,
158 0x24000090,
159 0x26000098,
160 0x288000a2,
161 0x2ac000ab,
162 0x2d4000b5,
163 0x300000c0,
164 0x32c000cb,
165 0x35c000d7,
166 0x390000e4,
167 0x3c8000f2,
168 0x40000100,
169 0x43c0010f,
170 0x47c0011f,
171 0x4c000130,
172 0x50800142,
173 0x55400155,
174 0x5a400169,
175 0x5fc0017f,
176 0x65400195,
177 0x6b8001ae,
178 0x71c001c7,
179 0x788001e2,
180 0x7f8001fe
181};
182
183u8 CCKSwingTable_Ch1_Ch13_New[CCK_TABLE_SIZE][8] = {
184 {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01},
185 {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01},
186 {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01},
187 {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01},
188 {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01},
189 {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},
190 {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01},
191 {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01},
192 {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01},
193 {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01},
194 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01},
195 {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
196 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
197 {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
198 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
199 {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
200 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
201 {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
202 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
203 {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
204 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
205 {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
206 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
207 {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
208 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
209 {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
210 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
211 {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
212 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
213 {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
214 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
215 {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
216 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}
217};
218
219u8 CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8] = {
220 {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00},
221 {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
222 {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
223 {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
224 {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
225 {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
226 {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
227 {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00},
228 {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
229 {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
230 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00},
231 {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
232 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
233 {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
234 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
235 {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
236 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
237 {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
238 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
239 {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
240 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
241 {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
242 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
243 {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
244 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
245 {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
246 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
247 {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00},
248 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
249 {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00},
250 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
251 {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
252 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}
253};
254
255u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = {
256 0x081,
257 0x088,
258 0x090,
259 0x099,
260 0x0A2,
261 0x0AC,
262 0x0B6,
263 0x0C0,
264 0x0CC,
265 0x0D8,
266 0x0E5,
267 0x0F2,
268 0x101,
269 0x110,
270 0x120,
271 0x131,
272 0x143,
273 0x156,
274 0x16A,
275 0x180,
276 0x197,
277 0x1AF,
278 0x1C8,
279 0x1E3,
280 0x200,
281 0x21E,
282 0x23E,
283 0x261,
284 0x285,
285 0x2AB,
286 0x2D3,
287 0x2FE,
288 0x32B,
289 0x35C,
290 0x38E,
291 0x3C4,
292 0x3FE
293};
294
295
296
297
298void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm);
299
300void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm);
301
302void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm);
303
304void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm);
305
306
307
308
309
310
311
312
313
314
315
316
317
318void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm);
319
320
321
322void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm);
323
324void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm);
325
326void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm);
327
328void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm);
329
330void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
331
332
333
334void odm_GlobalAdapterCheck(void);
335
336void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm);
337
338void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
339
340void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm);
341
342void odm_TXPowerTrackingThermalMeterInit(PDM_ODM_T pDM_Odm);
343
344
345void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
346
347void odm_TXPowerTrackingCheckCE(PDM_ODM_T pDM_Odm);
348
349
350
351
352#define RxDefaultAnt1 0x65a9
353#define RxDefaultAnt2 0x569a
354
355void odm_InitHybridAntDiv(PDM_ODM_T pDM_Odm);
356
357bool odm_StaDefAntSel(
358 PDM_ODM_T pDM_Odm,
359 u32 OFDM_Ant1_Cnt,
360 u32 OFDM_Ant2_Cnt,
361 u32 CCK_Ant1_Cnt,
362 u32 CCK_Ant2_Cnt,
363 u8 *pDefAnt
364);
365
366void odm_SetRxIdleAnt(PDM_ODM_T pDM_Odm, u8 Ant, bool bDualPath);
367
368
369
370void odm_HwAntDiv(PDM_ODM_T pDM_Odm);
371
372
373
374
375
376
377
378
379
380void ODM_DMInit(PDM_ODM_T pDM_Odm)
381{
382
383 odm_CommonInfoSelfInit(pDM_Odm);
384 odm_CmnInfoInit_Debug(pDM_Odm);
385 odm_DIGInit(pDM_Odm);
386 odm_NHMCounterStatisticsInit(pDM_Odm);
387 odm_AdaptivityInit(pDM_Odm);
388 odm_RateAdaptiveMaskInit(pDM_Odm);
389 ODM_CfoTrackingInit(pDM_Odm);
390 ODM_EdcaTurboInit(pDM_Odm);
391 odm_RSSIMonitorInit(pDM_Odm);
392 odm_TXPowerTrackingInit(pDM_Odm);
393
394 ODM_ClearTxPowerTrackingState(pDM_Odm);
395
396 if (*(pDM_Odm->mp_mode) != 1)
397 odm_PathDiversityInit(pDM_Odm);
398
399 odm_DynamicBBPowerSavingInit(pDM_Odm);
400 odm_DynamicTxPowerInit(pDM_Odm);
401
402 odm_SwAntDetectInit(pDM_Odm);
403}
404
405
406
407
408
409
410void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
411{
412 odm_CommonInfoSelfUpdate(pDM_Odm);
413 odm_BasicDbgMessage(pDM_Odm);
414 odm_FalseAlarmCounterStatistics(pDM_Odm);
415 odm_NHMCounterStatistics(pDM_Odm);
416 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): RSSI = 0x%x\n", pDM_Odm->RSSI_Min));
417
418 odm_RSSIMonitorCheck(pDM_Odm);
419
420
421
422
423
424 if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE)
425
426
427
428
429 ) {
430 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n"));
431 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
432 odm_DIGbyRSSI_LPS(pDM_Odm);
433 } else
434 odm_DIG(pDM_Odm);
435
436 {
437 pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
438
439 odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
440 }
441 odm_CCKPacketDetectionThresh(pDM_Odm);
442
443 if (*(pDM_Odm->pbPowerSaving) == true)
444 return;
445
446
447 odm_RefreshRateAdaptiveMask(pDM_Odm);
448 odm_EdcaTurboCheck(pDM_Odm);
449 odm_PathDiversity(pDM_Odm);
450 ODM_CfoTracking(pDM_Odm);
451
452 ODM_TXPowerTrackingCheck(pDM_Odm);
453
454
455
456
457
458 pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
459}
460
461
462
463
464
465void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
466{
467
468
469
470 switch (CmnInfo) {
471
472
473
474 case ODM_CMNINFO_ABILITY:
475 pDM_Odm->SupportAbility = (u32)Value;
476 break;
477
478 case ODM_CMNINFO_RF_TYPE:
479 pDM_Odm->RFType = (u8)Value;
480 break;
481
482 case ODM_CMNINFO_PLATFORM:
483 pDM_Odm->SupportPlatform = (u8)Value;
484 break;
485
486 case ODM_CMNINFO_INTERFACE:
487 pDM_Odm->SupportInterface = (u8)Value;
488 break;
489
490 case ODM_CMNINFO_MP_TEST_CHIP:
491 pDM_Odm->bIsMPChip = (u8)Value;
492 break;
493
494 case ODM_CMNINFO_IC_TYPE:
495 pDM_Odm->SupportICType = Value;
496 break;
497
498 case ODM_CMNINFO_CUT_VER:
499 pDM_Odm->CutVersion = (u8)Value;
500 break;
501
502 case ODM_CMNINFO_FAB_VER:
503 pDM_Odm->FabVersion = (u8)Value;
504 break;
505
506 case ODM_CMNINFO_RFE_TYPE:
507 pDM_Odm->RFEType = (u8)Value;
508 break;
509
510 case ODM_CMNINFO_RF_ANTENNA_TYPE:
511 pDM_Odm->AntDivType = (u8)Value;
512 break;
513
514 case ODM_CMNINFO_BOARD_TYPE:
515 pDM_Odm->BoardType = (u8)Value;
516 break;
517
518 case ODM_CMNINFO_PACKAGE_TYPE:
519 pDM_Odm->PackageType = (u8)Value;
520 break;
521
522 case ODM_CMNINFO_EXT_LNA:
523 pDM_Odm->ExtLNA = (u8)Value;
524 break;
525
526 case ODM_CMNINFO_5G_EXT_LNA:
527 pDM_Odm->ExtLNA5G = (u8)Value;
528 break;
529
530 case ODM_CMNINFO_EXT_PA:
531 pDM_Odm->ExtPA = (u8)Value;
532 break;
533
534 case ODM_CMNINFO_5G_EXT_PA:
535 pDM_Odm->ExtPA5G = (u8)Value;
536 break;
537
538 case ODM_CMNINFO_GPA:
539 pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value;
540 break;
541 case ODM_CMNINFO_APA:
542 pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value;
543 break;
544 case ODM_CMNINFO_GLNA:
545 pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value;
546 break;
547 case ODM_CMNINFO_ALNA:
548 pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value;
549 break;
550
551 case ODM_CMNINFO_EXT_TRSW:
552 pDM_Odm->ExtTRSW = (u8)Value;
553 break;
554 case ODM_CMNINFO_PATCH_ID:
555 pDM_Odm->PatchID = (u8)Value;
556 break;
557 case ODM_CMNINFO_BINHCT_TEST:
558 pDM_Odm->bInHctTest = (bool)Value;
559 break;
560 case ODM_CMNINFO_BWIFI_TEST:
561 pDM_Odm->bWIFITest = (bool)Value;
562 break;
563
564 case ODM_CMNINFO_SMART_CONCURRENT:
565 pDM_Odm->bDualMacSmartConcurrent = (bool)Value;
566 break;
567
568
569 default:
570
571 break;
572 }
573
574}
575
576
577void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue)
578{
579
580
581
582 switch (CmnInfo) {
583
584
585
586 case ODM_CMNINFO_MAC_PHY_MODE:
587 pDM_Odm->pMacPhyMode = pValue;
588 break;
589
590 case ODM_CMNINFO_TX_UNI:
591 pDM_Odm->pNumTxBytesUnicast = pValue;
592 break;
593
594 case ODM_CMNINFO_RX_UNI:
595 pDM_Odm->pNumRxBytesUnicast = pValue;
596 break;
597
598 case ODM_CMNINFO_WM_MODE:
599 pDM_Odm->pwirelessmode = pValue;
600 break;
601
602 case ODM_CMNINFO_BAND:
603 pDM_Odm->pBandType = pValue;
604 break;
605
606 case ODM_CMNINFO_SEC_CHNL_OFFSET:
607 pDM_Odm->pSecChOffset = pValue;
608 break;
609
610 case ODM_CMNINFO_SEC_MODE:
611 pDM_Odm->pSecurity = pValue;
612 break;
613
614 case ODM_CMNINFO_BW:
615 pDM_Odm->pBandWidth = pValue;
616 break;
617
618 case ODM_CMNINFO_CHNL:
619 pDM_Odm->pChannel = pValue;
620 break;
621
622 case ODM_CMNINFO_DMSP_GET_VALUE:
623 pDM_Odm->pbGetValueFromOtherMac = pValue;
624 break;
625
626 case ODM_CMNINFO_BUDDY_ADAPTOR:
627 pDM_Odm->pBuddyAdapter = pValue;
628 break;
629
630 case ODM_CMNINFO_DMSP_IS_MASTER:
631 pDM_Odm->pbMasterOfDMSP = pValue;
632 break;
633
634 case ODM_CMNINFO_SCAN:
635 pDM_Odm->pbScanInProcess = pValue;
636 break;
637
638 case ODM_CMNINFO_POWER_SAVING:
639 pDM_Odm->pbPowerSaving = pValue;
640 break;
641
642 case ODM_CMNINFO_ONE_PATH_CCA:
643 pDM_Odm->pOnePathCCA = pValue;
644 break;
645
646 case ODM_CMNINFO_DRV_STOP:
647 pDM_Odm->pbDriverStopped = pValue;
648 break;
649
650 case ODM_CMNINFO_PNP_IN:
651 pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = pValue;
652 break;
653
654 case ODM_CMNINFO_INIT_ON:
655 pDM_Odm->pinit_adpt_in_progress = pValue;
656 break;
657
658 case ODM_CMNINFO_ANT_TEST:
659 pDM_Odm->pAntennaTest = pValue;
660 break;
661
662 case ODM_CMNINFO_NET_CLOSED:
663 pDM_Odm->pbNet_closed = pValue;
664 break;
665
666 case ODM_CMNINFO_FORCED_RATE:
667 pDM_Odm->pForcedDataRate = pValue;
668 break;
669
670 case ODM_CMNINFO_FORCED_IGI_LB:
671 pDM_Odm->pu1ForcedIgiLb = pValue;
672 break;
673
674 case ODM_CMNINFO_MP_MODE:
675 pDM_Odm->mp_mode = pValue;
676 break;
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697 default:
698
699 break;
700 }
701
702}
703
704
705void ODM_CmnInfoPtrArrayHook(
706 PDM_ODM_T pDM_Odm,
707 ODM_CMNINFO_E CmnInfo,
708 u16 Index,
709 void *pValue
710)
711{
712
713
714
715 switch (CmnInfo) {
716
717
718
719 case ODM_CMNINFO_STA_STATUS:
720 pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
721 break;
722
723 default:
724
725 break;
726 }
727
728}
729
730
731
732
733
734void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value)
735{
736
737
738
739 switch (CmnInfo) {
740 case ODM_CMNINFO_LINK_IN_PROGRESS:
741 pDM_Odm->bLinkInProcess = (bool)Value;
742 break;
743
744 case ODM_CMNINFO_ABILITY:
745 pDM_Odm->SupportAbility = (u32)Value;
746 break;
747
748 case ODM_CMNINFO_RF_TYPE:
749 pDM_Odm->RFType = (u8)Value;
750 break;
751
752 case ODM_CMNINFO_WIFI_DIRECT:
753 pDM_Odm->bWIFI_Direct = (bool)Value;
754 break;
755
756 case ODM_CMNINFO_WIFI_DISPLAY:
757 pDM_Odm->bWIFI_Display = (bool)Value;
758 break;
759
760 case ODM_CMNINFO_LINK:
761 pDM_Odm->bLinked = (bool)Value;
762 break;
763
764 case ODM_CMNINFO_STATION_STATE:
765 pDM_Odm->bsta_state = (bool)Value;
766 break;
767
768 case ODM_CMNINFO_RSSI_MIN:
769 pDM_Odm->RSSI_Min = (u8)Value;
770 break;
771
772 case ODM_CMNINFO_DBG_COMP:
773 pDM_Odm->DebugComponents = Value;
774 break;
775
776 case ODM_CMNINFO_DBG_LEVEL:
777 pDM_Odm->DebugLevel = (u32)Value;
778 break;
779 case ODM_CMNINFO_RA_THRESHOLD_HIGH:
780 pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value;
781 break;
782
783 case ODM_CMNINFO_RA_THRESHOLD_LOW:
784 pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value;
785 break;
786
787 case ODM_CMNINFO_BT_ENABLED:
788 pDM_Odm->bBtEnabled = (bool)Value;
789 break;
790
791 case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
792 pDM_Odm->bBtConnectProcess = (bool)Value;
793 break;
794
795 case ODM_CMNINFO_BT_HS_RSSI:
796 pDM_Odm->btHsRssi = (u8)Value;
797 break;
798
799 case ODM_CMNINFO_BT_OPERATION:
800 pDM_Odm->bBtHsOperation = (bool)Value;
801 break;
802
803 case ODM_CMNINFO_BT_LIMITED_DIG:
804 pDM_Odm->bBtLimitedDig = (bool)Value;
805 break;
806
807 case ODM_CMNINFO_BT_DISABLE_EDCA:
808 pDM_Odm->bBtDisableEdcaTurbo = (bool)Value;
809 break;
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840 default:
841
842 break;
843 }
844
845
846}
847
848void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm)
849{
850 pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
851 pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
852
853 ODM_InitDebugSetting(pDM_Odm);
854
855 pDM_Odm->TxRate = 0xFF;
856}
857
858void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm)
859{
860 u8 EntryCnt = 0;
861 u8 i;
862 PSTA_INFO_T pEntry;
863
864 if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
865 if (*(pDM_Odm->pSecChOffset) == 1)
866 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
867 else if (*(pDM_Odm->pSecChOffset) == 2)
868 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
869 } else
870 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
871
872 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
873 pEntry = pDM_Odm->pODM_StaInfo[i];
874 if (IS_STA_VALID(pEntry))
875 EntryCnt++;
876 }
877
878 if (EntryCnt == 1)
879 pDM_Odm->bOneEntryOnly = true;
880 else
881 pDM_Odm->bOneEntryOnly = false;
882}
883
884void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm)
885{
886 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
887 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
888 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility));
889 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface =%d\n", pDM_Odm->SupportInterface));
890 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType));
891 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion));
892 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion));
893 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType =%d\n", pDM_Odm->RFType));
894 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType));
895 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA));
896 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA));
897 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW));
898 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID =%d\n", pDM_Odm->PatchID));
899 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest));
900 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest));
901 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent));
902
903}
904
905void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
906{
907 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
908 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
909 pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
910 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
911 pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
912}
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm)
953{
954 PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive;
955
956 pOdmRA->Type = DM_Type_ByDriver;
957 if (pOdmRA->Type == DM_Type_ByDriver)
958 pDM_Odm->bUseRAMask = true;
959 else
960 pDM_Odm->bUseRAMask = false;
961
962 pOdmRA->RATRState = DM_RATR_STA_INIT;
963 pOdmRA->LdpcThres = 35;
964 pOdmRA->bUseLdpc = false;
965 pOdmRA->HighRSSIThresh = 50;
966 pOdmRA->LowRSSIThresh = 20;
967}
968
969u32 ODM_Get_Rate_Bitmap(
970 PDM_ODM_T pDM_Odm,
971 u32 macid,
972 u32 ra_mask,
973 u8 rssi_level
974)
975{
976 PSTA_INFO_T pEntry;
977 u32 rate_bitmap = 0;
978 u8 WirelessMode;
979
980 pEntry = pDM_Odm->pODM_StaInfo[macid];
981 if (!IS_STA_VALID(pEntry))
982 return ra_mask;
983
984 WirelessMode = pEntry->wireless_mode;
985
986 switch (WirelessMode) {
987 case ODM_WM_B:
988 if (ra_mask & 0x0000000c)
989 rate_bitmap = 0x0000000d;
990 else
991 rate_bitmap = 0x0000000f;
992 break;
993
994 case (ODM_WM_G):
995 case (ODM_WM_A):
996 if (rssi_level == DM_RATR_STA_HIGH)
997 rate_bitmap = 0x00000f00;
998 else
999 rate_bitmap = 0x00000ff0;
1000 break;
1001
1002 case (ODM_WM_B|ODM_WM_G):
1003 if (rssi_level == DM_RATR_STA_HIGH)
1004 rate_bitmap = 0x00000f00;
1005 else if (rssi_level == DM_RATR_STA_MIDDLE)
1006 rate_bitmap = 0x00000ff0;
1007 else
1008 rate_bitmap = 0x00000ff5;
1009 break;
1010
1011 case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
1012 case (ODM_WM_B|ODM_WM_N24G):
1013 case (ODM_WM_G|ODM_WM_N24G):
1014 case (ODM_WM_A|ODM_WM_N5G):
1015 if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
1016 if (rssi_level == DM_RATR_STA_HIGH)
1017 rate_bitmap = 0x000f0000;
1018 else if (rssi_level == DM_RATR_STA_MIDDLE)
1019 rate_bitmap = 0x000ff000;
1020 else {
1021 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
1022 rate_bitmap = 0x000ff015;
1023 else
1024 rate_bitmap = 0x000ff005;
1025 }
1026 } else {
1027 if (rssi_level == DM_RATR_STA_HIGH)
1028 rate_bitmap = 0x0f8f0000;
1029 else if (rssi_level == DM_RATR_STA_MIDDLE)
1030 rate_bitmap = 0x0f8ff000;
1031 else {
1032 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
1033 rate_bitmap = 0x0f8ff015;
1034 else
1035 rate_bitmap = 0x0f8ff005;
1036 }
1037 }
1038 break;
1039
1040 case (ODM_WM_AC|ODM_WM_G):
1041 if (rssi_level == 1)
1042 rate_bitmap = 0xfc3f0000;
1043 else if (rssi_level == 2)
1044 rate_bitmap = 0xfffff000;
1045 else
1046 rate_bitmap = 0xffffffff;
1047 break;
1048
1049 case (ODM_WM_AC|ODM_WM_A):
1050
1051 if (pDM_Odm->RFType == RF_1T1R) {
1052 if (rssi_level == 1)
1053 rate_bitmap = 0x003f8000;
1054 else if (rssi_level == 2)
1055 rate_bitmap = 0x003ff000;
1056 else
1057 rate_bitmap = 0x003ff010;
1058 } else {
1059 if (rssi_level == 1)
1060 rate_bitmap = 0xfe3f8000;
1061 else if (rssi_level == 2)
1062 rate_bitmap = 0xfffff000;
1063 else
1064 rate_bitmap = 0xfffff010;
1065 }
1066 break;
1067
1068 default:
1069 if (pDM_Odm->RFType == RF_1T2R)
1070 rate_bitmap = 0x000fffff;
1071 else
1072 rate_bitmap = 0x0fffffff;
1073 break;
1074 }
1075
1076
1077 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", rssi_level, WirelessMode, rate_bitmap));
1078
1079 return (ra_mask&rate_bitmap);
1080
1081}
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm)
1101{
1102
1103 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
1104 if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
1105 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
1106 return;
1107 }
1108 odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
1109}
1110
1111void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm)
1112{
1113 u8 i;
1114 struct adapter *padapter = pDM_Odm->Adapter;
1115
1116 if (padapter->bDriverStopped) {
1117 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
1118 return;
1119 }
1120
1121 if (!pDM_Odm->bUseRAMask) {
1122 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
1123 return;
1124 }
1125
1126
1127
1128 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
1129 PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
1130
1131 if (IS_STA_VALID(pstat)) {
1132 if (IS_MCAST(pstat->hwaddr))
1133 continue;
1134 if (IS_MCAST(pstat->hwaddr))
1135 continue;
1136
1137 if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
1138 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level));
1139
1140 rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
1141 }
1142
1143 }
1144 }
1145}
1146
1147
1148
1149bool ODM_RAStateCheck(
1150 PDM_ODM_T pDM_Odm,
1151 s32 RSSI,
1152 bool bForceUpdate,
1153 u8 *pRATRState
1154)
1155{
1156 PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
1157 const u8 GoUpGap = 5;
1158 u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
1159 u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
1160 u8 RATRState;
1161
1162
1163
1164
1165 switch (*pRATRState) {
1166 case DM_RATR_STA_INIT:
1167 case DM_RATR_STA_HIGH:
1168 break;
1169
1170 case DM_RATR_STA_MIDDLE:
1171 HighRSSIThreshForRA += GoUpGap;
1172 break;
1173
1174 case DM_RATR_STA_LOW:
1175 HighRSSIThreshForRA += GoUpGap;
1176 LowRSSIThreshForRA += GoUpGap;
1177 break;
1178
1179 default:
1180 ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
1181 break;
1182 }
1183
1184
1185 if (RSSI > HighRSSIThreshForRA)
1186 RATRState = DM_RATR_STA_HIGH;
1187 else if (RSSI > LowRSSIThreshForRA)
1188 RATRState = DM_RATR_STA_MIDDLE;
1189 else
1190 RATRState = DM_RATR_STA_LOW;
1191
1192
1193 if (*pRATRState != RATRState || bForceUpdate) {
1194 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
1195 *pRATRState = RATRState;
1196 return true;
1197 }
1198
1199 return false;
1200}
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm)
1216{
1217 pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
1218
1219 pRA_Table->firstconnect = false;
1220
1221}
1222
1223void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm)
1224{
1225 if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
1226 return;
1227
1228 odm_RSSIMonitorCheckCE(pDM_Odm);
1229
1230}
1231
1232static void FindMinimumRSSI(struct adapter *padapter)
1233{
1234 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
1235 struct dm_priv *pdmpriv = &pHalData->dmpriv;
1236 PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
1237
1238
1239
1240 if (
1241 (pDM_Odm->bLinked != true) &&
1242 (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
1243 ) {
1244 pdmpriv->MinUndecoratedPWDBForDM = 0;
1245
1246 } else
1247 pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
1248
1249
1250
1251}
1252
1253void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm)
1254{
1255 struct adapter *Adapter = pDM_Odm->Adapter;
1256 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1257 struct dm_priv *pdmpriv = &pHalData->dmpriv;
1258 int i;
1259 int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
1260 u8 sta_cnt = 0;
1261 u32 PWDB_rssi[NUM_STA] = {0};
1262 bool FirstConnect = false;
1263 pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
1264
1265 if (pDM_Odm->bLinked != true)
1266 return;
1267
1268 FirstConnect = (pDM_Odm->bLinked) && (pRA_Table->firstconnect == false);
1269 pRA_Table->firstconnect = pDM_Odm->bLinked;
1270
1271
1272 {
1273 struct sta_info *psta;
1274
1275 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
1276 psta = pDM_Odm->pODM_StaInfo[i];
1277 if (IS_STA_VALID(psta)) {
1278 if (IS_MCAST(psta->hwaddr))
1279 continue;
1280
1281 if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
1282 continue;
1283
1284 if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
1285 tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
1286
1287 if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
1288 tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
1289
1290 if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
1291 PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
1292 }
1293 }
1294
1295
1296
1297 for (i = 0; i < sta_cnt; i++) {
1298 if (PWDB_rssi[i] != (0)) {
1299 if (pHalData->fw_ractrl == true)
1300 rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
1301 }
1302 }
1303 }
1304
1305
1306
1307 if (tmpEntryMaxPWDB != 0)
1308 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
1309 else
1310 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
1311
1312 if (tmpEntryMinPWDB != 0xff)
1313 pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
1314 else
1315 pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
1316
1317 FindMinimumRSSI(Adapter);
1318
1319 pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
1320
1321}
1322
1323
1324
1325
1326
1327void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm)
1328{
1329 odm_TXPowerTrackingThermalMeterInit(pDM_Odm);
1330}
1331
1332static u8 getSwingIndex(PDM_ODM_T pDM_Odm)
1333{
1334 struct adapter *Adapter = pDM_Odm->Adapter;
1335 u8 i = 0;
1336 u32 bbSwing;
1337 u32 swingTableSize;
1338 u32 *pSwingTable;
1339
1340 bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
1341
1342 pSwingTable = OFDMSwingTable_New;
1343 swingTableSize = OFDM_TABLE_SIZE;
1344
1345 for (i = 0; i < swingTableSize; ++i) {
1346 u32 tableValue = pSwingTable[i];
1347
1348 if (tableValue >= 0x100000)
1349 tableValue >>= 22;
1350 if (bbSwing == tableValue)
1351 break;
1352 }
1353 return i;
1354}
1355
1356void odm_TXPowerTrackingThermalMeterInit(PDM_ODM_T pDM_Odm)
1357{
1358 u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
1359 u8 p = 0;
1360 struct adapter *Adapter = pDM_Odm->Adapter;
1361 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1362
1363
1364 struct dm_priv *pdmpriv = &pHalData->dmpriv;
1365
1366 pdmpriv->bTXPowerTracking = true;
1367 pdmpriv->TXPowercount = 0;
1368 pdmpriv->bTXPowerTrackingInit = false;
1369
1370 if (*(pDM_Odm->mp_mode) != 1)
1371 pdmpriv->TxPowerTrackControl = true;
1372 else
1373 pdmpriv->TxPowerTrackControl = false;
1374
1375
1376
1377
1378
1379 pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
1380 pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
1381 pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
1382
1383
1384 pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
1385 pDM_Odm->DefaultCckIndex = 20;
1386
1387 pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
1388 pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
1389
1390 for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
1391 pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
1392 pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
1393 pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
1394 pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
1395 pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
1396 }
1397
1398}
1399
1400
1401void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm)
1402{
1403 odm_TXPowerTrackingCheckCE(pDM_Odm);
1404}
1405
1406void odm_TXPowerTrackingCheckCE(PDM_ODM_T pDM_Odm)
1407{
1408 struct adapter *Adapter = pDM_Odm->Adapter;
1409
1410 if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
1411 return;
1412
1413 if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) {
1414 PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
1415
1416
1417
1418 pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
1419 return;
1420 } else {
1421
1422 ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
1423 pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
1424 }
1425}
1426
1427
1428
1429
1430void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm)
1431{
1432 pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
1433
1434 pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
1435 pDM_SWAT_Table->PreAntenna = MAIN_ANT;
1436 pDM_SWAT_Table->CurAntenna = MAIN_ANT;
1437 pDM_SWAT_Table->SWAS_NoLink_State = 0;
1438}
1439