This source file includes following definitions.
- ODM_DMInit
- ODM_DMWatchdog
- ODM_CmnInfoInit
- ODM_CmnInfoHook
- ODM_CmnInfoPtrArrayHook
- ODM_CmnInfoUpdate
- odm_CommonInfoSelfInit
- odm_CommonInfoSelfUpdate
- odm_CmnInfoInit_Debug
- odm_BasicDbgMessage
- odm_RateAdaptiveMaskInit
- ODM_Get_Rate_Bitmap
- odm_RefreshRateAdaptiveMask
- odm_RefreshRateAdaptiveMaskCE
- ODM_RAStateCheck
- odm_RSSIMonitorInit
- odm_RSSIMonitorCheck
- FindMinimumRSSI
- odm_RSSIMonitorCheckCE
- getSwingIndex
- odm_TXPowerTrackingInit
- ODM_TXPowerTrackingCheck
- odm_SwAntDetectInit
1
2
3
4
5
6
7
8 #include "odm_precomp.h"
9
10 static 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
25 u32 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
65 u8 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
101 u8 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
137 u32 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
183 u8 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
219 u8 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
255 u32 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
298 void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm);
299
300 void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm);
301
302 void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm);
303
304 void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm);
305
306
307
308
309
310
311
312
313
314
315
316
317
318 void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm);
319
320
321
322 void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm);
323
324 void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm);
325
326 void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm);
327
328 void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm);
329
330 void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
331
332
333
334 void odm_GlobalAdapterCheck(void);
335
336 void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm);
337
338 void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm);
339
340 void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm);
341
342
343 void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm);
344
345
346
347
348 #define RxDefaultAnt1 0x65a9
349 #define RxDefaultAnt2 0x569a
350
351 void odm_InitHybridAntDiv(PDM_ODM_T pDM_Odm);
352
353 bool odm_StaDefAntSel(
354 PDM_ODM_T pDM_Odm,
355 u32 OFDM_Ant1_Cnt,
356 u32 OFDM_Ant2_Cnt,
357 u32 CCK_Ant1_Cnt,
358 u32 CCK_Ant2_Cnt,
359 u8 *pDefAnt
360 );
361
362 void odm_SetRxIdleAnt(PDM_ODM_T pDM_Odm, u8 Ant, bool bDualPath);
363
364
365
366 void odm_HwAntDiv(PDM_ODM_T pDM_Odm);
367
368
369
370
371
372
373
374
375
376 void ODM_DMInit(PDM_ODM_T pDM_Odm)
377 {
378
379 odm_CommonInfoSelfInit(pDM_Odm);
380 odm_CmnInfoInit_Debug(pDM_Odm);
381 odm_DIGInit(pDM_Odm);
382 odm_NHMCounterStatisticsInit(pDM_Odm);
383 odm_AdaptivityInit(pDM_Odm);
384 odm_RateAdaptiveMaskInit(pDM_Odm);
385 ODM_CfoTrackingInit(pDM_Odm);
386 ODM_EdcaTurboInit(pDM_Odm);
387 odm_RSSIMonitorInit(pDM_Odm);
388 odm_TXPowerTrackingInit(pDM_Odm);
389
390 ODM_ClearTxPowerTrackingState(pDM_Odm);
391
392 if (*(pDM_Odm->mp_mode) != 1)
393 odm_PathDiversityInit(pDM_Odm);
394
395 odm_DynamicBBPowerSavingInit(pDM_Odm);
396 odm_DynamicTxPowerInit(pDM_Odm);
397
398 odm_SwAntDetectInit(pDM_Odm);
399 }
400
401
402
403
404
405
406 void ODM_DMWatchdog(PDM_ODM_T pDM_Odm)
407 {
408 odm_CommonInfoSelfUpdate(pDM_Odm);
409 odm_BasicDbgMessage(pDM_Odm);
410 odm_FalseAlarmCounterStatistics(pDM_Odm);
411 odm_NHMCounterStatistics(pDM_Odm);
412 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): RSSI = 0x%x\n", pDM_Odm->RSSI_Min));
413
414 odm_RSSIMonitorCheck(pDM_Odm);
415
416
417
418
419
420 if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE)
421
422
423
424
425 ) {
426 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n"));
427 ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
428 odm_DIGbyRSSI_LPS(pDM_Odm);
429 } else
430 odm_DIG(pDM_Odm);
431
432 {
433 pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
434
435 odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
436 }
437 odm_CCKPacketDetectionThresh(pDM_Odm);
438
439 if (*(pDM_Odm->pbPowerSaving) == true)
440 return;
441
442
443 odm_RefreshRateAdaptiveMask(pDM_Odm);
444 odm_EdcaTurboCheck(pDM_Odm);
445 odm_PathDiversity(pDM_Odm);
446 ODM_CfoTracking(pDM_Odm);
447
448 ODM_TXPowerTrackingCheck(pDM_Odm);
449
450
451
452
453
454 pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
455 }
456
457
458
459
460
461 void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value)
462 {
463
464
465
466 switch (CmnInfo) {
467
468
469
470 case ODM_CMNINFO_ABILITY:
471 pDM_Odm->SupportAbility = (u32)Value;
472 break;
473
474 case ODM_CMNINFO_RF_TYPE:
475 pDM_Odm->RFType = (u8)Value;
476 break;
477
478 case ODM_CMNINFO_PLATFORM:
479 pDM_Odm->SupportPlatform = (u8)Value;
480 break;
481
482 case ODM_CMNINFO_INTERFACE:
483 pDM_Odm->SupportInterface = (u8)Value;
484 break;
485
486 case ODM_CMNINFO_MP_TEST_CHIP:
487 pDM_Odm->bIsMPChip = (u8)Value;
488 break;
489
490 case ODM_CMNINFO_IC_TYPE:
491 pDM_Odm->SupportICType = Value;
492 break;
493
494 case ODM_CMNINFO_CUT_VER:
495 pDM_Odm->CutVersion = (u8)Value;
496 break;
497
498 case ODM_CMNINFO_FAB_VER:
499 pDM_Odm->FabVersion = (u8)Value;
500 break;
501
502 case ODM_CMNINFO_RFE_TYPE:
503 pDM_Odm->RFEType = (u8)Value;
504 break;
505
506 case ODM_CMNINFO_RF_ANTENNA_TYPE:
507 pDM_Odm->AntDivType = (u8)Value;
508 break;
509
510 case ODM_CMNINFO_BOARD_TYPE:
511 pDM_Odm->BoardType = (u8)Value;
512 break;
513
514 case ODM_CMNINFO_PACKAGE_TYPE:
515 pDM_Odm->PackageType = (u8)Value;
516 break;
517
518 case ODM_CMNINFO_EXT_LNA:
519 pDM_Odm->ExtLNA = (u8)Value;
520 break;
521
522 case ODM_CMNINFO_5G_EXT_LNA:
523 pDM_Odm->ExtLNA5G = (u8)Value;
524 break;
525
526 case ODM_CMNINFO_EXT_PA:
527 pDM_Odm->ExtPA = (u8)Value;
528 break;
529
530 case ODM_CMNINFO_5G_EXT_PA:
531 pDM_Odm->ExtPA5G = (u8)Value;
532 break;
533
534 case ODM_CMNINFO_GPA:
535 pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value;
536 break;
537 case ODM_CMNINFO_APA:
538 pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value;
539 break;
540 case ODM_CMNINFO_GLNA:
541 pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value;
542 break;
543 case ODM_CMNINFO_ALNA:
544 pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value;
545 break;
546
547 case ODM_CMNINFO_EXT_TRSW:
548 pDM_Odm->ExtTRSW = (u8)Value;
549 break;
550 case ODM_CMNINFO_PATCH_ID:
551 pDM_Odm->PatchID = (u8)Value;
552 break;
553 case ODM_CMNINFO_BINHCT_TEST:
554 pDM_Odm->bInHctTest = (bool)Value;
555 break;
556 case ODM_CMNINFO_BWIFI_TEST:
557 pDM_Odm->bWIFITest = (bool)Value;
558 break;
559
560 case ODM_CMNINFO_SMART_CONCURRENT:
561 pDM_Odm->bDualMacSmartConcurrent = (bool)Value;
562 break;
563
564
565 default:
566
567 break;
568 }
569
570 }
571
572
573 void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue)
574 {
575
576
577
578 switch (CmnInfo) {
579
580
581
582 case ODM_CMNINFO_MAC_PHY_MODE:
583 pDM_Odm->pMacPhyMode = pValue;
584 break;
585
586 case ODM_CMNINFO_TX_UNI:
587 pDM_Odm->pNumTxBytesUnicast = pValue;
588 break;
589
590 case ODM_CMNINFO_RX_UNI:
591 pDM_Odm->pNumRxBytesUnicast = pValue;
592 break;
593
594 case ODM_CMNINFO_WM_MODE:
595 pDM_Odm->pwirelessmode = pValue;
596 break;
597
598 case ODM_CMNINFO_BAND:
599 pDM_Odm->pBandType = pValue;
600 break;
601
602 case ODM_CMNINFO_SEC_CHNL_OFFSET:
603 pDM_Odm->pSecChOffset = pValue;
604 break;
605
606 case ODM_CMNINFO_SEC_MODE:
607 pDM_Odm->pSecurity = pValue;
608 break;
609
610 case ODM_CMNINFO_BW:
611 pDM_Odm->pBandWidth = pValue;
612 break;
613
614 case ODM_CMNINFO_CHNL:
615 pDM_Odm->pChannel = pValue;
616 break;
617
618 case ODM_CMNINFO_DMSP_GET_VALUE:
619 pDM_Odm->pbGetValueFromOtherMac = pValue;
620 break;
621
622 case ODM_CMNINFO_BUDDY_ADAPTOR:
623 pDM_Odm->pBuddyAdapter = pValue;
624 break;
625
626 case ODM_CMNINFO_DMSP_IS_MASTER:
627 pDM_Odm->pbMasterOfDMSP = pValue;
628 break;
629
630 case ODM_CMNINFO_SCAN:
631 pDM_Odm->pbScanInProcess = pValue;
632 break;
633
634 case ODM_CMNINFO_POWER_SAVING:
635 pDM_Odm->pbPowerSaving = pValue;
636 break;
637
638 case ODM_CMNINFO_ONE_PATH_CCA:
639 pDM_Odm->pOnePathCCA = pValue;
640 break;
641
642 case ODM_CMNINFO_DRV_STOP:
643 pDM_Odm->pbDriverStopped = pValue;
644 break;
645
646 case ODM_CMNINFO_PNP_IN:
647 pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = pValue;
648 break;
649
650 case ODM_CMNINFO_INIT_ON:
651 pDM_Odm->pinit_adpt_in_progress = pValue;
652 break;
653
654 case ODM_CMNINFO_ANT_TEST:
655 pDM_Odm->pAntennaTest = pValue;
656 break;
657
658 case ODM_CMNINFO_NET_CLOSED:
659 pDM_Odm->pbNet_closed = pValue;
660 break;
661
662 case ODM_CMNINFO_FORCED_RATE:
663 pDM_Odm->pForcedDataRate = pValue;
664 break;
665
666 case ODM_CMNINFO_FORCED_IGI_LB:
667 pDM_Odm->pu1ForcedIgiLb = pValue;
668 break;
669
670 case ODM_CMNINFO_MP_MODE:
671 pDM_Odm->mp_mode = pValue;
672 break;
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693 default:
694
695 break;
696 }
697
698 }
699
700
701 void ODM_CmnInfoPtrArrayHook(
702 PDM_ODM_T pDM_Odm,
703 ODM_CMNINFO_E CmnInfo,
704 u16 Index,
705 void *pValue
706 )
707 {
708
709
710
711 switch (CmnInfo) {
712
713
714
715 case ODM_CMNINFO_STA_STATUS:
716 pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
717 break;
718
719 default:
720
721 break;
722 }
723
724 }
725
726
727
728
729
730 void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value)
731 {
732
733
734
735 switch (CmnInfo) {
736 case ODM_CMNINFO_LINK_IN_PROGRESS:
737 pDM_Odm->bLinkInProcess = (bool)Value;
738 break;
739
740 case ODM_CMNINFO_ABILITY:
741 pDM_Odm->SupportAbility = (u32)Value;
742 break;
743
744 case ODM_CMNINFO_RF_TYPE:
745 pDM_Odm->RFType = (u8)Value;
746 break;
747
748 case ODM_CMNINFO_WIFI_DIRECT:
749 pDM_Odm->bWIFI_Direct = (bool)Value;
750 break;
751
752 case ODM_CMNINFO_WIFI_DISPLAY:
753 pDM_Odm->bWIFI_Display = (bool)Value;
754 break;
755
756 case ODM_CMNINFO_LINK:
757 pDM_Odm->bLinked = (bool)Value;
758 break;
759
760 case ODM_CMNINFO_STATION_STATE:
761 pDM_Odm->bsta_state = (bool)Value;
762 break;
763
764 case ODM_CMNINFO_RSSI_MIN:
765 pDM_Odm->RSSI_Min = (u8)Value;
766 break;
767
768 case ODM_CMNINFO_DBG_COMP:
769 pDM_Odm->DebugComponents = Value;
770 break;
771
772 case ODM_CMNINFO_DBG_LEVEL:
773 pDM_Odm->DebugLevel = (u32)Value;
774 break;
775 case ODM_CMNINFO_RA_THRESHOLD_HIGH:
776 pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value;
777 break;
778
779 case ODM_CMNINFO_RA_THRESHOLD_LOW:
780 pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value;
781 break;
782
783 case ODM_CMNINFO_BT_ENABLED:
784 pDM_Odm->bBtEnabled = (bool)Value;
785 break;
786
787 case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
788 pDM_Odm->bBtConnectProcess = (bool)Value;
789 break;
790
791 case ODM_CMNINFO_BT_HS_RSSI:
792 pDM_Odm->btHsRssi = (u8)Value;
793 break;
794
795 case ODM_CMNINFO_BT_OPERATION:
796 pDM_Odm->bBtHsOperation = (bool)Value;
797 break;
798
799 case ODM_CMNINFO_BT_LIMITED_DIG:
800 pDM_Odm->bBtLimitedDig = (bool)Value;
801 break;
802
803 case ODM_CMNINFO_BT_DISABLE_EDCA:
804 pDM_Odm->bBtDisableEdcaTurbo = (bool)Value;
805 break;
806
807
808
809
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 default:
837
838 break;
839 }
840
841
842 }
843
844 void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm)
845 {
846 pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm));
847 pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm));
848
849 ODM_InitDebugSetting(pDM_Odm);
850
851 pDM_Odm->TxRate = 0xFF;
852 }
853
854 void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm)
855 {
856 u8 EntryCnt = 0;
857 u8 i;
858 PSTA_INFO_T pEntry;
859
860 if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
861 if (*(pDM_Odm->pSecChOffset) == 1)
862 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2;
863 else if (*(pDM_Odm->pSecChOffset) == 2)
864 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2;
865 } else
866 pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
867
868 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
869 pEntry = pDM_Odm->pODM_StaInfo[i];
870 if (IS_STA_VALID(pEntry))
871 EntryCnt++;
872 }
873
874 if (EntryCnt == 1)
875 pDM_Odm->bOneEntryOnly = true;
876 else
877 pDM_Odm->bOneEntryOnly = false;
878 }
879
880 void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm)
881 {
882 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n"));
883 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform));
884 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility));
885 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface =%d\n", pDM_Odm->SupportInterface));
886 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType));
887 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion));
888 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion));
889 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType =%d\n", pDM_Odm->RFType));
890 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType));
891 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA));
892 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA));
893 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW));
894 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID =%d\n", pDM_Odm->PatchID));
895 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest));
896 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest));
897 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent));
898
899 }
900
901 void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm)
902 {
903 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n"));
904 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n",
905 pDM_Odm->bLinked, pDM_Odm->RSSI_Min));
906 ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
907 pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
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
935
936
937
938
939
940
941
942
943
944
945
946
947
948 void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm)
949 {
950 PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive;
951
952 pOdmRA->Type = DM_Type_ByDriver;
953 if (pOdmRA->Type == DM_Type_ByDriver)
954 pDM_Odm->bUseRAMask = true;
955 else
956 pDM_Odm->bUseRAMask = false;
957
958 pOdmRA->RATRState = DM_RATR_STA_INIT;
959 pOdmRA->LdpcThres = 35;
960 pOdmRA->bUseLdpc = false;
961 pOdmRA->HighRSSIThresh = 50;
962 pOdmRA->LowRSSIThresh = 20;
963 }
964
965 u32 ODM_Get_Rate_Bitmap(
966 PDM_ODM_T pDM_Odm,
967 u32 macid,
968 u32 ra_mask,
969 u8 rssi_level
970 )
971 {
972 PSTA_INFO_T pEntry;
973 u32 rate_bitmap = 0;
974 u8 WirelessMode;
975
976 pEntry = pDM_Odm->pODM_StaInfo[macid];
977 if (!IS_STA_VALID(pEntry))
978 return ra_mask;
979
980 WirelessMode = pEntry->wireless_mode;
981
982 switch (WirelessMode) {
983 case ODM_WM_B:
984 if (ra_mask & 0x0000000c)
985 rate_bitmap = 0x0000000d;
986 else
987 rate_bitmap = 0x0000000f;
988 break;
989
990 case (ODM_WM_G):
991 case (ODM_WM_A):
992 if (rssi_level == DM_RATR_STA_HIGH)
993 rate_bitmap = 0x00000f00;
994 else
995 rate_bitmap = 0x00000ff0;
996 break;
997
998 case (ODM_WM_B|ODM_WM_G):
999 if (rssi_level == DM_RATR_STA_HIGH)
1000 rate_bitmap = 0x00000f00;
1001 else if (rssi_level == DM_RATR_STA_MIDDLE)
1002 rate_bitmap = 0x00000ff0;
1003 else
1004 rate_bitmap = 0x00000ff5;
1005 break;
1006
1007 case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
1008 case (ODM_WM_B|ODM_WM_N24G):
1009 case (ODM_WM_G|ODM_WM_N24G):
1010 case (ODM_WM_A|ODM_WM_N5G):
1011 if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
1012 if (rssi_level == DM_RATR_STA_HIGH)
1013 rate_bitmap = 0x000f0000;
1014 else if (rssi_level == DM_RATR_STA_MIDDLE)
1015 rate_bitmap = 0x000ff000;
1016 else {
1017 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
1018 rate_bitmap = 0x000ff015;
1019 else
1020 rate_bitmap = 0x000ff005;
1021 }
1022 } else {
1023 if (rssi_level == DM_RATR_STA_HIGH)
1024 rate_bitmap = 0x0f8f0000;
1025 else if (rssi_level == DM_RATR_STA_MIDDLE)
1026 rate_bitmap = 0x0f8ff000;
1027 else {
1028 if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
1029 rate_bitmap = 0x0f8ff015;
1030 else
1031 rate_bitmap = 0x0f8ff005;
1032 }
1033 }
1034 break;
1035
1036 case (ODM_WM_AC|ODM_WM_G):
1037 if (rssi_level == 1)
1038 rate_bitmap = 0xfc3f0000;
1039 else if (rssi_level == 2)
1040 rate_bitmap = 0xfffff000;
1041 else
1042 rate_bitmap = 0xffffffff;
1043 break;
1044
1045 case (ODM_WM_AC|ODM_WM_A):
1046
1047 if (pDM_Odm->RFType == RF_1T1R) {
1048 if (rssi_level == 1)
1049 rate_bitmap = 0x003f8000;
1050 else if (rssi_level == 2)
1051 rate_bitmap = 0x003ff000;
1052 else
1053 rate_bitmap = 0x003ff010;
1054 } else {
1055 if (rssi_level == 1)
1056 rate_bitmap = 0xfe3f8000;
1057 else if (rssi_level == 2)
1058 rate_bitmap = 0xfffff000;
1059 else
1060 rate_bitmap = 0xfffff010;
1061 }
1062 break;
1063
1064 default:
1065 if (pDM_Odm->RFType == RF_1T2R)
1066 rate_bitmap = 0x000fffff;
1067 else
1068 rate_bitmap = 0x0fffffff;
1069 break;
1070 }
1071
1072
1073 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));
1074
1075 return ra_mask & rate_bitmap;
1076
1077 }
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096 void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm)
1097 {
1098
1099 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
1100 if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) {
1101 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
1102 return;
1103 }
1104 odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
1105 }
1106
1107 void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm)
1108 {
1109 u8 i;
1110 struct adapter *padapter = pDM_Odm->Adapter;
1111
1112 if (padapter->bDriverStopped) {
1113 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
1114 return;
1115 }
1116
1117 if (!pDM_Odm->bUseRAMask) {
1118 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
1119 return;
1120 }
1121
1122
1123
1124 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
1125 PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
1126
1127 if (IS_STA_VALID(pstat)) {
1128 if (IS_MCAST(pstat->hwaddr))
1129 continue;
1130 if (IS_MCAST(pstat->hwaddr))
1131 continue;
1132
1133 if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
1134 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));
1135
1136 rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
1137 }
1138
1139 }
1140 }
1141 }
1142
1143
1144
1145 bool ODM_RAStateCheck(
1146 PDM_ODM_T pDM_Odm,
1147 s32 RSSI,
1148 bool bForceUpdate,
1149 u8 *pRATRState
1150 )
1151 {
1152 PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
1153 const u8 GoUpGap = 5;
1154 u8 HighRSSIThreshForRA = pRA->HighRSSIThresh;
1155 u8 LowRSSIThreshForRA = pRA->LowRSSIThresh;
1156 u8 RATRState;
1157
1158
1159
1160
1161 switch (*pRATRState) {
1162 case DM_RATR_STA_INIT:
1163 case DM_RATR_STA_HIGH:
1164 break;
1165
1166 case DM_RATR_STA_MIDDLE:
1167 HighRSSIThreshForRA += GoUpGap;
1168 break;
1169
1170 case DM_RATR_STA_LOW:
1171 HighRSSIThreshForRA += GoUpGap;
1172 LowRSSIThreshForRA += GoUpGap;
1173 break;
1174
1175 default:
1176 ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
1177 break;
1178 }
1179
1180
1181 if (RSSI > HighRSSIThreshForRA)
1182 RATRState = DM_RATR_STA_HIGH;
1183 else if (RSSI > LowRSSIThreshForRA)
1184 RATRState = DM_RATR_STA_MIDDLE;
1185 else
1186 RATRState = DM_RATR_STA_LOW;
1187
1188
1189 if (*pRATRState != RATRState || bForceUpdate) {
1190 ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState));
1191 *pRATRState = RATRState;
1192 return true;
1193 }
1194
1195 return false;
1196 }
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211 void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm)
1212 {
1213 pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
1214
1215 pRA_Table->firstconnect = false;
1216
1217 }
1218
1219 void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm)
1220 {
1221 if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
1222 return;
1223
1224 odm_RSSIMonitorCheckCE(pDM_Odm);
1225
1226 }
1227
1228 static void FindMinimumRSSI(struct adapter *padapter)
1229 {
1230 struct hal_com_data *pHalData = GET_HAL_DATA(padapter);
1231 struct dm_priv *pdmpriv = &pHalData->dmpriv;
1232 PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
1233
1234
1235
1236 if (
1237 (pDM_Odm->bLinked != true) &&
1238 (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)
1239 ) {
1240 pdmpriv->MinUndecoratedPWDBForDM = 0;
1241
1242 } else
1243 pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
1244
1245
1246
1247 }
1248
1249 void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm)
1250 {
1251 struct adapter *Adapter = pDM_Odm->Adapter;
1252 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1253 struct dm_priv *pdmpriv = &pHalData->dmpriv;
1254 int i;
1255 int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
1256 u8 sta_cnt = 0;
1257 u32 PWDB_rssi[NUM_STA] = {0};
1258 pRA_T pRA_Table = &pDM_Odm->DM_RA_Table;
1259
1260 if (pDM_Odm->bLinked != true)
1261 return;
1262
1263 pRA_Table->firstconnect = pDM_Odm->bLinked;
1264
1265
1266 {
1267 struct sta_info *psta;
1268
1269 for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
1270 psta = pDM_Odm->pODM_StaInfo[i];
1271 if (IS_STA_VALID(psta)) {
1272 if (IS_MCAST(psta->hwaddr))
1273 continue;
1274
1275 if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))
1276 continue;
1277
1278 if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
1279 tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
1280
1281 if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
1282 tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
1283
1284 if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
1285 PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
1286 }
1287 }
1288
1289
1290
1291 for (i = 0; i < sta_cnt; i++) {
1292 if (PWDB_rssi[i] != (0)) {
1293 if (pHalData->fw_ractrl == true)
1294 rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
1295 }
1296 }
1297 }
1298
1299
1300
1301 if (tmpEntryMaxPWDB != 0)
1302 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
1303 else
1304 pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
1305
1306 if (tmpEntryMinPWDB != 0xff)
1307 pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
1308 else
1309 pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
1310
1311 FindMinimumRSSI(Adapter);
1312
1313 pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM;
1314
1315 }
1316
1317
1318
1319
1320
1321 static u8 getSwingIndex(PDM_ODM_T pDM_Odm)
1322 {
1323 struct adapter *Adapter = pDM_Odm->Adapter;
1324 u8 i = 0;
1325 u32 bbSwing;
1326 u32 swingTableSize;
1327 u32 *pSwingTable;
1328
1329 bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000);
1330
1331 pSwingTable = OFDMSwingTable_New;
1332 swingTableSize = OFDM_TABLE_SIZE;
1333
1334 for (i = 0; i < swingTableSize; ++i) {
1335 u32 tableValue = pSwingTable[i];
1336
1337 if (tableValue >= 0x100000)
1338 tableValue >>= 22;
1339 if (bbSwing == tableValue)
1340 break;
1341 }
1342 return i;
1343 }
1344
1345 void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm)
1346 {
1347 u8 defaultSwingIndex = getSwingIndex(pDM_Odm);
1348 u8 p = 0;
1349 struct adapter *Adapter = pDM_Odm->Adapter;
1350 struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
1351
1352
1353 struct dm_priv *pdmpriv = &pHalData->dmpriv;
1354
1355 pdmpriv->bTXPowerTracking = true;
1356 pdmpriv->TXPowercount = 0;
1357 pdmpriv->bTXPowerTrackingInit = false;
1358
1359 if (*(pDM_Odm->mp_mode) != 1)
1360 pdmpriv->TxPowerTrackControl = true;
1361 else
1362 pdmpriv->TxPowerTrackControl = false;
1363
1364
1365
1366
1367
1368 pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
1369 pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
1370 pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
1371
1372
1373 pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex >= OFDM_TABLE_SIZE) ? 30 : defaultSwingIndex;
1374 pDM_Odm->DefaultCckIndex = 20;
1375
1376 pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
1377 pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
1378
1379 for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
1380 pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
1381 pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
1382 pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
1383 pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
1384 pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
1385 }
1386
1387 }
1388
1389 void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm)
1390 {
1391 struct adapter *Adapter = pDM_Odm->Adapter;
1392
1393 if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
1394 return;
1395
1396 if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) {
1397 PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
1398
1399
1400
1401 pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
1402 return;
1403 } else {
1404
1405 ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
1406 pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
1407 }
1408 }
1409
1410
1411
1412
1413 void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm)
1414 {
1415 pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
1416
1417 pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control);
1418 pDM_SWAT_Table->PreAntenna = MAIN_ANT;
1419 pDM_SWAT_Table->CurAntenna = MAIN_ANT;
1420 pDM_SWAT_Table->SWAS_NoLink_State = 0;
1421 }