1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
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
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
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
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
|
//============================================================
// File Name: HalComDMOutSrc.c
//
// Description:
//
// This file is for 92CE/92CU/88EE/88EU outsource dynamic mechanism for partner.
//
//
//============================================================
//============================================================
// include files
//============================================================
#include "Mp_Precomp.h"
//
// 20112/01/31 MH HW team will use ODM module to do all dynamic scheme.
//
#if 0
const u2Byte dB_Invert_Table[8][12] = {
{ 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4},
{ 4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16},
{ 18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63},
{ 71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251},
{ 282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000},
{ 1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981},
{ 4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, 15849},
{ 17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, 56234, 65535}};
// 20100515 Joseph: Add global variable to keep temporary scan list for antenna switching test.
//u1Byte tmpNumBssDesc;
//RT_WLAN_BSS tmpbssDesc[MAX_BSS_DESC];
static u4Byte edca_setting_DL[HT_IOT_PEER_MAX] =
// UNKNOWN REALTEK_90 REALTEK_92SE BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP(UpLink/Rx)
{ 0xa44f, 0x5ea44f, 0x5e4322, 0x5ea42b, 0xa44f, 0x3ea42b, 0x5ea630, 0xa44f, 0xa42b, 0xa42b};
static u4Byte edca_setting_DL_GMode[HT_IOT_PEER_MAX] =
// UNKNOWN REALTEK_90 REALTEK_92SE BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP
{ 0x4322, 0xa44f, 0x5e4322, 0xa42b, 0x5e4322, 0x4322, 0xa42b, 0xa44f, 0x5e4322, 0x5ea42b};
static u4Byte edca_setting_UL[HT_IOT_PEER_MAX] =
// UNKNOWN REALTEK_90 REALTEK_92SE BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP(DownLink/Tx)
{ 0x5e4322, 0xa44f, 0x5e4322, 0x5ea32b, 0x5ea422, 0x5ea322, 0x3ea430, 0x5ea44f, 0x5e4322, 0x5e4322};
//============================================================
//============================================================
// Global var
//============================================================
u4Byte OFDMSwingTable[OFDM_TABLE_SIZE_92D] = {
0x7f8001fe, // 0, +6.0dB
0x788001e2, // 1, +5.5dB
0x71c001c7, // 2, +5.0dB
0x6b8001ae, // 3, +4.5dB
0x65400195, // 4, +4.0dB
0x5fc0017f, // 5, +3.5dB
0x5a400169, // 6, +3.0dB
0x55400155, // 7, +2.5dB
0x50800142, // 8, +2.0dB
0x4c000130, // 9, +1.5dB
0x47c0011f, // 10, +1.0dB
0x43c0010f, // 11, +0.5dB
0x40000100, // 12, +0dB
0x3c8000f2, // 13, -0.5dB
0x390000e4, // 14, -1.0dB
0x35c000d7, // 15, -1.5dB
0x32c000cb, // 16, -2.0dB
0x300000c0, // 17, -2.5dB
0x2d4000b5, // 18, -3.0dB
0x2ac000ab, // 19, -3.5dB
0x288000a2, // 20, -4.0dB
0x26000098, // 21, -4.5dB
0x24000090, // 22, -5.0dB
0x22000088, // 23, -5.5dB
0x20000080, // 24, -6.0dB
0x1e400079, // 25, -6.5dB
0x1c800072, // 26, -7.0dB
0x1b00006c, // 27. -7.5dB
0x19800066, // 28, -8.0dB
0x18000060, // 29, -8.5dB
0x16c0005b, // 30, -9.0dB
0x15800056, // 31, -9.5dB
0x14400051, // 32, -10.0dB
0x1300004c, // 33, -10.5dB
0x12000048, // 34, -11.0dB
0x11000044, // 35, -11.5dB
0x10000040, // 36, -12.0dB
0x0f00003c,// 37, -12.5dB
0x0e400039,// 38, -13.0dB
0x0d800036,// 39, -13.5dB
0x0cc00033,// 40, -14.0dB
0x0c000030,// 41, -14.5dB
0x0b40002d,// 42, -15.0dB
};
u1Byte CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = {
{0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, // 0, +0dB
{0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, // 1, -0.5dB
{0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 2, -1.0dB
{0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, // 3, -1.5dB
{0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 4, -2.0dB
{0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, // 5, -2.5dB
{0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 6, -3.0dB
{0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, // 7, -3.5dB
{0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 8, -4.0dB
{0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, // 9, -4.5dB
{0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 10, -5.0dB
{0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, // 11, -5.5dB
{0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 12, -6.0dB
{0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, // 13, -6.5dB
{0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 14, -7.0dB
{0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, // 15, -7.5dB
{0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 16, -8.0dB
{0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, // 17, -8.5dB
{0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 18, -9.0dB
{0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 19, -9.5dB
{0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 20, -10.0dB
{0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, // 21, -10.5dB
{0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, // 22, -11.0dB
{0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, // 23, -11.5dB
{0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, // 24, -12.0dB
{0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, // 25, -12.5dB
{0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, // 26, -13.0dB
{0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, // 27, -13.5dB
{0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, // 28, -14.0dB
{0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, // 29, -14.5dB
{0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, // 30, -15.0dB
{0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, // 31, -15.5dB
{0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} // 32, -16.0dB
};
u1Byte CCKSwingTable_Ch14 [CCK_TABLE_SIZE][8]= {
{0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, // 0, +0dB
{0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, // 1, -0.5dB
{0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 2, -1.0dB
{0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, // 3, -1.5dB
{0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 4, -2.0dB
{0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, // 5, -2.5dB
{0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 6, -3.0dB
{0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, // 7, -3.5dB
{0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 8, -4.0dB
{0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, // 9, -4.5dB
{0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 10, -5.0dB
{0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 11, -5.5dB
{0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 12, -6.0dB
{0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, // 13, -6.5dB
{0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 14, -7.0dB
{0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 15, -7.5dB
{0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 16, -8.0dB
{0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 17, -8.5dB
{0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 18, -9.0dB
{0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 19, -9.5dB
{0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 20, -10.0dB
{0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, // 21, -10.5dB
{0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, // 22, -11.0dB
{0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, // 23, -11.5dB
{0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, // 24, -12.0dB
{0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, // 25, -12.5dB
{0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, // 26, -13.0dB
{0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, // 27, -13.5dB
{0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, // 28, -14.0dB
{0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, // 29, -14.5dB
{0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, // 30, -15.0dB
{0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, // 31, -15.5dB
{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} // 32, -16.0dB
};
//#pragma mark --DIG --
//3============================================================
//3 DIG
//3============================================================
/*-----------------------------------------------------------------------------
* Function: odm_DIGInit()
*
* Overview: Set DIG scheme init value.
*
* Input: NONE
*
* Output: NONE
*
* Return: NONE
*
* Revised History:
* When Who Remark
*
*---------------------------------------------------------------------------*/
void odm_DIGInit(
IN PADAPTER pAdapter
)
{
pDIG_T pDM_DigTable = &pAdapter->DM_DigTable;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
pDM_DigTable->Dig_Enable_Flag = TRUE;
pDM_DigTable->Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX;
pDM_DigTable->CurIGValue = 0x20;
pDM_DigTable->PreIGValue = 0x0;
pDM_DigTable->CurSTAConnectState = pDM_DigTable->PreSTAConnectState = DIG_STA_DISCONNECT;
pDM_DigTable->CurMultiSTAConnectState = DIG_MultiSTA_DISCONNECT;
pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW;
pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH;
pDM_DigTable->FALowThresh = DM_FALSEALARM_THRESH_LOW;
pDM_DigTable->FAHighThresh = DM_FALSEALARM_THRESH_HIGH;
//vivi note! 92d and 92c has different value
/*if(IS_HARDWARE_TYPE_8192D(pAdapter))
{
pDM_DigTable->rx_gain_range_max = DM_DIG_FA_UPPER;
pDM_DigTable->rx_gain_range_min = DM_DIG_FA_LOWER;
}*/
//else
//{
pDM_DigTable->rx_gain_range_max = DM_DIG_MAX;
pDM_DigTable->rx_gain_range_min = DM_DIG_MIN;
//}
pDM_DigTable->BackoffVal = DM_DIG_BACKOFF_DEFAULT;
pDM_DigTable->BackoffVal_range_max = DM_DIG_BACKOFF_MAX;
pDM_DigTable->BackoffVal_range_min = DM_DIG_BACKOFF_MIN;
//vivi note! 92d and 92c has different value
/*if(IS_HARDWARE_TYPE_8192D(pAdapter))
{
pDM_DigTable->PreCCKPDState = CCK_PD_STAGE_LowRssi;
pDM_DigTable->CurCCKPDState = CCK_PD_STAGE_MAX;
pDM_DigTable->ForbiddenIGI = DM_DIG_FA_LOWER;
}*/
//else
//{
pDM_DigTable->PreCCKPDState = CCK_PD_STAGE_MAX;
pDM_DigTable->CurCCKPDState = CCK_PD_STAGE_LowRssi;
pDM_DigTable->ForbiddenIGI = DM_DIG_MIN;
pDM_DigTable->DeadZone = DM_DIG_MIN;
//}
pDM_DigTable->LargeFAHit = 0;
pDM_DigTable->Recover_cnt = 0;
pDM_DigTable->DIG_Dynamic_MIN_0 = 0x25;
pDM_DigTable->DIG_Dynamic_MIN_1 = 0x25;
pDM_DigTable->bMediaConnect_0 =FALSE;
pDM_DigTable->bMediaConnect_1 =FALSE;
pDM_DigTable->preearly= 2;
pDM_DigTable->curearly= 1;
// The EDCCA value should be adjusted according to the DIG value. 2011.11.25. by tynli.
pHalData->bPreEdccaEnable = FALSE;
}
VOID
ODM_Write_DIG(
IN PADAPTER pAdapter
)
{
pDIG_T pDM_DigTable = &pAdapter->DM_DigTable;
//RT_TRACE( COMP_DIG, DBG_LOUD, ("CurIGValue = 0x%x, PreIGValue = 0x%x, BackoffVal = %d\n",
// pDM_DigTable->CurIGValue, pDM_DigTable->PreIGValue, pDM_DigTable->BackoffVal));
RT_TRACE( COMP_DIG, DBG_LOUD, ("CurIGValue = 0x%x, PreIGValue = 0x%x\n",
pDM_DigTable->CurIGValue, pDM_DigTable->PreIGValue));
#if 0 // Fix DIG for NdisTest in the house --------------------------
//PHY_SetBBReg(pAdapter, rOFDM0_RxDetector1, 0x7f, 0x4c);
//PHY_SetBBReg(pAdapter, rOFDM0_XAAGCCore1, 0x7f, 0x4e);
//PHY_SetBBReg(pAdapter, rOFDM0_XBAGCCore1, 0x7f, 0x4e);
return;
#endif // -------------------------------------------------
if (pDM_DigTable->Dig_Enable_Flag == FALSE)
{
RT_TRACE( COMP_DIG, DBG_LOUD, ("DIG is disabled\n"));
//pDM_DigTable->PreIGValue = 0x17;
return;
}
if(pDM_DigTable->PreIGValue != pDM_DigTable->CurIGValue)
{
// Set initial gain.
// 20100211 Joseph: Set only BIT0~BIT6 for DIG. BIT7 is the function switch of Antenna diversity.
// Just not to modified it for SD3 testing.
//PHY_SetBBReg(pAdapter, rOFDM0_XAAGCCore1, bMaskByte0, DM_DigTable.CurIGValue);
//PHY_SetBBReg(pAdapter, rOFDM0_XBAGCCore1, bMaskByte0, DM_DigTable.CurIGValue);
PHY_SetBBReg(pAdapter, rOFDM0_XAAGCCore1, 0x7f, pDM_DigTable->CurIGValue);
if(!IS_HARDWARE_TYPE_8188E(pAdapter))
PHY_SetBBReg(pAdapter, rOFDM0_XBAGCCore1, 0x7f, pDM_DigTable->CurIGValue);
// 2011/07/12 MH According to Luke.Lee's suggestion, we need to restore 0xc50 by driver
// after scan process.
//if(pDM_DigTable->CurIGValue != 0x17)
pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue;
}
// Adjust EDCCA.
if(!IS_HARDWARE_TYPE_8188E(pAdapter))
odm_DynamicEDCCA(pAdapter);
}
//#pragma mark -- Init Gain --
//3============================================================
//3 Initial Gain
//3============================================================
u1Byte
odm_initial_gain_MinPWDB(
IN PADAPTER pAdapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
s4Byte Rssi_val_min = 0;
#if 0
pDIG_T pDM_DigTable = &pAdapter->DM_DigTable;
if( (pDM_DigTable->CurMultiSTAConnectState == DIG_MultiSTA_CONNECT) &&
(pDM_DigTable->CurSTAConnectState == DIG_STA_CONNECT) )
{
if(pHalData->EntryMinUndecoratedSmoothedPWDB != 0)
Rssi_val_min = (pHalData->EntryMinUndecoratedSmoothedPWDB > pHalData->UndecoratedSmoothedPWDB)?
pHalData->UndecoratedSmoothedPWDB:pHalData->EntryMinUndecoratedSmoothedPWDB;
else
Rssi_val_min = pHalData->UndecoratedSmoothedPWDB;
}
else if( pDM_DigTable->CurSTAConnectState == DIG_STA_CONNECT ||
pDM_DigTable->CurSTAConnectState == DIG_STA_BEFORE_CONNECT)
Rssi_val_min = pHalData->UndecoratedSmoothedPWDB;
else if(pDM_DigTable->CurMultiSTAConnectState == DIG_MultiSTA_CONNECT)
Rssi_val_min = pHalData->EntryMinUndecoratedSmoothedPWDB;
#endif
if(pHalData->EntryMinUndecoratedSmoothedPWDB != 0)
Rssi_val_min = (pHalData->EntryMinUndecoratedSmoothedPWDB > pHalData->UndecoratedSmoothedPWDB)?
pHalData->UndecoratedSmoothedPWDB:pHalData->EntryMinUndecoratedSmoothedPWDB;
else
Rssi_val_min = pHalData->UndecoratedSmoothedPWDB;
return (u1Byte)Rssi_val_min;
}
VOID
ODM_ChangeDynamicInitGainThresh(
IN PADAPTER pAdapter,
IN INT32 DM_Type,
IN INT32 DM_Value)
{
pDIG_T pDM_DigTable = &pAdapter->DM_DigTable;
if (DM_Type == DIG_TYPE_THRESH_HIGH)
{
pDM_DigTable->RssiHighThresh = DM_Value;
}
else if (DM_Type == DIG_TYPE_THRESH_LOW)
{
pDM_DigTable->RssiLowThresh = DM_Value;
}
else if (DM_Type == DIG_TYPE_ENABLE)
{
pDM_DigTable->Dig_Enable_Flag = TRUE;
}
else if (DM_Type == DIG_TYPE_DISABLE)
{
pDM_DigTable->Dig_Enable_Flag = FALSE;
}
else if (DM_Type == DIG_TYPE_BACKOFF)
{
if(DM_Value > 30)
DM_Value = 30;
pDM_DigTable->BackoffVal = (u1Byte)DM_Value;
}
else if(DM_Type == DIG_TYPE_RX_GAIN_MIN)
{
if(DM_Value == 0)
DM_Value = 0x1;
pDM_DigTable->rx_gain_range_min = (u1Byte)DM_Value;
}
else if(DM_Type == DIG_TYPE_RX_GAIN_MAX)
{
if(DM_Value > 0x50)
DM_Value = 0x50;
pDM_DigTable->rx_gain_range_max = (u1Byte)DM_Value;
}
} /* DM_ChangeDynamicInitGainThresh */
//#pragma mark --Tx Power --
//3============================================================
//3 Dynamic Tx Power
//3============================================================
VOID
odm_SavePowerIndex(IN PADAPTER Adapter)
{
u1Byte index;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
u4Byte Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
for(index = 0; index< 6; index++)
pHalData->PowerIndex_backup[index] = PlatformEFIORead1Byte(Adapter, Power_Index_REG[index]);
}
VOID
odm_RestorePowerIndex(IN PADAPTER Adapter)
{
u1Byte index;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
u4Byte Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
for(index = 0; index< 6; index++)
PlatformEFIOWrite1Byte(Adapter, Power_Index_REG[index], pHalData->PowerIndex_backup[index]);
}
VOID
odm_WritePowerIndex(
IN PADAPTER Adapter,
IN u1Byte Value)
{
u1Byte index;
u4Byte Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
for(index = 0; index< 6; index++)
PlatformEFIOWrite1Byte(Adapter, Power_Index_REG[index], Value);
}
void odm_InitDynamicTxPower(IN PADAPTER Adapter)
{
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
#if DEV_BUS_TYPE==RT_USB_INTERFACE
if(RT_GetInterfaceSelection(Adapter) == INTF_SEL1_USB_High_Power)
{
odm_SavePowerIndex(Adapter);
pMgntInfo->bDynamicTxPowerEnable = TRUE;
}
else
#else
pMgntInfo->bDynamicTxPowerEnable = FALSE;
#endif
if(IS_HARDWARE_TYPE_8192D(Adapter) && (Adapter->MgntInfo.FirmwareVersion > 0x14))
{
RT_TRACE(COMP_INIT, DBG_LOUD, ("Dynamic Tx Power is enabled by FW \n"));
pMgntInfo->bDynamicTxPowerEnable = FALSE;
}
pHalData->LastDTPLvl = TxHighPwrLevel_Normal;
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
}
void odm_DynamicTxPower (IN PADAPTER Adapter)
{
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
s4Byte UndecoratedSmoothedPWDB;
// STA not connected and AP not connected
if((!pMgntInfo->bMediaConnect) &&
(pHalData->EntryMinUndecoratedSmoothedPWDB == 0))
{
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("Not connected to any \n"));
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
//the LastDTPlvl should reset when disconnect,
//otherwise the tx power level wouldn't change when disconnect and connect again.
// Maddest 20091220.
pHalData->LastDTPLvl=TxHighPwrLevel_Normal;
return;
}
#if (INTEL_PROXIMITY_SUPPORT == 1)
// Intel set fixed tx power
if(pMgntInfo->IntelProximityModeInfo.PowerOutput > 0)
{
switch(pMgntInfo->IntelProximityModeInfo.PowerOutput){
case 1:
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_100\n"));
break;
case 2:
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_70;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_70\n"));
break;
case 3:
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_50;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_50\n"));
break;
case 4:
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_35;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_35\n"));
break;
case 5:
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_15;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_15\n"));
break;
default:
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_100\n"));
break;
}
}
else
#endif
{
if( (pMgntInfo->bDynamicTxPowerEnable != TRUE) ||
(pHalData->DMFlag & HAL_DM_HIPWR_DISABLE) ||
pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)
{
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
}
else
{
if(pMgntInfo->bMediaConnect) // Default port
{
if(ACTING_AS_AP(Adapter) || ACTING_AS_IBSS(Adapter))
{
UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
}
else
{
UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
}
}
else // associated entry pwdb
{
UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
}
if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
{
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
}
else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
{
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
}
else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
{
pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
}
}
}
if( pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl )
{
RT_TRACE(COMP_HIPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192C() Channel = %d \n" , pHalData->CurrentChannel));
#if DEV_BUS_TYPE != RT_SDIO_INTERFACE
if(IS_HARDWARE_TYPE_8812(Adapter))
{
PHY_SetTxPowerLevel8812(Adapter, pHalData->CurrentChannel);
}
else
#endif
if(IS_HARDWARE_TYPE_8188E(Adapter))
{
PHY_SetTxPowerLevel8188E(Adapter, pHalData->CurrentChannel);
}
else if(IS_HARDWARE_TYPE_8192C(Adapter))
{
PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
}
if( (pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Normal) &&
(pHalData->LastDTPLvl == TxHighPwrLevel_Level1 || pHalData->LastDTPLvl == TxHighPwrLevel_Level2)) //TxHighPwrLevel_Normal
odm_RestorePowerIndex(Adapter);
else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
odm_WritePowerIndex(Adapter, 0x14);
else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2)
odm_WritePowerIndex(Adapter, 0x10);
}
pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl;
}
//============================================================
//#pragma mark --EDCA Turbo --
//3============================================================
//3 EDCA Turbo
//3============================================================
void
ODM_InitEdcaTurbo(
IN PADAPTER Adapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
pHalData->bCurrentTurboEDCA = FALSE;
pHalData->bIsAnyNonBEPkts = FALSE;
pHalData->bIsCurRDLState = FALSE;
} // ODM_InitEdcaTurbo
void
odm_CheckEdcaTurbo(
IN PADAPTER Adapter
)
{
PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
PADAPTER pExtAdapter = NULL;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
PSTA_QOS pStaQos = Adapter->MgntInfo.pStaQos;
// Keep past Tx/Rx packet count for RT-to-RT EDCA turbo.
//static u8Byte lastTxOkCnt = 0;
//static u8Byte lastRxOkCnt = 0;
u8Byte curTxOkCnt = 0;
u8Byte curRxOkCnt = 0;
u4Byte EDCA_BE_UL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_UL[pMgntInfo->IOTPeer];
u4Byte EDCA_BE_DL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_DL[pMgntInfo->IOTPeer];
//[Win7 Count Tx/Rx statistic for Extension Port] odm_CheckEdcaTurbo's Adapter is always Default. 2009.08.20, by Bohn
//static u8Byte Ext_lastTxOkCnt = 0;
//static u8Byte Ext_lastRxOkCnt = 0;
u8Byte Ext_curTxOkCnt = 0;
u8Byte Ext_curRxOkCnt = 0;
//For future Win7 Enable Default Port to modify AMPDU size dynamically, 2009.08.20, Bohn.
u1Byte TwoPortStatus = (u1Byte)TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE;
pExtAdapter = GetFirstExtAdapter(Adapter);
if(pExtAdapter == NULL) pExtAdapter = pDefaultAdapter;
#ifndef UNDER_CE
if(BT_DisableEDCATurbo(Adapter))
{
return;
}
#endif
if(IS_HARDWARE_TYPE_8192D(Adapter))
{
if(IS_92D_SINGLEPHY(pHalData->VersionID))
{
EDCA_BE_UL = 0x60a42b;
EDCA_BE_DL = 0x60a42b;
}
else
{
EDCA_BE_UL = 0x6ea42b;
EDCA_BE_DL = 0x6ea42b;
}
// IOT.
#if DEV_BUS_TYPE==RT_PCI_INTERFACE
if(pMgntInfo->IOTPeer == HT_IOT_PEER_CISCO && IS_WIRELESS_MODE_N_24G(Adapter))
{
// Suggested by SD3 Cherry. Added by tynli. 2011.12.19.
EDCA_BE_DL = edca_setting_DL[pMgntInfo->IOTPeer];
EDCA_BE_UL = 0x5ea430;
}
#endif
}
else
{
#if DEV_BUS_TYPE==RT_PCI_INTERFACE
if(IS_92C_SERIAL(pHalData->VersionID))
{
EDCA_BE_UL = 0x60a42b;
EDCA_BE_DL = 0x60a42b;
}
else
{
EDCA_BE_UL = 0x6ea42b;
EDCA_BE_DL = 0x6ea42b;
}
#endif
}
GetTwoPortSharedResource(Adapter,TWO_PORT_SHARED_OBJECT__STATUS,NULL,&TwoPortStatus);
if(TwoPortStatus == TWO_PORT_STATUS__EXTENSION_ONLY)
{
EDCA_BE_UL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_UL[ExtAdapter->MgntInfo.IOTPeer];
EDCA_BE_DL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_DL[ExtAdapter->MgntInfo.IOTPeer];
}
RT_TRACE(COMP_TURBO,DBG_TRACE,("==>odm_CheckEdcaTurbo, Now is %s Adapt.\n",(IsDefaultAdapter(Adapter))?"Def":"Ext"));
// RT_TRACE(COMP_TURBO,DBG_TRACE,("Def_IOTPeer=%ld.Ext_IOTPeer=%ld\n",pDefaultAdapter->MgntInfo.IOTPeer, ExtAdapter->MgntInfo.IOTPeer));
//
// Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters
// should follow the settings from QAP. By Bruce, 2007-12-07.
//
if(Adapter->MgntInfo.bWiFiConfg)
goto dm_CheckEdcaTurbo_EXIT;
// 1. We do not turn on EDCA turbo mode for some AP that has IOT issue
// 2. User may disable EDCA Turbo mode with OID settings.
if((pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) ||pHalData->bForcedDisableTurboEDCA)
goto dm_CheckEdcaTurbo_EXIT;
#if (INTEL_PROXIMITY_SUPPORT == 1)
if(pMgntInfo->IntelClassModeInfo.bEnableCA == TRUE)
{
EDCA_BE_UL = EDCA_BE_DL = 0xa44f;
}
else
#endif
{
if((!pMgntInfo->bDisableFrameBursting) &&
(pMgntInfo->IOTAction & (HT_IOT_ACT_FORCED_ENABLE_BE_TXOP|HT_IOT_ACT_AMSDU_ENABLE)))
{// To check whether we shall force turn on TXOP configuration.
if(!(EDCA_BE_UL & 0xffff0000))
EDCA_BE_UL |= 0x005e0000; // Force TxOP limit to 0x005e for UL.
if(!(EDCA_BE_DL & 0xffff0000))
EDCA_BE_DL |= 0x005e0000; // Force TxOP limit to 0x005e for DL.
}
//92D txop can't be set to 0x3e for cisco1250
if((!IS_HARDWARE_TYPE_8192D (Adapter)) && pMgntInfo->IOTPeer == HT_IOT_PEER_CISCO && IS_WIRELESS_MODE_N_24G(Adapter))
{
EDCA_BE_DL = edca_setting_DL[pMgntInfo->IOTPeer];
EDCA_BE_UL = edca_setting_UL[pMgntInfo->IOTPeer];
}
else if(pMgntInfo->IOTPeer == HT_IOT_PEER_CISCO
&& ( IS_WIRELESS_MODE_G(Adapter) ||IS_WIRELESS_MODE_B(Adapter) ||IS_WIRELESS_MODE_A(Adapter) ))
{
EDCA_BE_DL = edca_setting_DL_GMode[pMgntInfo->IOTPeer];
RT_TRACE(COMP_TURBO,DBG_LOUD,("==>odm_CheckEdcaTurbo,HT_IOT_PEER_CISCO,G/B mode. set EDCA_BE_DL=0x%x\n ",EDCA_BE_DL));
}
else if(pMgntInfo->IOTPeer == HT_IOT_PEER_AIRGO && (IS_WIRELESS_MODE_G(Adapter) || IS_WIRELESS_MODE_A(Adapter)))
{
EDCA_BE_DL = 0xa630;
}
else if(pMgntInfo->IOTPeer == HT_IOT_PEER_MARVELL)
{
EDCA_BE_DL = edca_setting_DL[pMgntInfo->IOTPeer];
EDCA_BE_UL = edca_setting_UL[pMgntInfo->IOTPeer];
}
else if(pMgntInfo->IOTPeer == HT_IOT_PEER_ATHEROS)
{
// Set DL EDCA for Atheros peer to 0x3ea42b. Suggested by SD3 Wilson for ASUS TP issue.
// 2011.11.28. by tynli.
EDCA_BE_DL = edca_setting_DL[pMgntInfo->IOTPeer];
}
}
if (pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_AC_TXOP)
{
//DbgPrint("HT_IOT_ACT_DISABLE_AC_TXOP return\n");
return; // Disable EDCA turbo for WNDAP 4500 broadcom 3T3R AP.
}
// Check if the status needs to be changed.
if((!pHalData->bIsAnyNonBEPkts) && (!pMgntInfo->bDisableFrameBursting))
{
RTPRINT(FDM, DM_EDCA_Turbo, ("Turn on Turbo EDCA \n"));
//
// Turn On EDCA turbo here.
// In this point, 2 condition needs to be checked:
// (1) What peer STA do we link to.
// (2) Check Tx/Rx count to determine if it is in uplink/downlink.
// Use specific EDCA parameter for each different combination.
//
curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - pMgntInfo->lastTxOkCnt;
curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - pMgntInfo->lastRxOkCnt;
Ext_curTxOkCnt = pExtAdapter->TxStats.NumTxBytesUnicast - pMgntInfo->Ext_lastTxOkCnt;
Ext_curRxOkCnt = pExtAdapter->RxStats.NumRxBytesUnicast - pMgntInfo->Ext_lastRxOkCnt;
RT_TRACE(COMP_TURBO,DBG_TRACE,("[Def]curTxOkCnt=%"i64fmt"d.",curTxOkCnt));
RT_TRACE(COMP_TURBO,DBG_TRACE,("curRxOkCnt=%"i64fmt"d.\n",curRxOkCnt));
RT_TRACE(COMP_TURBO,DBG_TRACE,("[Ext]curTxOkCnt=%"i64fmt"d.",Ext_curTxOkCnt));
RT_TRACE(COMP_TURBO,DBG_TRACE,("curRxOkCnt=%"i64fmt"d.\n",Ext_curRxOkCnt));
//For future Win7 Enable Default Port to modify AMPDU size dynamically, 2009.08.20, Bohn.
{
u1Byte TwoPortStatus = (u1Byte)TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE;
GetTwoPortSharedResource(Adapter,TWO_PORT_SHARED_OBJECT__STATUS,NULL,&TwoPortStatus);
if(TwoPortStatus == TWO_PORT_STATUS__EXTENSION_ONLY)
{
curTxOkCnt = Ext_curTxOkCnt ;
curRxOkCnt = Ext_curRxOkCnt ;
}
}
// Modify EDCA parameters selection bias
// For some APs, use downlink EDCA parameters for uplink+downlink
if(pMgntInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX)
{
RTPRINT(FDM, DM_EDCA_Turbo, ("EDCA IOT state : BIAS on Rx\n"));
if(curTxOkCnt > 4*curRxOkCnt)
{// Uplink TP is present.
RTPRINT(FDM, DM_EDCA_Turbo, ("EDCA Current Uplink state\n"));
if(pHalData->bIsCurRDLState || !pHalData->bCurrentTurboEDCA)
{
PlatformEFIOWrite4Byte(Adapter, REG_EDCA_BE_PARAM, EDCA_BE_UL);
pHalData->bIsCurRDLState = FALSE;
}
}
else
{// Balance TP is present.
RTPRINT(FDM, DM_EDCA_Turbo, ("EDCA Current Balance state\n"));
if(!pHalData->bIsCurRDLState || !pHalData->bCurrentTurboEDCA)
{
PlatformEFIOWrite4Byte(Adapter, REG_EDCA_BE_PARAM, EDCA_BE_DL);
pHalData->bIsCurRDLState = TRUE;
}
}
pHalData->bCurrentTurboEDCA = TRUE;
}
else
{// For generic IOT Action.
RTPRINT(FDM, DM_EDCA_Turbo, ("EDCA IOT state : Generic\n"));
if(curRxOkCnt > 4*curTxOkCnt)
{// Downlink TP is present.
RTPRINT(FDM, DM_EDCA_Turbo, ("EDCA Current Downlink state\n"));
if(!pHalData->bIsCurRDLState || !pHalData->bCurrentTurboEDCA)
{
PlatformEFIOWrite4Byte(Adapter, REG_EDCA_BE_PARAM, EDCA_BE_DL);
pHalData->bIsCurRDLState = TRUE;
}
}
else
{// Balance TP is present.
RTPRINT(FDM, DM_EDCA_Turbo, ("EDCA Current Balance state\n"));
if(pHalData->bIsCurRDLState || !pHalData->bCurrentTurboEDCA)
{
PlatformEFIOWrite4Byte(Adapter, REG_EDCA_BE_PARAM, EDCA_BE_UL);
pHalData->bIsCurRDLState = FALSE;
}
}
pHalData->bCurrentTurboEDCA = TRUE;
}
}
else
{
RTPRINT(FDM, DM_EDCA_Turbo, ("Turn off Turbo EDCA \n"));
//
// Turn Off EDCA turbo here.
// Restore original EDCA according to the declaration of AP.
//
if(pHalData->bCurrentTurboEDCA)
{
Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_AC_PARAM, GET_WMM_PARAM_ELE_SINGLE_AC_PARAM(pStaQos->WMMParamEle, AC0_BE) );
pHalData->bCurrentTurboEDCA = FALSE;
}
}
dm_CheckEdcaTurbo_EXIT:
// Set variables for next time.
pHalData->bIsAnyNonBEPkts = FALSE;
pMgntInfo->lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast;
pMgntInfo->lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast;
pMgntInfo->Ext_lastTxOkCnt = pExtAdapter->TxStats.NumTxBytesUnicast;
pMgntInfo->Ext_lastRxOkCnt = pExtAdapter->RxStats.NumRxBytesUnicast;
} // odm_CheckEdcaTurbo
//============================================================
//#pragma mark -- Tx Power Tracking --
//3============================================================
//3 Tx Power Tracking
//3============================================================
static VOID
odm_InitializeTXPowerTracking_ThermalMeter(
IN PADAPTER Adapter)
{
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
pMgntInfo->bTXPowerTracking = TRUE;
pHalData->TXPowercount = 0;
pHalData->bTXPowerTrackingInit = FALSE;
#if MP_DRIVER != 1 //for mp driver, turn off txpwrtracking as default
if(!IS_HARDWARE_TYPE_8188E(Adapter))
pHalData->TxPowerTrackControl = TRUE;
#endif
RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("pMgntInfo->bTXPowerTracking = %d\n", pMgntInfo->bTXPowerTracking));
}
VOID
odm_InitializeTXPowerTracking(
IN PADAPTER Adapter)
{
odm_InitializeTXPowerTracking_ThermalMeter(Adapter);
}
VOID
odm_CheckTXPowerTracking_ThermalMeter(
IN PADAPTER Adapter)
{
#if (HAL_CODE_BASE==RTL8192_C)
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
//HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
static u1Byte TM_Trigger = 0;
//u1Byte TxPowerCheckCnt = 5; //10 sec
if(!pMgntInfo->bTXPowerTracking /*|| (!pHalData->TxPowerTrackControl && pHalData->bAPKdone)*/)
{
return;
}
if(!TM_Trigger) //at least delay 1 sec
{
if(IS_HARDWARE_TYPE_8192D(Adapter))
PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_92D, BIT17 | BIT16, 0x03);
else if(IS_HARDWARE_TYPE_8188E(Adapter))
PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03);
else if(IS_HARDWARE_TYPE_8812(Adapter))
PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT16, 0x01);
else
PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60);
RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,("Trigger 92C Thermal Meter!!\n"));
TM_Trigger = 1;
return;
}
else
{
RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,("Schedule TxPowerTracking direct call!!\n"));
odm_TXPowerTrackingDirectCall(Adapter); //Using direct call is instead, added by Roger, 2009.06.18.
TM_Trigger = 0;
}
#endif
}
//
// 2011/07/26 MH Add an API for testing IQK fail case.
//
BOOLEAN
ODM_CheckPowerStatus(
IN PADAPTER Adapter)
{
RT_RF_POWER_STATE rtState;
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
// 2011/07/27 MH We are not testing ready~~!! We may fail to get correct value when init sequence.
if (pMgntInfo->init_adpt_in_progress == TRUE)
{
RT_TRACE(COMP_INIT, DBG_LOUD, ("ODM_CheckPowerStatus Return TRUE, due to initadapter"));
return TRUE;
}
//
// 2011/07/19 MH We can not execute tx pwoer tracking/ LLC calibrate or IQK.
//
Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState));
if(Adapter->bDriverStopped || Adapter->bDriverIsGoingToPnpSetPowerSleep || rtState == eRfOff)
{
RT_TRACE(COMP_INIT, DBG_LOUD, ("ODM_CheckPowerStatus Return FALSE, due to %d/%d/%d\n",
Adapter->bDriverStopped, Adapter->bDriverIsGoingToPnpSetPowerSleep, rtState));
return FALSE;
}
return TRUE;
}
VOID
ODM_CheckTXPowerTracking(
IN PADAPTER Adapter)
{
if (ODM_CheckPowerStatus(Adapter) == FALSE)
return;
odm_CheckTXPowerTracking_ThermalMeter(Adapter);
}
//============================================================
//#pragma mark --Rate Adaptive --
//3============================================================
//3 Rate Adaptive
//3============================================================
VOID
odm_InitRateAdaptiveMask(
IN PADAPTER Adapter
)
{
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
PRATE_ADAPTIVE pRA = (PRATE_ADAPTIVE)&pMgntInfo->RateAdaptive;
pRA->RATRState = DM_RATR_STA_INIT;
pRA->PreRATRState = DM_RATR_STA_INIT;
if (pMgntInfo->DM_Type == DM_Type_ByDriver)
pMgntInfo->bUseRAMask = TRUE;
else
pMgntInfo->bUseRAMask = FALSE;
}
VOID
ODM_ApInitRateAdaptiveState(
IN PADAPTER Adapter ,
IN PRT_WLAN_STA pEntry
)
{
PRATE_ADAPTIVE pRA = (PRATE_ADAPTIVE)&pEntry->RateAdaptive;
pRA->RATRState = DM_RATR_STA_INIT;
pRA->PreRATRState = DM_RATR_STA_INIT;
}
/*-----------------------------------------------------------------------------
* Function: odm_RefreshRateAdaptiveMask()
*
* Overview: Update rate table mask according to rssi
*
* Input: NONE
*
* Output: NONE
*
* Return: NONE
*
* Revised History:
* When Who Remark
* 05/27/2009 hpfan Create Version 0.
*
*---------------------------------------------------------------------------*/
VOID
odm_RefreshRateAdaptiveMask( IN PADAPTER pAdapter )
{
PADAPTER pTargetAdapter = NULL;
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
PMGNT_INFO pMgntInfo = GetDefaultMgntInfo(pAdapter);
PRATE_ADAPTIVE pRA = (PRATE_ADAPTIVE)&pMgntInfo->RateAdaptive;
u4Byte LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0;
if(pAdapter->bDriverStopped)
{
RT_TRACE(COMP_RATR, DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
return;
}
if(!pMgntInfo->bUseRAMask)
{
RT_TRACE(COMP_RATR, DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
return;
}
// if default port is connected, update RA table for default port (infrastructure mode only)
if(pAdapter->MgntInfo.mAssoc && (!ACTING_AS_AP(pAdapter)))
{
// decide rastate according to rssi
switch (pRA->PreRATRState)
{
case DM_RATR_STA_HIGH:
HighRSSIThreshForRA = 50;
LowRSSIThreshForRA = 20;
break;
case DM_RATR_STA_MIDDLE:
HighRSSIThreshForRA = 55;
LowRSSIThreshForRA = 20;
break;
case DM_RATR_STA_LOW:
HighRSSIThreshForRA = 50;
LowRSSIThreshForRA = 25;
break;
default:
HighRSSIThreshForRA = 50;
LowRSSIThreshForRA = 20;
break;
}
if(pHalData->UndecoratedSmoothedPWDB > (s4Byte)HighRSSIThreshForRA)
pRA->RATRState = DM_RATR_STA_HIGH;
else if(pHalData->UndecoratedSmoothedPWDB > (s4Byte)LowRSSIThreshForRA)
pRA->RATRState = DM_RATR_STA_MIDDLE;
else
pRA->RATRState = DM_RATR_STA_LOW;
if((pRA->PreRATRState != pRA->RATRState)||pMgntInfo->bSetTXPowerTrainingByOid)
{
RT_PRINT_ADDR(COMP_RATR, DBG_LOUD, ("Target AP addr : "), pMgntInfo->Bssid);
RT_TRACE(COMP_RATR, DBG_LOUD, ("RSSI = %d\n", pHalData->UndecoratedSmoothedPWDB));
RT_TRACE(COMP_RATR, DBG_LOUD, ("RSSI_LEVEL = %d\n", pRA->RATRState));
RT_TRACE(COMP_RATR, DBG_LOUD, ("PreState = %d, CurState = %d\n", pRA->PreRATRState, pRA->RATRState));
pAdapter->HalFunc.UpdateHalRAMaskHandler(
pAdapter,
FALSE,
0,
NULL,
NULL,
pRA->RATRState,
RAMask_Normal);
pRA->PreRATRState = pRA->RATRState;
}
}
//
// The following part configure AP/VWifi/IBSS rate adaptive mask.
//
if(pMgntInfo->mIbss)
{
// Target: AP/IBSS peer.
pTargetAdapter = GetDefaultAdapter(pAdapter);
}
else
{
pTargetAdapter = GetDefaultAdapter(pAdapter);
while(pTargetAdapter != NULL)
{
if(ACTING_AS_AP(pTargetAdapter ))
break;
pTargetAdapter = GetNextExtAdapter(pTargetAdapter);
}
}
// if extension port (softap) is started, updaet RA table for more than one clients associate
if(pTargetAdapter != NULL)
{
int i;
PRT_WLAN_STA pEntry;
PRATE_ADAPTIVE pEntryRA;
for(i = 0; i < ASSOCIATE_ENTRY_NUM; i++)
{
if( pTargetAdapter->MgntInfo.AsocEntry[i].bUsed && pTargetAdapter->MgntInfo.AsocEntry[i].bAssociated)
{
pEntry = pTargetAdapter->MgntInfo.AsocEntry+i;
pEntryRA = &pEntry->RateAdaptive;
switch (pEntryRA->PreRATRState)
{
case DM_RATR_STA_HIGH:
{
HighRSSIThreshForRA = 50;
LowRSSIThreshForRA = 20;
}
break;
case DM_RATR_STA_MIDDLE:
{
HighRSSIThreshForRA = 55;
LowRSSIThreshForRA = 20;
}
break;
case DM_RATR_STA_LOW:
{
HighRSSIThreshForRA = 50;
LowRSSIThreshForRA = 25;
}
break;
default:
{
HighRSSIThreshForRA = 50;
LowRSSIThreshForRA = 20;
}
}
if(pEntry->rssi_stat.UndecoratedSmoothedPWDB > (s4Byte)HighRSSIThreshForRA)
pEntryRA->RATRState = DM_RATR_STA_HIGH;
else if(pEntry->rssi_stat.UndecoratedSmoothedPWDB > (s4Byte)LowRSSIThreshForRA)
pEntryRA->RATRState = DM_RATR_STA_MIDDLE;
else
pEntryRA->RATRState = DM_RATR_STA_LOW;
if((pEntryRA->PreRATRState != pEntryRA->RATRState)||pMgntInfo->bSetTXPowerTrainingByOid)
{
RT_PRINT_ADDR(COMP_RATR, DBG_LOUD, ("AsocEntry addr : "), pEntry->MacAddr);
RT_TRACE(COMP_RATR, DBG_LOUD, ("RSSI = %d\n", pEntry->rssi_stat.UndecoratedSmoothedPWDB));
RT_TRACE(COMP_RATR, DBG_LOUD, ("RSSI_LEVEL = %d\n", pEntryRA->RATRState));
RT_TRACE(COMP_RATR, DBG_LOUD, ("PreState = %d, CurState = %d\n", pEntryRA->PreRATRState, pEntryRA->RATRState));
pAdapter->HalFunc.UpdateHalRAMaskHandler(
pTargetAdapter,
FALSE,
pEntry->AID+1,
pEntry->MacAddr,
pEntry,
pEntryRA->RATRState,
RAMask_Normal);
pEntryRA->PreRATRState = pEntryRA->RATRState;
}
}
}
}
if(pMgntInfo->bSetTXPowerTrainingByOid)
pMgntInfo->bSetTXPowerTrainingByOid = FALSE;
}
//============================================================
//#pragma mark --BB Power Save --
//3============================================================
//3 BB Power Save
//3============================================================
void odm_InitDynamicBBPowerSaving(
IN PADAPTER Adapter
)
{
pPS_T pDM_PSTable = &Adapter->DM_PSTable;
pDM_PSTable->PreCCAState = CCA_MAX;
pDM_PSTable->CurCCAState = CCA_MAX;
pDM_PSTable->PreRFState = RF_MAX;
pDM_PSTable->CurRFState = RF_MAX;
pDM_PSTable->Rssi_val_min = 0;
}
void
odm_DynamicBBPowerSaving(
IN PADAPTER pAdapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo);
pPS_T pDM_PSTable = &pAdapter->DM_PSTable;
//1 1.Determine the minimum RSSI
if((!pMgntInfo->bMediaConnect) &&
(pHalData->EntryMinUndecoratedSmoothedPWDB == 0))
{
pDM_PSTable->Rssi_val_min = 0;
RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any \n"));
}
if(pMgntInfo->bMediaConnect) // Default port
{
if(ACTING_AS_AP(pAdapter) || pMgntInfo->mIbss)
{
pDM_PSTable->Rssi_val_min = pHalData->EntryMinUndecoratedSmoothedPWDB;
RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, ("AP Client PWDB = 0x%x \n", pDM_PSTable->Rssi_val_min));
}
else
{
pDM_PSTable->Rssi_val_min = pHalData->UndecoratedSmoothedPWDB;
RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", pDM_PSTable->Rssi_val_min));
}
}
else // associated entry pwdb
{
pDM_PSTable->Rssi_val_min = pHalData->EntryMinUndecoratedSmoothedPWDB;
RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", pDM_PSTable->Rssi_val_min));
}
//1 2.Power Saving for 92C
if(IS_92C_SERIAL(pHalData->VersionID))
{
odm_1R_CCA(pAdapter);
}
// 20100628 Joseph: Turn off BB power save for 88CE because it makesthroughput unstable.
// 20100831 Joseph: Turn ON BB power save again after modifying AGC delay from 900ns ot 600ns.
//1 3.Power Saving for 88C
else
{
dm_RF_Saving(pAdapter, FALSE);
}
}
//============================================================
//#pragma mark --Antenna Diversity --
//3============================================================
//3 Antenna Diversity
//3============================================================
//
// 20100514 Joseph:
// Add new function to reset the state of antenna diversity before link.
//
VOID
ODM_SwAntDivResetBeforeLink(
IN PADAPTER Adapter
)
{
pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
pDM_SWAT_Table->SWAS_NoLink_State = 0;
}
u1Byte
odm_SwAntDivSelectChkChnl(
IN PADAPTER Adapter
)
{
#if (RT_MEM_SIZE_LEVEL != RT_MEM_SIZE_MINIMUM)
u1Byte index, target_chnl=0;
u1Byte chnl_peer_cnt[14] = {0};
if(Adapter->MgntInfo.tmpNumBssDesc==0)
{
return 0;
}
else
{
// 20100519 Joseph: Select checking channel from current scan list.
// We just choose the channel with most APs to be the test scan channel.
for(index=0; index<Adapter->MgntInfo.tmpNumBssDesc; index++)
{
// Add by hpfan: prevent access invalid channel number
// TODO: Verify channel number by channel plan
if(Adapter->MgntInfo.tmpbssDesc[index].ChannelNumber == 0 ||
Adapter->MgntInfo.tmpbssDesc[index].ChannelNumber > 13)
continue;
chnl_peer_cnt[Adapter->MgntInfo.tmpbssDesc[index].ChannelNumber-1]++;
}
for(index=0; index<14; index++)
{
if(chnl_peer_cnt[index]>chnl_peer_cnt[target_chnl])
target_chnl = index;
}
target_chnl+=1;
RT_TRACE(COMP_SWAS, DBG_LOUD,
("odm_SwAntDivSelectChkChnl(): Channel %d is select as test channel.\n", target_chnl));
return target_chnl;
}
#else
return 0;
#endif
}
VOID
odm_SwAntDivConsructChkScanChnl(
IN PADAPTER Adapter,
IN u1Byte ChkChnl
)
{
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
PRT_CHANNEL_LIST pChannelList = GET_RT_CHANNEL_LIST(pMgntInfo);
u1Byte index;
if(ChkChnl==0)
{
// 20100519 Joseph: Original antenna scanned nothing.
// Test antenna shall scan all channel with half period in this condition.
RtActChannelList(Adapter, RT_CHNL_LIST_ACTION_CONSTRUCT_SCAN_LIST, NULL, NULL);
for(index=0; index<pChannelList->ChannelLen; index++)
pChannelList->ChannelInfo[index].ScanPeriod /= 2;
}
else
{
// The using of this CustomizedScanRequest is a trick to rescan the two channels
// under the NORMAL scanning process. It will not affect MGNT_INFO.CustomizedScanRequest.
CUSTOMIZED_SCAN_REQUEST CustomScanReq;
CustomScanReq.bEnabled = TRUE;
CustomScanReq.Channels[0] = ChkChnl;
CustomScanReq.Channels[1] = pMgntInfo->dot11CurrentChannelNumber;
CustomScanReq.nChannels = 2;
CustomScanReq.ScanType = SCAN_ACTIVE;
CustomScanReq.Duration = DEFAULT_ACTIVE_SCAN_PERIOD;
RtActChannelList(Adapter, RT_CHNL_LIST_ACTION_CONSTRUCT_SCAN_LIST, &CustomScanReq, NULL);
}
}
//
// 20100503 Joseph:
// Add new function SwAntDivCheck8192C().
// This is the main function of Antenna diversity function before link.
// Mainly, it just retains last scan result and scan again.
// After that, it compares the scan result to see which one gets better RSSI.
// It selects antenna with better receiving power and returns better scan result.
//
BOOLEAN
ODM_SwAntDivCheckBeforeLink(
IN PADAPTER Adapter
)
{
#if (RT_MEM_SIZE_LEVEL != RT_MEM_SIZE_MINIMUM)
HAL_DATA_TYPE* pHalData = GET_HAL_DATA(Adapter);
PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
s1Byte Score = 0;
PRT_WLAN_BSS pTmpBssDesc;
PRT_WLAN_BSS pTestBssDesc;
u1Byte target_chnl = 0;
u1Byte index;
// Condition that does not need to use antenna diversity.
// 8723A need to use SW Ant
if(IS_HARDWARE_TYPE_8192D(Adapter) ||IS_92C_SERIAL(pHalData->VersionID) ||
(pHalData->AntDivCfg==0) ||
pMgntInfo->AntennaTest )
{
RT_TRACE(COMP_SWAS, DBG_LOUD,
("ODM_SwAntDivCheckBeforeLink(): No AntDiv Mechanism.\n"));
return FALSE;
}
//2 8723A may only one Ant
if(IS_HARDWARE_TYPE_8723A(Adapter) && (pDM_SWAT_Table->ANTB_ON == FALSE))
{
RT_TRACE(COMP_SWAS, DBG_LOUD,
("ODM_SwAntDivCheckBeforeLink(): No AntDiv Mechanism, Antenna B is off\n"));
return FALSE;
}
// Since driver is going to set BB register, it shall check if there is another thread controlling BB/RF.
PlatformAcquireSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
if(pHalData->eRFPowerState!=eRfOn || pMgntInfo->RFChangeInProgress || pMgntInfo->bMediaConnect)
{
PlatformReleaseSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
RT_TRACE(COMP_SWAS, DBG_LOUD,
("ODM_SwAntDivCheckBeforeLink(): RFChangeInProgress(%x), eRFPowerState(%x)\n",
pMgntInfo->RFChangeInProgress,
pHalData->eRFPowerState));
pDM_SWAT_Table->SWAS_NoLink_State = 0;
return FALSE;
}
else
{
PlatformReleaseSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
}
//1 Run AntDiv mechanism "Before Link" part.
if(pDM_SWAT_Table->SWAS_NoLink_State == 0)
{
//1 Prepare to do Scan again to check current antenna state.
// Set check state to next step.
pDM_SWAT_Table->SWAS_NoLink_State = 1;
// Copy Current Scan list.
Adapter->MgntInfo.tmpNumBssDesc = pMgntInfo->NumBssDesc;
PlatformMoveMemory((PVOID)Adapter->MgntInfo.tmpbssDesc, (PVOID)pMgntInfo->bssDesc, sizeof(RT_WLAN_BSS)*MAX_BSS_DESC);
// Switch Antenna to another one.
pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
pDM_SWAT_Table->CurAntenna = (pDM_SWAT_Table->CurAntenna==Antenna_A)?Antenna_B:Antenna_A;
RT_TRACE(COMP_SWAS, DBG_LOUD,
("ODM_SwAntDivCheckBeforeLink(): Change to Ant(%s) for testing.\n", (pDM_SWAT_Table->CurAntenna==Antenna_A)?"A":"B"));
//PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, DM_SWAT_Table.CurAntenna);
pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ((pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 & 0xfffffcff) | (pDM_SWAT_Table->CurAntenna<<8));
PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, bMaskDWord, pDM_SWAT_Table->SWAS_NoLink_BK_Reg860);
// Go back to scan function again.
RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink(): Scan one more time\n"));
pMgntInfo->ScanStep=0;
target_chnl = odm_SwAntDivSelectChkChnl(Adapter);
odm_SwAntDivConsructChkScanChnl(Adapter, target_chnl);
HTReleaseChnlOpLock(Adapter);
PlatformSetTimer(Adapter, &pMgntInfo->ScanTimer, 5);
return TRUE;
}
else
{
//1 ScanComple() is called after antenna swiched.
//1 Check scan result and determine which antenna is going
//1 to be used.
for(index=0; index<Adapter->MgntInfo.tmpNumBssDesc; index++)
{
pTmpBssDesc = &(Adapter->MgntInfo.tmpbssDesc[index]);
pTestBssDesc = &(pMgntInfo->bssDesc[index]);
if(PlatformCompareMemory(pTestBssDesc->bdBssIdBuf, pTmpBssDesc->bdBssIdBuf, 6)!=0)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink(): ERROR!! This shall not happen.\n"));
continue;
}
if(pTmpBssDesc->RecvSignalPower > pTestBssDesc->RecvSignalPower)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink8192C: Compare scan entry: Score++\n"));
RT_PRINT_STR(COMP_SWAS, DBG_LOUD, "SSID: ", pTestBssDesc->bdSsIdBuf, pTestBssDesc->bdSsIdLen);
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Original: %d, Test: %d\n", pTmpBssDesc->RecvSignalPower, pTestBssDesc->RecvSignalPower));
Score++;
PlatformMoveMemory(pTestBssDesc, pTmpBssDesc, sizeof(RT_WLAN_BSS));
}
else if(pTmpBssDesc->RecvSignalPower < pTestBssDesc->RecvSignalPower)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink: Compare scan entry: Score--\n"));
RT_PRINT_STR(COMP_SWAS, DBG_LOUD, "SSID: ", pTestBssDesc->bdSsIdBuf, pTestBssDesc->bdSsIdLen);
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Original: %d, Test: %d\n", pTmpBssDesc->RecvSignalPower, pTestBssDesc->RecvSignalPower));
Score--;
}
}
if(pMgntInfo->NumBssDesc!=0 && Score<=0)
{
RT_TRACE(COMP_SWAS, DBG_LOUD,
("ODM_SwAntDivCheckBeforeLink(): Using Ant(%s)\n", (pDM_SWAT_Table->CurAntenna==Antenna_A)?"A":"B"));
pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
}
else
{
RT_TRACE(COMP_SWAS, DBG_LOUD,
("ODM_SwAntDivCheckBeforeLink(): Remain Ant(%s)\n", (pDM_SWAT_Table->CurAntenna==Antenna_A)?"B":"A"));
pDM_SWAT_Table->CurAntenna = pDM_SWAT_Table->PreAntenna;
//PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, DM_SWAT_Table.CurAntenna);
pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ((pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 & 0xfffffcff) | (pDM_SWAT_Table->CurAntenna<<8));
PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, bMaskDWord, pDM_SWAT_Table->SWAS_NoLink_BK_Reg860);
}
// Check state reset to default and wait for next time.
pDM_SWAT_Table->SWAS_NoLink_State = 0;
return FALSE;
}
#else
return FALSE;
#endif
}
//
// 20100514 Luke/Joseph:
// Add new function to reset antenna diversity state after link.
//
VOID
ODM_SwAntDivRestAfterLink(
IN PADAPTER Adapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
pHalData->RSSI_cnt_A = 0;
pHalData->RSSI_cnt_B = 0;
pHalData->RSSI_test = FALSE;
pDM_SWAT_Table->try_flag = 0xff;
pDM_SWAT_Table->RSSI_Trying = 0;
pDM_SWAT_Table->SelectAntennaMap=0xAA;
}
//
// 20100514 Luke/Joseph:
// Add new function for antenna diversity after link.
// This is the main function of antenna diversity after link.
// This function is called in HalDmWatchDog() and ODM_SwAntDivChkAntSwitchCallback().
// HalDmWatchDog() calls this function with SWAW_STEP_PEAK to initialize the antenna test.
// In SWAW_STEP_PEAK, another antenna and a 500ms timer will be set for testing.
// After 500ms, ODM_SwAntDivChkAntSwitchCallback() calls this function to compare the signal just
// listened on the air with the RSSI of original antenna.
// It chooses the antenna with better RSSI.
// There is also a aged policy for error trying. Each error trying will cost more 5 seconds waiting
// penalty to get next try.
//
VOID
odm_SwAntDivChkAntSwitch(
PADAPTER Adapter,
u1Byte Step
)
{
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
s4Byte curRSSI=100, RSSI_A, RSSI_B;
u1Byte nextAntenna=Antenna_B;
static u8Byte lastTxOkCnt=0, lastRxOkCnt=0;
u8Byte curTxOkCnt, curRxOkCnt;
static u8Byte TXByteCnt_A=0, TXByteCnt_B=0, RXByteCnt_A=0, RXByteCnt_B=0;
u8Byte CurByteCnt=0, PreByteCnt=0;
static u1Byte TrafficLoad = TRAFFIC_LOW;
u1Byte Score_A=0, Score_B=0;
u1Byte i;
// sleep state for 8723
u1Byte CHK_A=0, CHK_B=0;
static u1Byte PeningCount=0;
static u1Byte NeedtoChk=1;
static BOOLEAN TryingOK=FALSE;
// Condition that does not need to use antenna diversity.
// 8723A need to use SW ANT
if(IS_92C_SERIAL(pHalData->VersionID) ||(pHalData->AntDivCfg==0) || pMgntInfo->AntennaTest)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): No AntDiv Mechanism.\n"));
return;
}
//2 8723A may only one ANT
if(IS_HARDWARE_TYPE_8723A(Adapter) &&
(pDM_SWAT_Table->ANTB_ON == FALSE))
{
RT_TRACE(COMP_SWAS, DBG_LOUD,
("odm_SwAntDivChkAntSwitch(): No AntDiv Mechanism, Antenna B is off\n"));
return;
}
// Radio off: Status reset to default and return.
if(pHalData->eRFPowerState==eRfOff)
{
ODM_SwAntDivRestAfterLink(Adapter);
return;
}
// Handling step mismatch condition.
// Peak step is not finished at last time. Recover the variable and check again.
if( Step != pDM_SWAT_Table->try_flag )
{
ODM_SwAntDivRestAfterLink(Adapter);
}
//8723A Sleep State
if(IS_HARDWARE_TYPE_8723A(Adapter))
{
if((PeningCount >0)&&(TryingOK==TRUE))
{
PeningCount--;
NeedtoChk=0;
//DbgPrint("SwAnt is in Sleeping State");
return;
}
// Add to Steady State to avoid busy traing
// to Check SelectAntennaMap first
if((NeedtoChk)&&(TryingOK==TRUE))
{
for(i=0;i<8;i++)
{
if(((pDM_SWAT_Table->SelectAntennaMap>>i)&BIT0) == 1)
CHK_A++;
else
CHK_B++;
}
if((CHK_A >=8)||(CHK_B>=8))
{
PeningCount=0x1E;
//DbgPrint("SwAnt go into Sleeping State");
return;
}
}
else
{
NeedtoChk=1;
//DbgPrint("SwAnt Out to Sleeping State");
}
}
if(pDM_SWAT_Table->try_flag == 0xff)
{
// Select RSSI checking target
if(pMgntInfo->mAssoc && !ACTING_AS_AP(Adapter))
{
// Target: Infrastructure mode AP.
pHalData->RSSI_target = NULL;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): RSSI_target is DEF AP!\n"));
}
else
{
u1Byte index = 0;
PRT_WLAN_STA pEntry = NULL;
PADAPTER pTargetAdapter = NULL;
if(pMgntInfo->mIbss )
{
// Target: AP/IBSS peer.
pTargetAdapter = Adapter;
}
else
{
pTargetAdapter = GetDefaultAdapter(Adapter);
while(pTargetAdapter != NULL)
{
if(ACTING_AS_AP(pTargetAdapter ))
break;
pTargetAdapter = GetNextExtAdapter(pTargetAdapter);
}
}
if(pTargetAdapter != NULL)
{
for(index=0; index<ASSOCIATE_ENTRY_NUM; index++)
{
pEntry = AsocEntry_EnumStation(pTargetAdapter, index);
if(pEntry != NULL)
{
if(pEntry->bAssociated)
break;
}
}
}
if(pEntry == NULL)
{
ODM_SwAntDivRestAfterLink(Adapter);
RT_TRACE(COMP_SWAS, DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): No Link.\n"));
return;
}
else
{
pHalData->RSSI_target = pEntry;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): RSSI_target is PEER STA\n"));
}
}
pHalData->RSSI_cnt_A = 0;
pHalData->RSSI_cnt_B = 0;
pDM_SWAT_Table->try_flag = 0;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): Set try_flag to 0 prepare for peak!\n"));
return;
}
else
{
curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - lastTxOkCnt;
curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - lastRxOkCnt;
lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast;
lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast;
TryingOK=FALSE; //Neil -----> for 8723A sleep State using
if(pDM_SWAT_Table->try_flag == 1)
{
if(pDM_SWAT_Table->CurAntenna == Antenna_A)
{
TXByteCnt_A += curTxOkCnt;
RXByteCnt_A += curRxOkCnt;
}
else
{
TXByteCnt_B += curTxOkCnt;
RXByteCnt_B += curRxOkCnt;
}
nextAntenna = (pDM_SWAT_Table->CurAntenna == Antenna_A)? Antenna_B : Antenna_A;
pDM_SWAT_Table->RSSI_Trying--;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("RSSI_Trying = %d\n",pDM_SWAT_Table->RSSI_Trying));
if(pDM_SWAT_Table->RSSI_Trying == 0)
{
CurByteCnt = (pDM_SWAT_Table->CurAntenna == Antenna_A)? (TXByteCnt_A+RXByteCnt_A) : (TXByteCnt_B+RXByteCnt_B);
PreByteCnt = (pDM_SWAT_Table->CurAntenna == Antenna_A)? (TXByteCnt_B+RXByteCnt_B) : (TXByteCnt_A+RXByteCnt_A);
if(TrafficLoad == TRAFFIC_HIGH)
CurByteCnt = PlatformDivision64(CurByteCnt, 9);
else if(TrafficLoad == TRAFFIC_LOW)
CurByteCnt = PlatformDivision64(CurByteCnt, 2);
if(pHalData->RSSI_cnt_A > 0)
RSSI_A = pHalData->RSSI_sum_A/pHalData->RSSI_cnt_A;
else
RSSI_A = 0;
if(pHalData->RSSI_cnt_B > 0)
RSSI_B = pHalData->RSSI_sum_B/pHalData->RSSI_cnt_B;
else
RSSI_B = 0;
curRSSI = (pDM_SWAT_Table->CurAntenna == Antenna_A)? RSSI_A : RSSI_B;
pDM_SWAT_Table->PreRSSI = (pDM_SWAT_Table->CurAntenna == Antenna_A)? RSSI_B : RSSI_A;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Luke:PreRSSI = %d, CurRSSI = %d\n",pDM_SWAT_Table->PreRSSI, curRSSI));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: preAntenna= %s, curAntenna= %s \n",
(pDM_SWAT_Table->PreAntenna == Antenna_A?"A":"B"), (pDM_SWAT_Table->CurAntenna == Antenna_A?"A":"B")));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Luke:RSSI_A= %d, RSSI_cnt_A = %d, RSSI_B= %d, RSSI_cnt_B = %d\n",
RSSI_A, pHalData->RSSI_cnt_A, RSSI_B, pHalData->RSSI_cnt_B));
}
}
else
{
if(pHalData->RSSI_cnt_A > 0)
RSSI_A = pHalData->RSSI_sum_A/pHalData->RSSI_cnt_A;
else
RSSI_A = 0;
if(pHalData->RSSI_cnt_B > 0)
RSSI_B = pHalData->RSSI_sum_B/pHalData->RSSI_cnt_B;
else
RSSI_B = 0;
curRSSI = (pDM_SWAT_Table->CurAntenna == Antenna_A)? RSSI_A : RSSI_B;
pDM_SWAT_Table->PreRSSI = (pDM_SWAT_Table->PreAntenna == Antenna_A)? RSSI_A : RSSI_B;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:PreRSSI = %d, CurRSSI = %d\n", pDM_SWAT_Table->PreRSSI, curRSSI));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: preAntenna= %s, curAntenna= %s \n",
(pDM_SWAT_Table->PreAntenna == Antenna_A?"A":"B"), (pDM_SWAT_Table->CurAntenna == Antenna_A?"A":"B")));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:RSSI_A= %d, RSSI_cnt_A = %d, RSSI_B= %d, RSSI_cnt_B = %d\n",
RSSI_A, pHalData->RSSI_cnt_A, RSSI_B, pHalData->RSSI_cnt_B));
//RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:curTxOkCnt = %d\n", curTxOkCnt));
//RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:curRxOkCnt = %d\n", curRxOkCnt));
}
//1 Trying State
if((pDM_SWAT_Table->try_flag == 1)&&(pDM_SWAT_Table->RSSI_Trying == 0))
{
if(pDM_SWAT_Table->TestMode == TP_MODE)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: TestMode = TP_MODE"));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("TRY:CurByteCnt = %"i64fmt"d,", CurByteCnt));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("TRY:PreByteCnt = %"i64fmt"d\n",PreByteCnt));
if(CurByteCnt < PreByteCnt)
{
if(pDM_SWAT_Table->CurAntenna == Antenna_A)
pDM_SWAT_Table->SelectAntennaMap=pDM_SWAT_Table->SelectAntennaMap<<1;
else
pDM_SWAT_Table->SelectAntennaMap=(pDM_SWAT_Table->SelectAntennaMap<<1)+1;
}
else
{
if(pDM_SWAT_Table->CurAntenna == Antenna_A)
pDM_SWAT_Table->SelectAntennaMap=(pDM_SWAT_Table->SelectAntennaMap<<1)+1;
else
pDM_SWAT_Table->SelectAntennaMap=pDM_SWAT_Table->SelectAntennaMap<<1;
}
for (i= 0; i<8; i++)
{
if(((pDM_SWAT_Table->SelectAntennaMap>>i)&BIT0) == 1)
Score_A++;
else
Score_B++;
}
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SelectAntennaMap=%x\n ",pDM_SWAT_Table->SelectAntennaMap));
RT_TRACE(COMP_SWAS, DBG_LOUD, ("Score_A=%d, Score_B=%d\n", Score_A, Score_B));
if(pDM_SWAT_Table->CurAntenna == Antenna_A)
{
nextAntenna = (Score_A > Score_B)?Antenna_A:Antenna_B;
}
else
{
nextAntenna = (Score_B > Score_A)?Antenna_B:Antenna_A;
}
//RT_TRACE(COMP_SWAS, DBG_LOUD, ("nextAntenna=%s\n",(nextAntenna==Antenna_A)?"A":"B"));
//RT_TRACE(COMP_SWAS, DBG_LOUD, ("preAntenna= %s, curAntenna= %s \n",
//(DM_SWAT_Table.PreAntenna == Antenna_A?"A":"B"), (DM_SWAT_Table.CurAntenna == Antenna_A?"A":"B")));
if(nextAntenna != pDM_SWAT_Table->CurAntenna)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: Switch back to another antenna"));
}
else
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: current anntena is good\n"));
}
// for 8723A Sleep State using
TryingOK=TRUE;
}
if(pDM_SWAT_Table->TestMode == RSSI_MODE)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: TestMode = RSSI_MODE"));
pDM_SWAT_Table->SelectAntennaMap=0xAA;
if(curRSSI < pDM_SWAT_Table->PreRSSI) //Current antenna is worse than previous antenna
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: Switch back to another antenna"));
nextAntenna = (pDM_SWAT_Table->CurAntenna == Antenna_A)? Antenna_B : Antenna_A;
}
else // current anntena is good
{
nextAntenna =pDM_SWAT_Table->CurAntenna;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: current anntena is good\n"));
}
}
pDM_SWAT_Table->try_flag = 0;
pHalData->RSSI_test = FALSE;
pHalData->RSSI_sum_A = 0;
pHalData->RSSI_cnt_A = 0;
pHalData->RSSI_sum_B = 0;
pHalData->RSSI_cnt_B = 0;
TXByteCnt_A = 0;
TXByteCnt_B = 0;
RXByteCnt_A = 0;
RXByteCnt_B = 0;
}
//1 Normal State
else if(pDM_SWAT_Table->try_flag == 0)
{
if(TrafficLoad == TRAFFIC_HIGH)
{
if(PlatformDivision64(curTxOkCnt+curRxOkCnt, 2) > 1875000)
TrafficLoad = TRAFFIC_HIGH;
else
TrafficLoad = TRAFFIC_LOW;
}
else if(TrafficLoad == TRAFFIC_LOW)
{
if(PlatformDivision64(curTxOkCnt+curRxOkCnt, 2) > 1875000)
TrafficLoad = TRAFFIC_HIGH;
else
TrafficLoad = TRAFFIC_LOW;
}
if(TrafficLoad == TRAFFIC_HIGH)
pDM_SWAT_Table->bTriggerAntennaSwitch = 0;
//RT_TRACE(COMP_SWAS, DBG_LOUD, ("Normal:TrafficLoad = %llu\n", curTxOkCnt+curRxOkCnt));
//Prepare To Try Antenna
nextAntenna = (pDM_SWAT_Table->CurAntenna == Antenna_A)? Antenna_B : Antenna_A;
pDM_SWAT_Table->try_flag = 1;
pHalData->RSSI_test = TRUE;
if((curRxOkCnt+curTxOkCnt) > 1000)
{
pDM_SWAT_Table->RSSI_Trying = 4;
pDM_SWAT_Table->TestMode = TP_MODE;
}
else
{
pDM_SWAT_Table->RSSI_Trying = 2;
pDM_SWAT_Table->TestMode = RSSI_MODE;
}
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: Normal State -> Begin Trying!\n"));
pHalData->RSSI_sum_A = 0;
pHalData->RSSI_cnt_A = 0;
pHalData->RSSI_sum_B = 0;
pHalData->RSSI_cnt_B = 0;
}
}
//1 4.Change TRX antenna
if(nextAntenna != pDM_SWAT_Table->CurAntenna)
{
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: Change TX Antenna!\n "));
PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, nextAntenna);
}
//1 5.Reset Statistics
pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
pDM_SWAT_Table->CurAntenna = nextAntenna;
pDM_SWAT_Table->PreRSSI = curRSSI;
//1 6.Set next timer
if(pDM_SWAT_Table->RSSI_Trying == 0)
return;
if(pDM_SWAT_Table->RSSI_Trying%2 == 0)
{
if(pDM_SWAT_Table->TestMode == TP_MODE)
{
if(TrafficLoad == TRAFFIC_HIGH)
{
PlatformSetTimer( Adapter, &pHalData->SwAntennaSwitchTimer, 10 ); //ms
RT_TRACE(COMP_SWAS, DBG_LOUD, ("dm_SW_AntennaSwitch(): Test another antenna for 10 ms\n"));
}
else if(TrafficLoad == TRAFFIC_LOW)
{
PlatformSetTimer( Adapter, &pHalData->SwAntennaSwitchTimer, 50 ); //ms
RT_TRACE(COMP_SWAS, DBG_LOUD, ("dm_SW_AntennaSwitch(): Test another antenna for 50 ms\n"));
}
}
else
{
PlatformSetTimer( Adapter, &pHalData->SwAntennaSwitchTimer, 500 ); //ms
RT_TRACE(COMP_SWAS, DBG_LOUD, ("dm_SW_AntennaSwitch(): Test another antenna for 500 ms\n"));
}
}
else
{
if(pDM_SWAT_Table->TestMode == TP_MODE)
{
if(TrafficLoad == TRAFFIC_HIGH)
PlatformSetTimer( Adapter, &pHalData->SwAntennaSwitchTimer, 90 ); //ms
else if(TrafficLoad == TRAFFIC_LOW)
PlatformSetTimer( Adapter, &pHalData->SwAntennaSwitchTimer, 100 ); //ms
}
else
PlatformSetTimer( Adapter, &pHalData->SwAntennaSwitchTimer, 500 ); //ms
}
}
//
// 20100514 Luke/Joseph:
// Callback function for 500ms antenna test trying.
//
VOID
ODM_SwAntDivChkAntSwitchCallback(
PRT_TIMER pTimer
)
{
PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
#if USE_WORKITEM
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
#endif
#if DEV_BUS_TYPE==RT_PCI_INTERFACE
#if USE_WORKITEM
PlatformScheduleWorkItem(&pHalData->SwAntennaSwitchWorkitem);
#else
odm_SwAntDivChkAntSwitch(Adapter, SWAW_STEP_DETERMINE);
#endif
#else
PlatformScheduleWorkItem(&pHalData->SwAntennaSwitchWorkitem);
#endif
}
VOID
ODM_SwAntDivChkAntSwitchWorkitemCallback(
IN PVOID pContext
)
{
PADAPTER pAdapter = (PADAPTER)pContext;
if(pAdapter->bDriverStopped)
return;
odm_SwAntDivChkAntSwitch(pAdapter, SWAW_STEP_DETERMINE);
}
//
// 20100514 Luke/Joseph:
// This function is used to gather the RSSI information for antenna testing.
// It selects the RSSI of the peer STA that we want to know.
//
VOID
ODM_SwAntDivChkPerPktRssi(
PADAPTER Adapter,
BOOLEAN bIsDefPort,
BOOLEAN bMatchBSSID,
PRT_WLAN_STA pEntry,
PRT_RFD pRfd
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
BOOLEAN bCount = FALSE;
pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
if(pHalData->RSSI_target==NULL && bIsDefPort && bMatchBSSID)
bCount = TRUE;
else if(pHalData->RSSI_target!=NULL && pEntry!=NULL && pHalData->RSSI_target==pEntry)
bCount = TRUE;
if(bCount)
{
//1 RSSI for SW Antenna Switch
if(pDM_SWAT_Table->CurAntenna == Antenna_A)
{
pHalData->RSSI_sum_A += pRfd->Status.RxPWDBAll;
pHalData->RSSI_cnt_A++;
}
else
{
pHalData->RSSI_sum_B += pRfd->Status.RxPWDBAll;
pHalData->RSSI_cnt_B++;
}
}
}
VOID
odm_SwAntDivInit(
IN PADAPTER Adapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS:Init SW Antenna Switch\n"));
pHalData->RSSI_sum_A = 0;
pHalData->RSSI_cnt_A = 0;
pHalData->RSSI_sum_B = 0;
pHalData->RSSI_cnt_B = 0;
pDM_SWAT_Table->CurAntenna = Antenna_A;
pDM_SWAT_Table->PreAntenna = Antenna_A;
pDM_SWAT_Table->try_flag = 0xff;
pDM_SWAT_Table->PreRSSI = 0;
pDM_SWAT_Table->SWAS_NoLink_State = 0;
pDM_SWAT_Table->bTriggerAntennaSwitch = 0;
pDM_SWAT_Table->SelectAntennaMap=0xAA;
pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = PlatformEFIORead4Byte(Adapter, 0x860);
}
//============================================================
//#pragma mark --RSSI Monitor --
//3============================================================
//3 RSSI Monitor
//3============================================================
VOID
odm_RSSIMonitorInit(
IN PADAPTER Adapter
)
{
}
VOID
odm_RSSIMonitorCheck(
IN PADAPTER Adapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
PRT_WLAN_STA pEntry;
u1Byte i;
s4Byte tmpEntryMaxPWDB=0, tmpEntryMinPWDB=0xffff;
RTPRINT(FDM, DM_PWDB, ("pHalData->UndecoratedSmoothedPWDB = 0x%x( %d)\n",
pHalData->UndecoratedSmoothedPWDB,
pHalData->UndecoratedSmoothedPWDB));
for(i = 0; i < ASSOCIATE_ENTRY_NUM; i++)
{
if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
{
pEntry = AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i);
}
else
{
pEntry = AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i);
}
if(pEntry!=NULL)
{
if(pEntry->bAssociated)
{
RTPRINT_ADDR(FDM, DM_PWDB, ("pEntry->MacAddr ="), pEntry->MacAddr);
RTPRINT(FDM, DM_PWDB, ("pEntry->rssi = 0x%x(%d)\n",
pEntry->rssi_stat.UndecoratedSmoothedPWDB,
pEntry->rssi_stat.UndecoratedSmoothedPWDB));
if(pEntry->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
tmpEntryMinPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
if(pEntry->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
tmpEntryMaxPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
}
}
else
{
break;
}
}
if(tmpEntryMaxPWDB != 0) // If associated entry is found
{
pHalData->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
RTPRINT(FDM, DM_PWDB, ("EntryMaxPWDB = 0x%x(%d)\n",
tmpEntryMaxPWDB, tmpEntryMaxPWDB));
}
else
{
pHalData->EntryMaxUndecoratedSmoothedPWDB = 0;
}
if(tmpEntryMinPWDB != 0xffff) // If associated entry is found
{
pHalData->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
RTPRINT(FDM, DM_PWDB, ("EntryMinPWDB = 0x%x(%d)\n",
tmpEntryMinPWDB, tmpEntryMinPWDB));
}
else
{
pHalData->EntryMinUndecoratedSmoothedPWDB = 0;
}
// Indicate Rx signal strength to FW.
if(Adapter->MgntInfo.bUseRAMask)
{
u1Byte H2C_Parameter[3] ={0};
// DbgPrint("RxSS: %lx =%ld\n", pHalData->UndecoratedSmoothedPWDB, pHalData->UndecoratedSmoothedPWDB);
H2C_Parameter[2] = (u1Byte)(pHalData->UndecoratedSmoothedPWDB & 0xFF);
H2C_Parameter[1] = 0x20; // fw v12 cmdid 5:use max macid ,for nic ,default macid is 0 ,max macid is 1
FillH2CCmd(Adapter, H2C_RSSI_REPORT(Adapter), 3, H2C_Parameter);
}
else
{
PlatformEFIOWrite1Byte(Adapter, 0x4fe, (u1Byte)pHalData->UndecoratedSmoothedPWDB);
//DbgPrint("0x4fe write %x %d\n", pHalData->UndecoratedSmoothedPWDB, pHalData->UndecoratedSmoothedPWDB);
}
}
VOID
odm_Init_RSSIForDM(
PADAPTER Adapter
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
pHalData->PacketMap = 0;
pHalData->ValidBit = 0;
}
VOID
Process_RSSIForDM(
PADAPTER Adapter,
PRT_RFD pRfd,
PRT_WLAN_STA pEntry,
pu1Byte pDesc
)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
s4Byte UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK, UndecoratedSmoothedOFDM, RSSI_Ave;
s4Byte RxRSSIPercentage[2];
u1Byte isCCKrate=0;
u1Byte RSSI_max, RSSI_min, i;
u4Byte OFDM_pkt=0;
u4Byte Weighting=0;
pPD_T pDM_PDTable = &Adapter->DM_PDTable;
isCCKrate = RX_HAL_IS_CCK_RATE(Adapter, pDesc);
if(!pRfd->Status.bPacketMatchBSSID)
{
return;
}
if(pEntry)
{
UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK;
UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM;
UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
for (i=0; i<2; i++)
RxRSSIPercentage[i] = pEntry->rssi_stat.RxRSSIPercentage[i];
}
else
{
UndecoratedSmoothedCCK = pHalData->UndecoratedSmoothedCCK;
UndecoratedSmoothedOFDM = pHalData->UndecoratedSmoothedOFDM;
UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB;
}
if(pRfd->Status.bPacketToSelf || pRfd->Status.bPacketBeacon)
{
if(!isCCKrate)
{
pDM_PDTable->OFDM_Pkt_Cnt++;
if(pRfd->Status.RxMIMOSignalStrength[1] == 0)
RSSI_Ave = pRfd->Status.RxMIMOSignalStrength[0];
else
{
//DbgPrint("pRfd->Status.RxMIMOSignalStrength[0] = %d, pRfd->Status.RxMIMOSignalStrength[1] = %d \n",
//pRfd->Status.RxMIMOSignalStrength[0], pRfd->Status.RxMIMOSignalStrength[1]);
if(pRfd->Status.RxMIMOSignalStrength[0] > pRfd->Status.RxMIMOSignalStrength[1])
{
RSSI_max = pRfd->Status.RxMIMOSignalStrength[0];
RSSI_min = pRfd->Status.RxMIMOSignalStrength[1];
}
else
{
RSSI_max = pRfd->Status.RxMIMOSignalStrength[1];
RSSI_min = pRfd->Status.RxMIMOSignalStrength[0];
}
if((RSSI_max -RSSI_min) < 3)
RSSI_Ave = RSSI_max;
else if((RSSI_max -RSSI_min) < 6)
RSSI_Ave = RSSI_max - 1;
else if((RSSI_max -RSSI_min) < 10)
RSSI_Ave = RSSI_max - 2;
else
RSSI_Ave = RSSI_max - 3;
}
//1 Process OFDM RSSI
if(UndecoratedSmoothedOFDM <= 0) // initialize
{
UndecoratedSmoothedOFDM = pRfd->Status.RxPWDBAll;
}
else
{
if(pRfd->Status.RxPWDBAll > (u4Byte)UndecoratedSmoothedOFDM)
{
UndecoratedSmoothedOFDM =
( ((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) +
(RSSI_Ave)) /(Rx_Smooth_Factor);
UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1;
}
else
{
UndecoratedSmoothedOFDM =
( ((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) +
(RSSI_Ave)) /(Rx_Smooth_Factor);
}
}
if(pEntry)
{
pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0;
pEntry->rssi_stat.OFDM_Pkt_Cnt++;
}
else
{
pHalData->PacketMap = (pHalData->PacketMap<<1) | BIT0;
pHalData->OFDM_Pkt_Cnt++;
}
//2011.09.05 Luke Lee: Process two path RSSI for 92C path diversity
if(pEntry)
{
//RT_TRACE( COMP_DIG, DBG_LOUD, ("pEntry: Per Path RSSI\n"));
for (i=0; i<2; i++)
{
if(RxRSSIPercentage[i] <= 0) // initialize
{
RxRSSIPercentage[i] = pRfd->Status.RxMIMOSignalStrength[i];
}
else
{
if(pRfd->Status.RxMIMOSignalStrength[i] > (u4Byte) RxRSSIPercentage[i])
{
RxRSSIPercentage[i] =
( ((RxRSSIPercentage[i])*(Rx_Smooth_Factor-1)) +
(pRfd->Status.RxMIMOSignalStrength[i])) /(Rx_Smooth_Factor);
RxRSSIPercentage[i] = RxRSSIPercentage[i] + 1;
}
else
{
RxRSSIPercentage[i] =
( ((RxRSSIPercentage[i])*(Rx_Smooth_Factor-1)) +
(pRfd->Status.RxMIMOSignalStrength[i])) /(Rx_Smooth_Factor);
}
}
pEntry->rssi_stat.RxRSSIPercentage[i] = RxRSSIPercentage[i];
}
}
}
else
{
pDM_PDTable->CCK_Pkt_Cnt++;
RSSI_Ave = pRfd->Status.RxPWDBAll;
//1 Process CCK RSSI
if(UndecoratedSmoothedCCK <= 0) // initialize
{
UndecoratedSmoothedCCK = pRfd->Status.RxPWDBAll;
}
else
{
if(pRfd->Status.RxPWDBAll > (u4Byte)UndecoratedSmoothedCCK)
{
UndecoratedSmoothedCCK =
( ((UndecoratedSmoothedCCK)*(Rx_Smooth_Factor-1)) +
(pRfd->Status.RxPWDBAll)) /(Rx_Smooth_Factor);
UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1;
}
else
{
UndecoratedSmoothedCCK =
( ((UndecoratedSmoothedCCK)*(Rx_Smooth_Factor-1)) +
(pRfd->Status.RxPWDBAll)) /(Rx_Smooth_Factor);
}
}
if(pEntry)
{
pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1;
pEntry->rssi_stat.CCK_Pkt_Cnt++;
}
else
{
pHalData->PacketMap = pHalData->PacketMap<<1;
pHalData->CCK_Pkt_Cnt++;
}
}
if(pEntry)
{
//2011.07.28 LukeLee: modified to prevent unstable CCK RSSI
if(pEntry->rssi_stat.ValidBit >= 64)
pEntry->rssi_stat.ValidBit = 64;
else
pEntry->rssi_stat.ValidBit++;
for(i=0; i<pEntry->rssi_stat.ValidBit; i++)
OFDM_pkt += (u1Byte)(pEntry->rssi_stat.PacketMap>>i)&BIT0;
if(pHalData->ValidBit == 64)
{
Weighting = ((OFDM_pkt<<4) > 64)?64:(OFDM_pkt<<4);
UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6;
}
else
{
if(pHalData->ValidBit != 0)
UndecoratedSmoothedPWDB = (OFDM_pkt*UndecoratedSmoothedOFDM+(pHalData->ValidBit-OFDM_pkt)*UndecoratedSmoothedCCK)/pHalData->ValidBit;
else
UndecoratedSmoothedPWDB = 0;
}
pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK;
pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM;
pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB;
//DbgPrint("OFDM_pkt=%d, Weighting=%d\n", OFDM_pkt, Weighting);
//DbgPrint("UndecoratedSmoothedOFDM=%d, UndecoratedSmoothedPWDB=%d, UndecoratedSmoothedCCK=%d\n",
// UndecoratedSmoothedOFDM, UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK);
}
else
{
//2011.07.28 LukeLee: modified to prevent unstable CCK RSSI
if(pHalData->ValidBit >= 64)
pHalData->ValidBit = 64;
else
pHalData->ValidBit++;
for(i=0; i<pHalData->ValidBit; i++)
OFDM_pkt += (u1Byte)(pHalData->PacketMap>>i)&BIT0;
if(pHalData->ValidBit == 64)
{
Weighting = ((OFDM_pkt<<4) > 64)?64:(OFDM_pkt<<4);
UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6;
}
else
{
if(pHalData->ValidBit != 0)
UndecoratedSmoothedPWDB = (OFDM_pkt*UndecoratedSmoothedOFDM+(pHalData->ValidBit-OFDM_pkt)*UndecoratedSmoothedCCK)/pHalData->ValidBit;
else
UndecoratedSmoothedPWDB = 0;
}
//DbgPrint("ValidBit = 0x%x\n",pHalData->ValidBit);
//DbgPrint("OFDM_pkt=%d, Weighting=%d, UndecoratedSmoothedPWDB=%d\n",
// OFDM_pkt, Weighting, UndecoratedSmoothedPWDB);
pHalData->UndecoratedSmoothedCCK = UndecoratedSmoothedCCK;
pHalData->UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM;
pHalData->UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB;
}
}
}
//#pragma mark --PSD Monitor --
//3============================================================
//3 PSD Monitor
//3============================================================
VOID
odm_PSDMonitorInit(
PADAPTER Adapter)
{
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
//PSD function is only applied in 2.4G in 92D -------add by Gary
if(IS_HARDWARE_TYPE_8192D(Adapter))
{
if(pHalData->CurrentBandType92D != BAND_ON_2_4G)
return;
}
//PSD Monitor Setting
//Which path in ADC/DAC is turnned on for PSD: both I/Q
PHY_SetBBReg(Adapter, 0x808, BIT10|BIT11, 0x3);
//Ageraged number: 8
PHY_SetBBReg(Adapter, 0x808, BIT12|BIT13, 0x1);
pHalData->bPSDinProcess = FALSE;
pHalData->bPSDactive = FALSE;
pHalData->bBTTurnOff = FALSE;
//Set Debug Port
//PHY_SetBBReg(Adapter, 0x908, bMaskDWord, 0x803);
//PHY_SetBBReg(Adapter, 0xB34, bMaskByte0, 0x00); // pause PSD
//PHY_SetBBReg(Adapter, 0xB38, bMaskByte0, 10); //rescan
//PHY_SetBBReg(Adapter, 0xB38, bMaskByte1, 0x32); // PSDDelay
//PHY_SetBBReg(Adapter, 0xB38, bMaskByte2|bMaskByte3, 100); //interval
//PlatformSetTimer( Adapter, &pHalData->PSDTriggerTimer, 0); //ms
}
u4Byte ConvertTo_dB(u4Byte Value)
{
u1Byte i;
u1Byte j;
u4Byte dB;
Value = Value & 0xFFFF;
for (i=0;i<8;i++)
{
if (Value <= dB_Invert_Table[i][11])
{
break;
}
}
if (i >= 8)
{
return (96); // maximum 96 dB
}
for (j=0;j<12;j++)
{
if (Value <= dB_Invert_Table[i][j])
{
break;
}
}
dB = i*12 + j + 1;
return (dB);
}
VOID
odm_PSDMonitorCallback(
PRT_TIMER pTimer
)
{
#if USE_WORKITEM
PADAPTER Adapter = (PADAPTER)pTimer->Adapter; // Add by Gary
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
#else
PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
#endif
#if USE_WORKITEM && ( DEV_BUS_TYPE == RT_PCI_INTERFACE || DEV_BUS_TYPE == RT_USB_INTERFACE )
PlatformScheduleWorkItem(&pHalData->PSDMonitorWorkitem);
#else
odm_PSDMonitor(Adapter);
#endif
}
VOID
odm_PSDMonitorWorkItemCallback(
IN PVOID pContext
)
{
PADAPTER Adapter = (PADAPTER)pContext;
odm_PSDMonitor(Adapter);
}
VOID
ODM_PSDDbgControl(
IN PADAPTER Adapter,
IN u4Byte mode,
IN u4Byte btRssi
)
{
#if (DEV_BUS_TYPE == RT_PCI_INTERFACE)
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
RT_TRACE(COMP_PSD, DBG_LOUD, (" Monitor mode=%d, btRssi=%d\n", mode, btRssi));
if(mode)
{
pHalData->RSSI_BT = (u1Byte)btRssi;
pHalData->bUserAssignLevel = TRUE;
PlatformSetTimer( Adapter, &pHalData->PSDTimer, 0); //ms
}
else
{
PlatformCancelTimer(Adapter, &pHalData->PSDTimer);
}
#endif
}
//#pragma mark --Export Interface --
//3============================================================
//3 Export Interface
//3============================================================
VOID
ODM_DMInit(
IN PADAPTER Adapter
)
{
//same, vivi
#if (DEV_BUS_TYPE == RT_PCI_INTERFACE)|(DEV_BUS_TYPE == RT_USB_INTERFACE)
odm_PSDMonitorInit(Adapter);
if(IS_HARDWARE_TYPE_8192C(Adapter) || IS_HARDWARE_TYPE_8192D(Adapter) || IS_HARDWARE_TYPE_8723A(Adapter))
odm_RXHPInit(Adapter); // Add by Gary
#endif
odm_DIGInit(Adapter);
odm_InitDynamicTxPower(Adapter);
ODM_InitEdcaTurbo(Adapter);
odm_InitRateAdaptiveMask(Adapter);
odm_InitializeTXPowerTracking(Adapter);
odm_RSSIMonitorInit(Adapter);
//different following
if(!IS_HARDWARE_TYPE_8192D(Adapter))
{
odm_InitDynamicBBPowerSaving(Adapter);
odm_SwAntDivInit(Adapter);
}
odm_Init_RSSIForDM(Adapter);
if(IS_HARDWARE_TYPE_8192C(Adapter) || IS_HARDWARE_TYPE_8192D(Adapter) || IS_HARDWARE_TYPE_8723A(Adapter))
odm_PathDiversityInit_92C(Adapter);
}
#endif
|