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