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
|
/******************************************************************************
*
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
*
******************************************************************************/
#ifndef __RTL8723A_BT_COEXIST_H__
#define __RTL8723A_BT_COEXIST_H__
#include <drv_types.h>
#include "../hal/OUTSRC/odm_precomp.h"
#define __BT_C__ 1
#define __BT_HANDLEPACKET_C__ 1
#define __BT_HCI_C__ 1
#define __HALBTC87231ANT_C__ 1
#define __HALBTC87232ANT_C__ 1
#define __HALBTC8723_C__ 1
#define __HALBTCCSR1ANT_C__ 1
#define __HALBTCCSR2ANT_C__ 1
#define __HALBTCOEXIST_C__ 1
#define __HALBT_C__ 1
#ifdef __BT_C__ // COMMON/BT.h
// HEADER/PlatformDef.h
typedef enum _RT_MEDIA_STATUS {
RT_MEDIA_DISCONNECT = 0,
RT_MEDIA_CONNECT = 1
} RT_MEDIA_STATUS;
// ===== Below this line is sync from SD7 driver COMMON/BT.h =====
#define BT_TMP_BUF_SIZE 100
void BT_SignalCompensation(PADAPTER padapter, u8 *rssi_wifi, u8 *rssi_bt);
void BT_WifiScanNotify(PADAPTER padapter, u8 scanType);
void BT_WifiAssociateNotify(PADAPTER padapter, u8 action);
void BT_WifiMediaStatusNotify(PADAPTER padapter, RT_MEDIA_STATUS mstatus);
void BT_SpecialPacketNotify(PADAPTER padapter);
void BT_HaltProcess(PADAPTER padapter);
void BT_LpsLeave(PADAPTER padapter);
#define BT_HsConnectionEstablished(Adapter) _FALSE
// ===== End of sync from SD7 driver COMMON/BT.h =====
#endif // __BT_C__
#ifdef __BT_HCI_C__ // COMMON/bt_hci.h
// HEADER/SecurityType.h
#define TKIP_ENC_KEY_POS 32 //(KEK_LEN+KEK_LEN)
#define MAXRSNIELEN 256
// HEADER/QoSType.h
#if 0
//
// BSS QOS data.
// Ref: BssDscr in 8185 code. [def. in BssDscr.h]
//
typedef struct _BSS_QOS
{
// Part 0. Ref. 8185 QoS code (From Emily)
QOS_MODE bdQoSMode;
u8 bdWMMIEBuf[MAX_WMMELE_LENGTH];
OCTET_STRING bdWMMIE;
QOS_ELE_SUBTYPE EleSubType;
// Part 2. EDCA Parameter (perAC)
u8 *pWMMInfoEle;
u8 *pWMMParamEle;
// QBSS Load.
u8 QBssLoad[QBSS_LOAD_SIZE];
u8 bQBssLoadValid;
} BSS_QOS, *PBSS_QOS;
#endif
// COMMON/Protocol802_11.h
//----------------------------------------------------------------------------
// 802.11 Management frame Status Code field
//----------------------------------------------------------------------------
typedef struct _OCTET_STRING{
u8 *Octet;
u16 Length;
} OCTET_STRING, *POCTET_STRING;
//======================================================================================
// AES_CCMP specific
//======================================================================================
enum
{
AESCCMP_BLK_SIZE = 16, // # octets in an AES block
AESCCMP_MAX_PACKET = 4*512, // largest packet size
AESCCMP_N_RESERVED = 0, // reserved nonce octet value
AESCCMP_A_DATA = 0x40, // the Adata bit in the flags
AESCCMP_M_SHIFT = 3, // how much to shift the 3-bit M field
AESCCMP_L_SHIFT = 0, // how much to shift the 3-bit L field
AESCCMP_L_SIZE = 2, // size of the l(m) length field (in octets)
AESCCMP_OFFSET_SC = 22,
AESCCMP_OFFSET_DURATION = 4,
AESCCMP_OFFSET_A2 = 10,
AESCCMP_OFFSET_A4 = 24,
AESCCMP_QC_TID_MASK = 0x0f,
AESCCMP_BLK_SIZE_TOTAL = 16*16, // Added by Annie for CKIP AES MIC BSOD, 2006-08-17.
// 16*8 < 4*60 Resove to 16*16
};
//
// Key Length
//
#define PMK_LEN 32
#define PTK_LEN_TKIP 64
#define GTK_LEN 32
#define KEY_NONCE_LEN 32
// COMMON/Dot11d.h
typedef struct _CHNL_TXPOWER_TRIPLE
{
u8 FirstChnl;
u8 NumChnls;
s8 MaxTxPowerInDbm;
} CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
// ===== Below this line is sync from SD7 driver COMMON/bt_hci.h =====
#define BT_THREAD 0
#if(BT_THREAD == 1)
#define SENDTXMEHTOD 2
#else
#define SENDTXMEHTOD 1 // 0=workitem, 1= SendDirectily, 2=thread
#endif
//=============================================
// The following is for BT 3.0 + HS HCI COMMAND ERRORS CODES
//=============================================
#define Max80211PALPDUSize 1492
#define Max80211AMPASSOCLen 672
#define MinGUserPrio 4
#define MaxGUserPrio 7
#define BEUserPrio0 0
#define BEUserPrio1 3
#define Max80211BeaconPeriod 2000
#define ShortRangeModePowerMax 4
#define BT_Default_Chnl 10
#define ACLDataHeaderLen 4
#define BTTotalDataBlockNum 0x100
#define BTLocalBufNum 0x200
#define BTMaxDataBlockLen 0x800
#define BTTOTALBANDWIDTH 0x7530
#define BTMAXBANDGUBANDWIDTH 0x4e20
#define TmpLocalBufSize 0x100
#define BTSynDataPacketLength 0xff
//=============================================
#define BTMaxAuthCount 5
#define BTMaxAsocCount 5
#define MAX_LOGICAL_LINK_NUM 2 //temporarily define
#define MAX_BT_ASOC_ENTRY_NUM 2 //temporarily define
#define INVALID_PL_HANDLE 0xff
#define INVALID_ENTRY_NUM 0xff
//=============================================
#define CAM_BT_START_INDEX (HALF_CAM_ENTRY - 4) // MAX_BT_ASOC_ENTRY_NUM : 4 !!!
#define BT_HWCAM_STAR CAM_BT_START_INDEX // We used HALF_CAM_ENTRY ~ HALF_CAM_ENTRY -MAX_BT_ASOC_ENTRY_NUM
typedef enum _HCI_STATUS
{
HCI_STATUS_SUCCESS =0x00, //Success
HCI_STATUS_UNKNOW_HCI_CMD =0x01, //Unknown HCI Command
HCI_STATUS_UNKNOW_CONNECT_ID =0X02, //Unknown Connection Identifier
HCI_STATUS_HW_FAIL =0X03, //Hardware Failure
HCI_STATUS_PAGE_TIMEOUT =0X04, //Page Timeout
HCI_STATUS_AUTH_FAIL =0X05, //Authentication Failure
HCI_STATUS_PIN_OR_KEY_MISSING =0X06, //PIN or Key Missing
HCI_STATUS_MEM_CAP_EXCEED =0X07, //Memory Capacity Exceeded
HCI_STATUS_CONNECT_TIMEOUT =0X08, //Connection Timeout
HCI_STATUS_CONNECT_LIMIT =0X09, //Connection Limit Exceeded
HCI_STATUS_SYN_CONNECT_LIMIT =0X0a, //Synchronous Connection Limit To A Device Exceeded
HCI_STATUS_ACL_CONNECT_EXISTS =0X0b, //ACL Connection Already Exists
HCI_STATUS_CMD_DISALLOW =0X0c, //Command Disallowed
HCI_STATUS_CONNECT_RJT_LIMIT_RESOURCE =0X0d, //Connection Rejected due to Limited Resources
HCI_STATUS_CONNECT_RJT_SEC_REASON =0X0e, //Connection Rejected Due To Security Reasons
HCI_STATUS_CONNECT_RJT_UNACCEPT_BD_ADDR =0X0f, //Connection Rejected due to Unacceptable BD_ADDR
HCI_STATUS_CONNECT_ACCEPT_TIMEOUT =0X10, //Connection Accept Timeout Exceeded
HCI_STATUS_UNSUPPORT_FEATURE_PARA_VALUE =0X11, //Unsupported Feature or Parameter Value
HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE =0X12, //Invalid HCI Command Parameters
HCI_STATUS_REMOTE_USER_TERMINATE_CONNECT =0X13, //Remote User Terminated Connection
HCI_STATUS_REMOTE_DEV_TERMINATE_LOW_RESOURCE =0X14, //Remote Device Terminated Connection due to Low Resources
HCI_STATUS_REMOTE_DEV_TERMINATE_CONNECT_POWER_OFF =0X15, //Remote Device Terminated Connection due to Power Off
HCI_STATUS_CONNECT_TERMINATE_LOCAL_HOST =0X16, //Connection Terminated By Local Host
HCI_STATUS_REPEATE_ATTEMPT =0X17, //Repeated Attempts
HCI_STATUS_PAIR_NOT_ALLOW =0X18, //Pairing Not Allowed
HCI_STATUS_UNKNOW_LMP_PDU =0X19, //Unknown LMP PDU
HCI_STATUS_UNSUPPORT_REMOTE_LMP_FEATURE =0X1a, //Unsupported Remote Feature / Unsupported LMP Feature
HCI_STATUS_SOC_OFFSET_REJECT =0X1b, //SCO Offset Rejected
HCI_STATUS_SOC_INTERVAL_REJECT =0X1c, //SCO Interval Rejected
HCI_STATUS_SOC_AIR_MODE_REJECT =0X1d,//SCO Air Mode Rejected
HCI_STATUS_INVALID_LMP_PARA =0X1e, //Invalid LMP Parameters
HCI_STATUS_UNSPECIFIC_ERROR =0X1f, //Unspecified Error
HCI_STATUS_UNSUPPORT_LMP_PARA_VALUE =0X20, //Unsupported LMP Parameter Value
HCI_STATUS_ROLE_CHANGE_NOT_ALLOW =0X21, //Role Change Not Allowed
HCI_STATUS_LMP_RESPONSE_TIMEOUT =0X22, //LMP Response Timeout
HCI_STATUS_LMP_ERROR_TRANSACTION_COLLISION =0X23, //LMP Error Transaction Collision
HCI_STATUS_LMP_PDU_NOT_ALLOW =0X24, //LMP PDU Not Allowed
HCI_STATUS_ENCRYPTION_MODE_NOT_ALLOW =0X25, //Encryption Mode Not Acceptable
HCI_STATUS_LINK_KEY_CAN_NOT_CHANGE =0X26, //Link Key Can Not be Changed
HCI_STATUS_REQUEST_QOS_NOT_SUPPORT =0X27, //Requested QoS Not Supported
HCI_STATUS_INSTANT_PASSED =0X28, //Instant Passed
HCI_STATUS_PAIRING_UNIT_KEY_NOT_SUPPORT =0X29, //Pairing With Unit Key Not Supported
HCI_STATUS_DIFFERENT_TRANSACTION_COLLISION =0X2a, //Different Transaction Collision
HCI_STATUS_RESERVE_1 =0X2b, //Reserved
HCI_STATUS_QOS_UNACCEPT_PARA =0X2c, //QoS Unacceptable Parameter
HCI_STATUS_QOS_REJECT =0X2d, //QoS Rejected
HCI_STATUS_CHNL_CLASSIFICATION_NOT_SUPPORT =0X2e, //Channel Classification Not Supported
HCI_STATUS_INSUFFICIENT_SECURITY =0X2f, //Insufficient Security
HCI_STATUS_PARA_OUT_OF_RANGE =0x30, //Parameter Out Of Mandatory Range
HCI_STATUS_RESERVE_2 =0X31, //Reserved
HCI_STATUS_ROLE_SWITCH_PENDING =0X32, //Role Switch Pending
HCI_STATUS_RESERVE_3 =0X33, //Reserved
HCI_STATUS_RESERVE_SOLT_VIOLATION =0X34, //Reserved Slot Violation
HCI_STATUS_ROLE_SWITCH_FAIL =0X35, //Role Switch Failed
HCI_STATUS_EXTEND_INQUIRY_RSP_TOO_LARGE =0X36, //Extended Inquiry Response Too Large
HCI_STATUS_SEC_SIMPLE_PAIRING_NOT_SUPPORT =0X37, //Secure Simple Pairing Not Supported By Host.
HCI_STATUS_HOST_BUSY_PAIRING =0X38, //Host Busy - Pairing
HCI_STATUS_CONNECT_REJ_NOT_SUIT_CHNL_FOUND =0X39, //Connection Rejected due to No Suitable Channel Found
HCI_STATUS_CONTROLLER_BUSY =0X3a //CONTROLLER BUSY
} HCI_STATUS,*PHCI_STATUS;
//=============================================
// The following is for BT 3.0 + HS HCI COMMAND
//=============================================
//bit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// | OCF | OGF |
//
//OGF 0x01
#define OGF_LINK_CONTROL_COMMANDS 0x01
typedef enum _LINK_CONTROL_COMMANDS
{
HCI_INQUIRY =0x0001,
HCI_INQUIRY_CANCEL =0x0002,
HCI_PERIODIC_INQUIRY_MODE =0x0003,
HCI_EXIT_PERIODIC_INQUIRY_MODE =0x0004,
HCI_CREATE_CONNECTION =0x0005,
HCI_DISCONNECT =0x0006,
HCI_CREATE_CONNECTION_CANCEL =0x0008,
HCI_ACCEPT_CONNECTIONREQUEST =0x0009,
HCI_REJECT_CONNECTION_REQUEST =0x000a,
HCI_LINK_KEY_REQUEST_REPLY =0x000b,
HCI_LINK_KEY_REQUEST_NEGATIVE_REPLY =0x000c,
HCI_PIN_CODE_REQUEST_REPLY =0x000d,
HCI_PIN_CODE_REQUEST_NEGATIVE_REPLY =0x000e,
HCI_CHANGE_CONNECTION_PACKET_TYPE =0x000f,
HCI_AUTHENTICATION_REQUESTED =0x0011,
HCI_SET_CONNECTION_ENCRYPTION =0x0013,
HCI_CHANGE_CONNECTION_LINK_KEY =0x0015,
HCI_MASTER_LINK_KEY =0x0017,
HCI_REMOTE_NAME_REQUEST =0x0019,
HCI_REMOTE_NAME_REQUEST_CANCEL =0x001a,
HCI_READ_REMOTE_SUPPORTED_FEATURES =0x001b,
HCI_READ_REMOTE_EXTENDED_FEATURES =0x001c,
HCI_READ_REMOTE_VERSION_INFORMATION =0x001d,
HCI_READ_CLOCK_OFFSET =0x001f,
HCI_READ_LMP_HANDLE =0x0020,
HCI_SETUP_SYNCHRONOUS_CONNECTION =0x0028,
HCI_ACCEPT_SYNCHRONOUS_CONNECTION_REQUEST =0x0029,
HCI_REJECT_SYNCHRONOUS_CONNECTION_REQUEST =0x002a,
HCI_IO_CAPABILITY_REQUEST_REPLY =0x002b,
HCI_USER_CONFIRMATION_REQUEST_REPLY =0x002c,
HCI_USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY =0x002d,
HCI_USER_PASSKEY_REQUEST_REPLY =0x002e,
HCI_USER_PASSKEY_REQUESTNEGATIVE_REPLY =0x002f,
HCI_REMOTE_OOB_DATA_REQUEST_REPLY =0x0030,
HCI_REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY =0x0033,
HCI_IO_CAPABILITY_REQUEST_NEGATIVE_REPLY =0x0034,
HCI_CREATE_PHYSICAL_LINK =0x0035,
HCI_ACCEPT_PHYSICAL_LINK =0x0036,
HCI_DISCONNECT_PHYSICAL_LINK =0x0037,
HCI_CREATE_LOGICAL_LINK =0x0038,
HCI_ACCEPT_LOGICAL_LINK =0x0039,
HCI_DISCONNECT_LOGICAL_LINK =0x003a,
HCI_LOGICAL_LINK_CANCEL =0x003b,
HCI_FLOW_SPEC_MODIFY =0x003c
} LINK_CONTROL_COMMANDS,*PLINK_CONTROL_COMMANDS;
//OGF 0x02
#define OGF_HOLD_MODE_COMMAND 0x02
typedef enum _HOLD_MODE_COMMAND
{
HCI_HOLD_MODE =0x0001,
HCI_SNIFF_MODE =0x0002,
HCI_EXIT_SNIFF_MODE =0x0003,
HCI_PARK_STATE =0x0005,
HCI_EXIT_PARK_STATE =0x0006,
HCI_QOS_SETUP =0x0007,
HCI_ROLE_DISCOVERY =0x0009,
HCI_SWITCH_ROLE =0x000b,
HCI_READ_LINK_POLICY_SETTINGS =0x000c,
HCI_WRITE_LINK_POLICY_SETTINGS =0x000d,
HCI_READ_DEFAULT_LINK_POLICY_SETTINGS =0x000e,
HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS =0x000f,
HCI_FLOW_SPECIFICATION =0x0010,
HCI_SNIFF_SUBRATING =0x0011
} HOLD_MODE_COMMAND,*PHOLD_MODE_COMMAND;
//OGF 0x03
#define OGF_SET_EVENT_MASK_COMMAND 0x03
typedef enum _SET_EVENT_MASK_COMMAND
{
HCI_SET_EVENT_MASK =0x0001,
HCI_RESET =0x0003,
HCI_SET_EVENT_FILTER =0x0005,
HCI_FLUSH =0x0008,
HCI_READ_PIN_TYPE =0x0009,
HCI_WRITE_PIN_TYPE =0x000a,
HCI_CREATE_NEW_UNIT_KEY =0x000b,
HCI_READ_STORED_LINK_KEY =0x000d,
HCI_WRITE_STORED_LINK_KEY =0x0011,
HCI_DELETE_STORED_LINK_KEY =0x0012,
HCI_WRITE_LOCAL_NAME =0x0013,
HCI_READ_LOCAL_NAME =0x0014,
HCI_READ_CONNECTION_ACCEPT_TIMEOUT =0x0015,
HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT =0x0016,
HCI_READ_PAGE_TIMEOUT =0x0017,
HCI_WRITE_PAGE_TIMEOUT =0x0018,
HCI_READ_SCAN_ENABLE =0x0019,
HCI_WRITE_SCAN_ENABLE =0x001a,
HCI_READ_PAGE_SCAN_ACTIVITY =0x001b,
HCI_WRITE_PAGE_SCAN_ACTIVITY =0x001c,
HCI_READ_INQUIRY_SCAN_ACTIVITY =0x001d,
HCI_WRITE_INQUIRY_SCAN_ACTIVITY =0x001e,
HCI_READ_AUTHENTICATION_ENABLE =0x001f,
HCI_WRITE_AUTHENTICATION_ENABLE =0x0020,
HCI_READ_CLASS_OF_DEVICE =0x0023,
HCI_WRITE_CLASS_OF_DEVICE =0x0024,
HCI_READ_VOICE_SETTING =0x0025,
HCI_WRITE_VOICE_SETTING =0x0026,
HCI_READ_AUTOMATIC_FLUSH_TIMEOUT =0x0027,
HCI_WRITE_AUTOMATIC_FLUSH_TIMEOUT =0x0028,
HCI_READ_NUM_BROADCAST_RETRANSMISSIONS =0x0029,
HCI_WRITE_NUM_BROADCAST_RETRANSMISSIONS =0x002a,
HCI_READ_HOLD_MODE_ACTIVITY =0x002b,
HCI_WRITE_HOLD_MODE_ACTIVITY =0x002c,
HCI_READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE =0x002e,
HCI_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE =0x002f,
HCI_SET_CONTROLLER_TO_HOST_FLOW_CONTROL =0x0031,
HCI_HOST_BUFFER_SIZE =0x0033,
HCI_HOST_NUMBER_OF_COMPLETED_PACKETS =0x0035,
HCI_READ_LINK_SUPERVISION_TIMEOUT =0x0036,
HCI_WRITE_LINK_SUPERVISION_TIMEOUT =0x0037,
HCI_READ_NUMBER_OF_SUPPORTED_IAC =0x0038,
HCI_READ_CURRENT_IAC_LAP =0x0039,
HCI_WRITE_CURRENT_IAC_LAP =0x003a,
HCI_READ_PAGE_SCAN_MODE =0x003d,
HCI_WRITE_PAGE_SCAN_MODE =0x003e,
HCI_SET_AFH_HOST_CHANNEL_CLASSIFICATION =0x003f,
HCI_READ_INQUIRY_SCAN_TYPE =0x0042,
HCI_WRITE_INQUIRY_SCAN_TYPE =0x0043,
HCI_READ_INQUIRY_MODE =0x0044,
HCI_WRITE_INQUIRY_MODE =0x0045,
HCI_READ_PAGE_SCAN_TYPE =0x0046,
HCI_WRITE_PAGE_SCAN_TYPE =0x0047,
HCI_READ_AFH_CHANNEL_ASSESSMENT_MODE =0x0048,
HCI_WRITE_AFH_CHANNEL_ASSESSMENT_MODE =0x0049,
HCI_READ_EXTENDED_INQUIRY_RESPONSE =0x0051,
HCI_WRITE_EXTENDED_INQUIRY_RESPONSE =0x0052,
HCI_REFRESH_ENCRYPTION_KEY =0x0053,
HCI_READ_SIMPLE_PAIRING_MODE =0x0055,
HCI_WRITE_SIMPLE_PAIRING_MODE =0x0056,
HCI_READ_LOCAL_OOB_DATA =0x0057,
HCI_READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL =0x0058,
HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL =0x0059,
HCI_READ_DEFAULT_ERRONEOUS_DATA_REPORTING =0x005a,
HCI_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING =0x005b,
HCI_ENHANCED_FLUSH =0x005f,
HCI_SEND_KEYPRESS_NOTIFICATION =0x0060,
HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT =0x0061,
HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT =0x0062,
HCI_SET_EVENT_MASK_PAGE_2 =0x0063,
HCI_READ_LOCATION_DATA =0x0064,
HCI_WRITE_LOCATION_DATA =0x0065,
HCI_READ_FLOW_CONTROL_MODE =0x0066,
HCI_WRITE_FLOW_CONTROL_MODE =0x0067,
HCI_READ_ENHANCE_TRANSMIT_POWER_LEVEL =0x0068,
HCI_READ_BEST_EFFORT_FLUSH_TIMEOUT =0x0069,
HCI_WRITE_BEST_EFFORT_FLUSH_TIMEOUT =0x006a,
HCI_SHORT_RANGE_MODE =0x006b
}SET_EVENT_MASK_COMMAND,*PSET_EVENT_MASK_COMMAND;
//OGF 0x04
#define OGF_INFORMATIONAL_PARAMETERS 0x04
typedef enum _INFORMATIONAL_PARAMETERS
{
HCI_READ_LOCAL_VERSION_INFORMATION =0x0001,
HCI_READ_LOCAL_SUPPORTED_COMMANDS =0x0002,
HCI_READ_LOCAL_SUPPORTED_FEATURES =0x0003,
HCI_READ_LOCAL_EXTENDED_FEATURES =0x0004,
HCI_READ_BUFFER_SIZE =0x0005,
HCI_READ_BD_ADDR =0x0009,
HCI_READ_DATA_BLOCK_SIZE =0x000a
} INFORMATIONAL_PARAMETERS,*PINFORMATIONAL_PARAMETERS;
//OGF 0x05
#define OGF_STATUS_PARAMETERS 0x05
typedef enum _STATUS_PARAMETERS
{
HCI_READ_FAILED_CONTACT_COUNTER =0x0001,
HCI_RESET_FAILED_CONTACT_COUNTER =0x0002,
HCI_READ_LINK_QUALITY =0x0003,
HCI_READ_RSSI =0x0005,
HCI_READ_AFH_CHANNEL_MAP =0x0006,
HCI_READ_CLOCK =0x0007,
HCI_READ_ENCRYPTION_KEY_SIZE =0x0008,
HCI_READ_LOCAL_AMP_INFO =0x0009,
HCI_READ_LOCAL_AMP_ASSOC =0x000a,
HCI_WRITE_REMOTE_AMP_ASSOC =0x000b
} STATUS_PARAMETERS,*PSTATUS_PARAMETERS;
//OGF 0x06
#define OGF_TESTING_COMMANDS 0x06
typedef enum _TESTING_COMMANDS
{
HCI_READ_LOOPBACK_MODE =0x0001,
HCI_WRITE_LOOPBACK_MODE =0x0002,
HCI_ENABLE_DEVICE_UNDER_TEST_MODE =0x0003,
HCI_WRITE_SIMPLE_PAIRING_DEBUG_MODE =0x0004,
HCI_ENABLE_AMP_RECEIVER_REPORTS =0x0007,
HCI_AMP_TEST_END =0x0008,
HCI_AMP_TEST_COMMAND =0x0009
} TESTING_COMMANDS,*PTESTING_COMMANDS;
//OGF 0x3f
#define OGF_EXTENSION 0X3f
typedef enum _HCI_EXTENSION_COMMANDS
{
HCI_SET_ACL_LINK_DATA_FLOW_MODE =0x0010,
HCI_SET_ACL_LINK_STATUS =0x0020,
HCI_SET_SCO_LINK_STATUS =0x0030,
HCI_SET_RSSI_VALUE =0x0040,
HCI_SET_CURRENT_BLUETOOTH_STATUS =0x0041,
//The following is for RTK8723
HCI_EXTENSION_VERSION_NOTIFY =0x0100,
HCI_LINK_STATUS_NOTIFY =0x0101,
HCI_BT_OPERATION_NOTIFY =0x0102,
HCI_ENABLE_WIFI_SCAN_NOTIFY =0x0103,
//The following is for IVT
HCI_WIFI_CURRENT_CHANNEL =0x0300,
HCI_WIFI_CURRENT_BANDWIDTH =0x0301,
HCI_WIFI_CONNECTION_STATUS =0x0302,
} HCI_EXTENSION_COMMANDS,*PHCI_EXTENSION_COMMANDS;
typedef enum _BT_SPEC
{
BT_SPEC_1_0_b =0x00,
BT_SPEC_1_1 =0x01,
BT_SPEC_1_2 =0x02,
BT_SPEC_2_0_EDR =0x03,
BT_SPEC_2_1_EDR =0x04,
BT_SPEC_3_0_HS =0x05,
BT_SPEC_4_0 =0x06
} BT_SPEC,*PBT_SPEC;
//=============================================
// The following is for BT 3.0 + HS EVENTS
//=============================================
typedef enum _HCI_EVENT
{
HCI_EVENT_INQUIRY_COMPLETE =0x01,
HCI_EVENT_INQUIRY_RESULT =0x02,
HCI_EVENT_CONNECTION_COMPLETE =0x03,
HCI_EVENT_CONNECTION_REQUEST =0x04,
HCI_EVENT_DISCONNECTION_COMPLETE =0x05,
HCI_EVENT_AUTHENTICATION_COMPLETE =0x06,
HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE =0x07,
HCI_EVENT_ENCRYPTION_CHANGE =0x08,
HCI_EVENT_CHANGE_LINK_KEY_COMPLETE =0x09,
HCI_EVENT_MASTER_LINK_KEY_COMPLETE =0x0a,
HCI_EVENT_READ_REMOTE_SUPPORT_FEATURES_COMPLETE =0x0b,
HCI_EVENT_READ_REMOTE_VER_INFO_COMPLETE =0x0c,
HCI_EVENT_QOS_SETUP_COMPLETE =0x0d,
HCI_EVENT_COMMAND_COMPLETE =0x0e,
HCI_EVENT_COMMAND_STATUS =0x0f,
HCI_EVENT_HARDWARE_ERROR =0x10,
HCI_EVENT_FLUSH_OCCRUED =0x11,
HCI_EVENT_ROLE_CHANGE =0x12,
HCI_EVENT_NUMBER_OF_COMPLETE_PACKETS =0x13,
HCI_EVENT_MODE_CHANGE =0x14,
HCI_EVENT_RETURN_LINK_KEYS =0x15,
HCI_EVENT_PIN_CODE_REQUEST =0x16,
HCI_EVENT_LINK_KEY_REQUEST =0x17,
HCI_EVENT_LINK_KEY_NOTIFICATION =0x18,
HCI_EVENT_LOOPBACK_COMMAND =0x19,
HCI_EVENT_DATA_BUFFER_OVERFLOW =0x1a,
HCI_EVENT_MAX_SLOTS_CHANGE =0x1b,
HCI_EVENT_READ_CLOCK_OFFSET_COMPLETE =0x1c,
HCI_EVENT_CONNECT_PACKET_TYPE_CHANGE =0x1d,
HCI_EVENT_QOS_VIOLATION =0x1e,
HCI_EVENT_PAGE_SCAN_REPETITION_MODE_CHANGE =0x20,
HCI_EVENT_FLOW_SEPC_COMPLETE =0x21,
HCI_EVENT_INQUIRY_RESULT_WITH_RSSI =0x22,
HCI_EVENT_READ_REMOTE_EXT_FEATURES_COMPLETE =0x23,
HCI_EVENT_SYNC_CONNECT_COMPLETE =0x2c,
HCI_EVENT_SYNC_CONNECT_CHANGE =0x2d,
HCI_EVENT_SNIFFER_SUBRATING =0x2e,
HCI_EVENT_EXTENTED_INQUIRY_RESULT =0x2f,
HCI_EVENT_ENCRYPTION_KEY_REFLASH_COMPLETE =0x30,
HCI_EVENT_IO_CAPIBILITY_COMPLETE =0x31,
HCI_EVENT_IO_CAPIBILITY_RESPONSE =0x32,
HCI_EVENT_USER_CONFIRMTION_REQUEST =0x33,
HCI_EVENT_USER_PASSKEY_REQUEST =0x34,
HCI_EVENT_REMOTE_OOB_DATA_REQUEST =0x35,
HCI_EVENT_SIMPLE_PAIRING_COMPLETE =0x36,
HCI_EVENT_LINK_SUPERVISION_TIMEOUT_CHANGE =0x38,
HCI_EVENT_ENHANCED_FLUSH_COMPLETE =0x39,
HCI_EVENT_USER_PASSKEY_NOTIFICATION =0x3b,
HCI_EVENT_KEYPRESS_NOTIFICATION =0x3c,
HCI_EVENT_REMOTE_HOST_SUPPORT_FEATURES_NOTIFICATION =0x3d,
HCI_EVENT_PHY_LINK_COMPLETE =0x40,
HCI_EVENT_CHANNEL_SELECT =0x41,
HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE =0x42,
HCI_EVENT_PHY_LINK_LOSS_EARLY_WARNING =0x43,
HCI_EVENT_PHY_LINK_RECOVER =0x44,
HCI_EVENT_LOGICAL_LINK_COMPLETE =0x45,
HCI_EVENT_DISCONNECT_LOGICAL_LINK_COMPLETE =0x46,
HCI_EVENT_FLOW_SPEC_MODIFY_COMPLETE =0x47,
HCI_EVENT_NUM_OF_COMPLETE_DATA_BLOCKS =0x48,
HCI_EVENT_AMP_START_TEST =0x49,
HCI_EVENT_AMP_TEST_END =0x4a,
HCI_EVENT_AMP_RECEIVER_REPORT =0x4b,
HCI_EVENT_SHORT_RANGE_MODE_CHANGE_COMPLETE =0x4c,
HCI_EVENT_AMP_STATUS_CHANGE =0x4d,
HCI_EVENT_EXTENSION_RTK =0xfe,
HCI_EVENT_EXTENSION_MOTO =0xff,
}HCI_EVENT, *PHCI_EVENT;
typedef enum _HCI_EXTENSION_EVENT_MOTO
{
HCI_EVENT_GET_BT_RSSI =0x01,
} HCI_EXTENSION_EVENT_MOTO, *PHCI_EXTENSION_EVENT_MOTO;
typedef enum _HCI_EXTENSION_EVENT_RTK
{
HCI_EVENT_EXT_WIFI_SCAN_NOTIFY =0x01,
} HCI_EXTENSION_EVENT_RTK, *PHCI_EXTENSION_EVENT_RTK;
typedef enum _HCI_EVENT_MASK_PAGE_2
{
EMP2_HCI_EVENT_PHY_LINK_COMPLETE =0x0000000000000001,
EMP2_HCI_EVENT_CHANNEL_SELECT =0x0000000000000002,
EMP2_HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE =0x0000000000000004,
EMP2_HCI_EVENT_PHY_LINK_LOSS_EARLY_WARNING =0x0000000000000008,
EMP2_HCI_EVENT_PHY_LINK_RECOVER =0x0000000000000010,
EMP2_HCI_EVENT_LOGICAL_LINK_COMPLETE =0x0000000000000020,
EMP2_HCI_EVENT_DISCONNECT_LOGICAL_LINK_COMPLETE =0x0000000000000040,
EMP2_HCI_EVENT_FLOW_SPEC_MODIFY_COMPLETE =0x0000000000000080,
EMP2_HCI_EVENT_NUM_OF_COMPLETE_DATA_BLOCKS =0x0000000000000100,
EMP2_HCI_EVENT_AMP_START_TEST =0x0000000000000200,
EMP2_HCI_EVENT_AMP_TEST_END =0x0000000000000400,
EMP2_HCI_EVENT_AMP_RECEIVER_REPORT =0x0000000000000800,
EMP2_HCI_EVENT_SHORT_RANGE_MODE_CHANGE_COMPLETE =0x0000000000001000,
EMP2_HCI_EVENT_AMP_STATUS_CHANGE =0x0000000000002000,
} HCI_EVENT_MASK_PAGE_2, *PHCI_EVENT_MASK_PAGE_2;
typedef enum _HCI_STATE_MACHINE
{
HCI_STATE_STARTING =0x01,
HCI_STATE_CONNECTING =0x02,
HCI_STATE_AUTHENTICATING =0x04,
HCI_STATE_CONNECTED =0x08,
HCI_STATE_DISCONNECTING =0x10,
HCI_STATE_DISCONNECTED =0x20
} HCI_STATE_MACHINE, *PHCI_STATE_MACHINE;
typedef enum _AMP_ASSOC_STRUCTURE_TYPE
{
AMP_MAC_ADDR =0x01,
AMP_PREFERRED_CHANNEL_LIST =0x02,
AMP_CONNECTED_CHANNEL =0x03,
AMP_80211_PAL_CAP_LIST =0x04,
AMP_80211_PAL_VISION =0x05,
AMP_RESERVED_FOR_TESTING =0x33
} AMP_ASSOC_STRUCTURE_TYPE, *PAMP_ASSOC_STRUCTURE_TYPE;
typedef enum _AMP_BTAP_TYPE
{
AMP_BTAP_NONE,
AMP_BTAP_CREATOR,
AMP_BTAP_JOINER
} AMP_BTAP_TYPE, *PAMP_BTAP_TYPE;
typedef enum _HCI_STATE_WITH_CMD
{
STATE_CMD_CREATE_PHY_LINK,
STATE_CMD_ACCEPT_PHY_LINK,
STATE_CMD_DISCONNECT_PHY_LINK,
STATE_CMD_CONNECT_ACCEPT_TIMEOUT,
STATE_CMD_MAC_START_COMPLETE,
STATE_CMD_MAC_START_FAILED,
STATE_CMD_MAC_CONNECT_COMPLETE,
STATE_CMD_MAC_CONNECT_FAILED,
STATE_CMD_MAC_DISCONNECT_INDICATE,
STATE_CMD_MAC_CONNECT_CANCEL_INDICATE,
STATE_CMD_4WAY_FAILED,
STATE_CMD_4WAY_SUCCESSED,
STATE_CMD_ENTER_STATE,
STATE_CMD_NO_SUCH_CMD,
} HCI_STATE_WITH_CMD, *PHCI_STATE_WITH_CMD;
typedef enum _HCI_SERVICE_TYPE
{
SERVICE_NO_TRAFFIC,
SERVICE_BEST_EFFORT,
SERVICE_GUARANTEE
} HCI_SERVICE_TYPE, *PHCI_SERVICE_TYPE;
typedef enum _HCI_TRAFFIC_MODE
{
TRAFFIC_MODE_BEST_EFFORT =0x00,
TRAFFIC_MODE_GUARANTEED_LATENCY =0x01,
TRAFFIC_MODE_GUARANTEED_BANDWIDTH =0x02,
TRAFFIC_MODE_GUARANTEED_LATENCY_AND_BANDWIDTH =0x03
} HCI_TRAFFIC_MODE, *PHCI_TRAFFIC_MODE;
#define HCIOPCODE(_OCF, _OGF) (_OGF<<10|_OCF)
#define HCIOPCODELOW(_OCF, _OGF) (u8)(HCIOPCODE(_OCF, _OGF)&0x00ff)
#define HCIOPCODEHIGHT(_OCF, _OGF) (u8)(HCIOPCODE(_OCF, _OGF)>>8)
#define TWOBYTE_HIGHTBYTE(_DATA) (u8)(_DATA>>8)
#define TWOBYTE_LOWBYTE(_DATA) (u8)(_DATA)
typedef enum _AMP_STATUS
{
AMP_STATUS_AVA_PHY_PWR_DWN = 0x0,
AMP_STATUS_BT_USE_ONLY = 0x1,
AMP_STATUS_NO_CAPACITY_FOR_BT = 0x2,
AMP_STATUS_LOW_CAPACITY_FOR_BT = 0x3,
AMP_STATUS_MEDIUM_CAPACITY_FOR_BT = 0x4,
AMP_STATUS_HIGH_CAPACITY_FOR_BT = 0x5,
AMP_STATUS_FULL_CAPACITY_FOR_BT = 0x6
} AMP_STATUS, *PAMP_STATUS;
typedef enum
{
Type_BT_4way1st = 0,
Type_BT_4way2nd = 1,
Type_BT_4way3rd = 2,
Type_BT_4way4th = 3,
Type_BT_unknow = 4
} BT_WPAMsgType;
typedef enum _BT_CONNECT_TYPE
{
BT_CONNECT_AUTH_REQ =0x00,
BT_CONNECT_AUTH_RSP =0x01,
BT_CONNECT_ASOC_REQ =0x02,
BT_CONNECT_ASOC_RSP =0x03,
BT_DISCONNECT =0x04
} BT_CONNECT_TYPE, *PBT_CONNECT_TYPE;
typedef enum _BT_LL_SERVICE_TYPE
{
BT_LL_BE = 0x01,
BT_LL_GU = 0x02
} BT_LL_SERVICE_TYPE;
typedef enum _BT_LL_FLOWSPEC
{
BT_TX_BE_FS, //TX best effort flowspec
BT_RX_BE_FS, //RX best effort flowspec
BT_TX_GU_FS, //TX guaranteed latency flowspec
BT_RX_GU_FS, //RX guaranteed latency flowspec
BT_TX_BE_AGG_FS, //TX aggregated best effort flowspec
BT_RX_BE_AGG_FS, //RX aggregated best effort flowspec
BT_TX_GU_BW_FS, //TX guaranteed bandwidth flowspec
BT_RX_GU_BW_FS, //RX guaranteed bandwidth flowspec
BT_TX_GU_LARGE_FS, //TX guaranteed latency flowspec, for testing only
BT_RX_GU_LARGE_FS, //RX guaranteed latency flowspec, for testing only
} BT_LL_FLOWSPEC;
typedef enum _BT_TRAFFIC_MODE
{
BT_MOTOR_EXT_BE = 0x00, //Best Effort. Default. for HCRP, PAN, SDP, RFCOMM-based profiles like FTP,OPP, SPP, DUN, etc.
BT_MOTOR_EXT_GUL = 0x01, //Guaranteed Latency. This type of traffic is used e.g. for HID and AVRCP.
BT_MOTOR_EXT_GUB = 0X02, //Guaranteed Bandwidth.
BT_MOTOR_EXT_GULB = 0X03 //Guaranteed Latency and Bandwidth. for A2DP and VDP.
} BT_TRAFFIC_MODE;
typedef enum _BT_TRAFFIC_MODE_PROFILE
{
BT_PROFILE_NONE,
BT_PROFILE_A2DP,
BT_PROFILE_PAN,
BT_PROFILE_HID,
BT_PROFILE_SCO
} BT_TRAFFIC_MODE_PROFILE;
typedef enum _BT_LINK_ROLE
{
BT_LINK_MASTER = 0,
BT_LINK_SLAVE = 1
} BT_LINK_ROLE;
typedef enum _BT_STATE_WPA_AUTH
{
STATE_WPA_AUTH_UNINITIALIZED,
STATE_WPA_AUTH_WAIT_PACKET_1, // Join
STATE_WPA_AUTH_WAIT_PACKET_2, // Creat
STATE_WPA_AUTH_WAIT_PACKET_3,
STATE_WPA_AUTH_WAIT_PACKET_4,
STATE_WPA_AUTH_SUCCESSED
} BT_STATE_WPA_AUTH, *PBT_STATE_WPA_AUTH;
#define BT_WPA_AUTH_TIMEOUT_PERIOD 1000
#define BTMaxWPAAuthReTransmitCoun 5
#define MAX_AMP_ASSOC_FRAG_LEN 248
#define TOTAL_ALLOCIATE_ASSOC_LEN 1000
typedef struct _HCI_FLOW_SPEC
{
u8 Identifier;
u8 ServiceType;
u16 MaximumSDUSize;
u32 SDUInterArrivalTime;
u32 AccessLatency;
u32 FlushTimeout;
} HCI_FLOW_SPEC, *PHCI_FLOW_SPEC;
typedef struct _HCI_LOG_LINK_CMD_DATA
{
u8 BtPhyLinkhandle;
u16 BtLogLinkhandle;
u8 BtTxFlowSpecID;
HCI_FLOW_SPEC Tx_Flow_Spec;
HCI_FLOW_SPEC Rx_Flow_Spec;
u32 TxPacketCount;
u32 BestEffortFlushTimeout;
u8 bLLCompleteEventIsSet;
u8 bLLCancelCMDIsSetandComplete;
} HCI_LOG_LINK_CMD_DATA, *PHCI_LOG_LINK_CMD_DATA;
typedef struct _HCI_PHY_LINK_CMD_DATA
{
//Physical_Link_Handle
u8 BtPhyLinkhandle;
u16 LinkSuperversionTimeout;
//u16 SuperTimeOutCnt;
//Dedicated_AMP_Key_Length
u8 BtAMPKeyLen;
//Dedicated_AMP_Key_Type
u8 BtAMPKeyType;
//Dedicated_AMP_Key
u8 BtAMPKey[PMK_LEN];
} HCI_PHY_LINK_CMD_DATA, *PHCI_PHY_LINK_CMD_DATA;
typedef struct _AMP_ASSOC_STRUCTURE
{
//TYPE ID
u8 TypeID;
//Length
u16 Length;
//Value
u8 Data[1];
} AMP_ASSOC_STRUCTURE, *PAMP_ASSOC_STRUCTURE;
typedef struct _AMP_PREF_CHNL_REGULATORY
{
u8 reXId;
u8 regulatoryClass;
u8 coverageClass;
} AMP_PREF_CHNL_REGULATORY, *PAMP_PREF_CHNL_REGULATORY;
typedef struct _AMP_ASSOC_CMD_DATA
{
//Physical_Link_Handle
u8 BtPhyLinkhandle;
//Length_So_Far
u16 LenSoFar;
u16 MaxRemoteASSOCLen;
//AMP_ASSOC_Remaining_Length
u16 AMPAssocRemLen;
//AMP_ASSOC_fragment
void *AMPAssocfragment;
} AMP_ASSOC_CMD_DATA, *PAMP_ASSOC_CMD_DATA;
typedef struct _HCI_LINK_INFO
{
u16 ConnectHandle;
u8 IncomingTrafficMode;
u8 OutgoingTrafficMode;
u8 BTProfile;
u8 BTCoreSpec;
s8 BT_RSSI;
u8 TrafficProfile;
u8 linkRole;
} HCI_LINK_INFO, *PHCI_LINK_INFO;
typedef struct _HCI_EXT_CONFIG
{
HCI_LINK_INFO linkInfo[MAX_BT_ASOC_ENTRY_NUM];
u8 btOperationCode;
u16 CurrentConnectHandle;
u8 CurrentIncomingTrafficMode;
u8 CurrentOutgoingTrafficMode;
s8 MIN_BT_RSSI;
u8 NumberOfHandle;
u8 NumberOfSCO;
u8 CurrentBTStatus;
u16 HCIExtensionVer;
//Bt coexist related
u8 btProfileCase;
u8 btProfileAction;
u8 bManualControl;
u8 bBTBusy;
u8 bBTA2DPBusy;
u8 bEnableWifiScanNotify;
u8 bHoldForBtOperation;
u32 bHoldPeriodCnt;
}HCI_EXT_CONFIG, *PHCI_EXT_CONFIG;
typedef struct _HCI_ACL_PACKET_DATA
{
u16 ACLDataPacketLen;
u8 SyncDataPacketLen;
u16 TotalNumACLDataPackets;
u16 TotalSyncNumDataPackets;
} HCI_ACL_PACKET_DATA, *PHCI_ACL_PACKET_DATA;
typedef struct _HCI_PHY_LINK_BSS_INFO
{
u16 bdCap; // capability information
// Qos related. Added by Annie, 2005-11-01.
// BSS_QOS BssQos; // not implement yet
} HCI_PHY_LINK_BSS_INFO, *PHCI_PHY_LINK_BSS_INFO;
typedef struct _PACKET_IRP_HCICMD_DATA
{
u16 OCF:10;
u16 OGF:6;
u8 Length;
u8 Data[1];
} PACKET_IRP_HCICMD_DATA, *PPACKET_IRP_HCICMD_DATA;
typedef struct _BT_ASOC_ENTRY
{
u8 bUsed;
u8 mAssoc;
u8 b4waySuccess;
u8 Bssid[6];
HCI_PHY_LINK_CMD_DATA PhyLinkCmdData;
HCI_LOG_LINK_CMD_DATA LogLinkCmdData[MAX_LOGICAL_LINK_NUM];
HCI_ACL_PACKET_DATA ACLPacketsData;
AMP_ASSOC_CMD_DATA AmpAsocCmdData;
OCTET_STRING BTSsid;
u8 BTSsidBuf[33];
HCI_STATUS PhyLinkDisconnectReason;
u8 bSendSupervisionPacket;
//u8 CurrentSuervisionPacketSendNum;
//u8 LastSuervisionPacketSendNum;
u32 NoRxPktCnt;
//Is Creator or Joiner
AMP_BTAP_TYPE AMPRole;
//BT current state
u8 BtCurrentState;
//BT next state
u8 BtNextState;
u8 bNeedPhysLinkCompleteEvent;
HCI_STATUS PhysLinkCompleteStatus;
u8 BTRemoteMACAddr[6];
u32 BTCapability;
u8 SyncDataPacketLen;
u16 TotalSyncNumDataPackets;
u16 TotalNumACLDataPackets;
u8 ShortRangeMode;
u8 PTK[PTK_LEN_TKIP];
u8 GTK[GTK_LEN];
u8 ANonce[KEY_NONCE_LEN];
u8 SNonce[KEY_NONCE_LEN];
u64 KeyReplayCounter;
u8 WPAAuthReplayCount;
u8 AESKeyBuf[AESCCMP_BLK_SIZE_TOTAL];
u8 PMK[PMK_LEN];
BT_STATE_WPA_AUTH BTWPAAuthState;
s32 UndecoratedSmoothedPWDB;
// Add for HW security !!
u8 HwCAMIndex; // Cam index
u8 bPeerQosSta;
u32 rxSuvpPktCnt;
}BT_ASOC_ENTRY, *PBT_ASOC_ENTRY;
typedef struct _BT_TRAFFIC_STATISTICS
{
u8 bTxBusyTraffic;
u8 bRxBusyTraffic;
u8 bIdle;
u32 TxPktCntInPeriod;
u32 RxPktCntInPeriod;
u64 TxPktLenInPeriod;
u64 RxPktLenInPeriod;
} BT_TRAFFIC_STATISTICS, *PBT_TRAFFIC_STATISTICS;
typedef struct _BT_MGNT
{
u8 bBTConnectInProgress;
u8 bLogLinkInProgress;
u8 bPhyLinkInProgress;
u8 bPhyLinkInProgressStartLL;
u8 BtCurrentPhyLinkhandle;
u16 BtCurrentLogLinkhandle;
u8 CurrentConnectEntryNum;
u8 DisconnectEntryNum;
u8 CurrentBTConnectionCnt;
BT_CONNECT_TYPE BTCurrentConnectType;
BT_CONNECT_TYPE BTReceiveConnectPkt;
u8 BTAuthCount;
u8 BTAsocCount;
u8 bStartSendSupervisionPkt;
u8 BtOperationOn;
u8 BTNeedAMPStatusChg;
u8 JoinerNeedSendAuth;
HCI_PHY_LINK_BSS_INFO bssDesc;
HCI_EXT_CONFIG ExtConfig;
u8 bNeedNotifyAMPNoCap;
u8 bCreateSpportQos;
u8 bSupportProfile;
u8 BTChannel;
u8 CheckChnlIsSuit;
u8 bBtScan;
u8 btLogoTest;
} BT_MGNT, *PBT_MGNT;
typedef struct _BT_HCI_DBG_INFO
{
u32 hciCmdCnt;
u32 hciCmdCntUnknown;
u32 hciCmdCntCreatePhyLink;
u32 hciCmdCntAcceptPhyLink;
u32 hciCmdCntDisconnectPhyLink;
u32 hciCmdPhyLinkStatus;
u32 hciCmdCntCreateLogLink;
u32 hciCmdCntAcceptLogLink;
u32 hciCmdCntDisconnectLogLink;
u32 hciCmdCntReadLocalAmpAssoc;
u32 hciCmdCntWriteRemoteAmpAssoc;
u32 hciCmdCntSetAclLinkStatus;
u32 hciCmdCntSetScoLinkStatus;
u32 hciCmdCntExtensionVersionNotify;
u32 hciCmdCntLinkStatusNotify;
} BT_HCI_DBG_INFO, *PBT_HCI_DBG_INFO;
typedef struct _BT_IRP_DBG_INFO
{
u32 irpMJCreate;
// Io Control
u32 irpIoControl;
u32 irpIoCtrlHciCmd;
u32 irpIoCtrlHciEvent;
u32 irpIoCtrlHciTxData;
u32 irpIoCtrlHciRxData;
u32 irpIoCtrlUnknown;
u32 irpIoCtrlHciTxData1s;
} BT_IRP_DBG_INFO, *PBT_IRP_DBG_INFO;
typedef struct _BT_PACKET_DBG_INFO
{
u32 btPktTxProbReq;
u32 btPktRxProbReq;
u32 btPktRxProbReqFail;
u32 btPktTxProbRsp;
u32 btPktRxProbRsp;
u32 btPktTxAuth;
u32 btPktRxAuth;
u32 btPktRxAuthButDrop;
u32 btPktTxAssocReq;
u32 btPktRxAssocReq;
u32 btPktRxAssocReqButDrop;
u32 btPktTxAssocRsp;
u32 btPktRxAssocRsp;
u32 btPktTxDisassoc;
u32 btPktRxDisassoc;
u32 btPktRxDeauth;
u32 btPktTx4way1st;
u32 btPktRx4way1st;
u32 btPktTx4way2nd;
u32 btPktRx4way2nd;
u32 btPktTx4way3rd;
u32 btPktRx4way3rd;
u32 btPktTx4way4th;
u32 btPktRx4way4th;
u32 btPktTxLinkSuperReq;
u32 btPktRxLinkSuperReq;
u32 btPktTxLinkSuperRsp;
u32 btPktRxLinkSuperRsp;
u32 btPktTxData;
u32 btPktRxData;
} BT_PACKET_DBG_INFO, *PBT_PACKET_DBG_INFO;
typedef struct _BT_DBG
{
u8 dbgCtrl;
u32 dbgProfile;
BT_HCI_DBG_INFO dbgHciInfo;
BT_IRP_DBG_INFO dbgIrpInfo;
BT_PACKET_DBG_INFO dbgBtPkt;
} BT_DBG, *PBT_DBG;
typedef struct _BT_HCI_INFO
{
//802.11 Pal version specifier
u8 BTPalVersion;
u16 BTPalCompanyID;
u16 BTPalsubversion;
//Connected channel list
u16 BTConnectChnlListLen;
u8 BTConnectChnllist[64];
//Fail contact counter
u16 FailContactCount;
//Event mask
u64 BTEventMask;
u64 BTEventMaskPage2;
//timeout var
u16 ConnAcceptTimeout;
u16 LogicalAcceptTimeout;
u16 PageTimeout;
u8 LocationDomainAware;
u16 LocationDomain;
u8 LocationDomainOptions;
u8 LocationOptions;
u8 FlowControlMode;
//Preferred channel list
u16 BtPreChnlListLen;
u8 BTPreChnllist[64];
u16 enFlush_LLH; //enhanced flush handle
u16 FLTO_LLH; //enhanced flush handle
//==========================================
//Test command only.
u8 bInTestMode;
u8 bTestIsEnd;
u8 bTestNeedReport;
u8 TestScenario;
u8 TestReportInterval;
u8 TestCtrType;
u32 TestEventType;
u16 TestNumOfFrame;
u16 TestNumOfErrFrame;
u16 TestNumOfBits;
u16 TestNumOfErrBits;
//==========================================
} BT_HCI_INFO, *PBT_HCI_INFO;
typedef struct _BT_TRAFFIC
{
// Add for check replay data
u8 LastRxUniFragNum;
u16 LastRxUniSeqNum;
//s32 EntryMaxUndecoratedSmoothedPWDB;
//s32 EntryMinUndecoratedSmoothedPWDB;
BT_TRAFFIC_STATISTICS Bt30TrafficStatistics;
} BT_TRAFFIC, *PBT_TRAFFIC;
#define RT_WORK_ITEM _workitem
#define RT_THREAD _thread_hdl_
typedef struct _BT_SECURITY
{
// WPA auth state
// May need to remove to BTSecInfo ...
//BT_STATE_WPA_AUTH BTWPAAuthState;
//u8 PMK[PMK_LEN];
RT_TIMER BTWPAAuthTimer;
OCTET_STRING RSNIE;
u8 RSNIEBuf[MAXRSNIELEN];
u8 bRegNoEncrypt;
u8 bUsedHwEncrypt; // It is define by OS version !!
} BT_SECURITY, *PBT_SECURITY;
typedef struct _BT30Info
{
PADAPTER padapter;
BT_ASOC_ENTRY BtAsocEntry[MAX_BT_ASOC_ENTRY_NUM];
BT_MGNT BtMgnt;
BT_DBG BtDbg;
BT_HCI_INFO BtHciInfo;
BT_TRAFFIC BtTraffic;
BT_SECURITY BtSec;
#if(BT_THREAD == 0)
RT_WORK_ITEM HCICmdWorkItem;
RT_TIMER BTHCICmdTimer;
#endif
#if (SENDTXMEHTOD==0)
RT_WORK_ITEM HCISendACLDataWorkItem;
RT_TIMER BTHCISendAclDataTimer;
#elif(SENDTXMEHTOD==2)
RT_THREAD BTTxThread;
#endif
RT_WORK_ITEM BTPsDisableWorkItem;
RT_WORK_ITEM BTConnectWorkItem;
RT_TIMER BTHCIDiscardAclDataTimer;
RT_TIMER BTHCIJoinTimeoutTimer;
RT_TIMER BTTestSendPacketTimer;
RT_TIMER BTSupervisionPktTimer;
RT_TIMER BTDisconnectPhyLinkTimer;
RT_TIMER BTBeaconTimer;
u8 BTBeaconTmrOn;
RT_TIMER BTPsDisableTimer;
RT_TIMER BTAuthTimeoutTimer;
RT_TIMER BTAsocTimeoutTimer;
PVOID pBtChnlList;
}BT30Info, *PBT30Info;
typedef struct _PACKET_IRP_ACL_DATA
{
u16 Handle:12;
u16 PB_Flag:2;
u16 BC_Flag:2;
u16 Length;
u8 Data[1];
} PACKET_IRP_ACL_DATA, *PPACKET_IRP_ACL_DATA;
typedef struct _PACKET_IRP_HCIEVENT_DATA
{
u8 EventCode;
u8 Length;
u8 Data[1];
} PACKET_IRP_HCIEVENT_DATA, *PPACKET_IRP_HCIEVENT_DATA;
typedef struct _COMMON_TRIPLE
{
u8 byte_1st;
u8 byte_2nd;
u8 byte_3rd;
} COMMON_TRIPLE, *PCOMMON_TRIPLE;
#define COUNTRY_STR_LEN 3 // country string len=3
#define LOCAL_PMK 0
typedef enum _HCI_WIFI_CONNECT_STATUS
{
HCI_WIFI_NOT_CONNECTED =0x0,
HCI_WIFI_CONNECTED =0x1,
HCI_WIFI_CONNECT_IN_PROGRESS =0x2,
} HCI_WIFI_CONNECT_STATUS, *PHCI_WIFI_CONNECT_STATUS;
typedef enum _HCI_EXT_BT_OPERATION
{
HCI_BT_OP_NONE = 0x0,
HCI_BT_OP_INQUIRY_START = 0x1,
HCI_BT_OP_INQUIRY_FINISH = 0x2,
HCI_BT_OP_PAGING_START = 0x3,
HCI_BT_OP_PAGING_SUCCESS = 0x4,
HCI_BT_OP_PAGING_UNSUCCESS = 0x5,
HCI_BT_OP_PAIRING_START = 0x6,
HCI_BT_OP_PAIRING_FINISH = 0x7,
HCI_BT_OP_BT_DEV_ENABLE = 0x8,
HCI_BT_OP_BT_DEV_DISABLE = 0x9,
HCI_BT_OP_MAX
} HCI_EXT_BT_OPERATION, *PHCI_EXT_BT_OPERATION;
//======================================
// Function proto type
//======================================
#define RT_LIST_ENTRY _list
typedef struct _BTData_ENTRY
{
RT_LIST_ENTRY List;
void *pDataBlock;
} BTData_ENTRY, *PBTData_ENTRY;
#define BTHCI_SM_WITH_INFO(_Adapter, _StateToEnter, _StateCmd, _EntryNum) \
{ \
RTPRINT(FIOCTL, IOCTL_STATE, ("[BT state change] caused by ""%s"", line=%d\n", __FUNCTION__, __LINE__)); \
BTHCI_StateMachine(_Adapter, _StateToEnter, _StateCmd, _EntryNum);\
}
void BTHCI_EventParse(PADAPTER padapter, void *pEvntData, u32 dataLen);
#define BT_EventParse BTHCI_EventParse
u8 BTHCI_HsConnectionEstablished(PADAPTER padapter);
void BTHCI_UpdateBTProfileRTKToMoto(PADAPTER padapter);
void BTHCI_WifiScanNotify(PADAPTER padapter, u8 scanType);
void BTHCI_StateMachine(PADAPTER padapter, u8 StateToEnter, HCI_STATE_WITH_CMD StateCmd, u8 EntryNum);
void BTHCI_DisconnectPeer(PADAPTER padapter, u8 EntryNum);
void BTHCI_EventNumOfCompletedDataBlocks(PADAPTER padapter);
void BTHCI_EventAMPStatusChange(PADAPTER padapter, u8 AMP_Status);
void BTHCI_DisconnectAll(PADAPTER padapter);
HCI_STATUS BTHCI_HandleHCICMD(PADAPTER padapter, PPACKET_IRP_HCICMD_DATA pHciCmd);
// ===== End of sync from SD7 driver COMMON/bt_hci.h =====
#endif // __BT_HCI_C__
#ifdef __HALBTC87231ANT_C__ // HAL/BTCoexist/HalBtc87231Ant.h
// ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.h =====
#define GET_BT_INFO(padapter) (&GET_HAL_DATA(padapter)->BtInfo)
#define BTC_FOR_SCAN_START 1
#define BTC_FOR_SCAN_FINISH 0
#define BT_TXRX_CNT_THRES_1 1200
#define BT_TXRX_CNT_THRES_2 1400
#define BT_TXRX_CNT_THRES_3 3000
#define BT_TXRX_CNT_LEVEL_0 0 // < 1200
#define BT_TXRX_CNT_LEVEL_1 1 // >= 1200 && < 1400
#define BT_TXRX_CNT_LEVEL_2 2 // >= 1400
#define BT_TXRX_CNT_LEVEL_3 3 // >= 3000
typedef enum _BT_STATE_1ANT{
BT_INFO_STATE_DISABLED = 0,
BT_INFO_STATE_NO_CONNECTION = 1,
BT_INFO_STATE_CONNECT_IDLE = 2,
BT_INFO_STATE_INQ_OR_PAG = 3,
BT_INFO_STATE_ACL_ONLY_BUSY = 4,
BT_INFO_STATE_SCO_ONLY_BUSY = 5,
BT_INFO_STATE_ACL_SCO_BUSY = 6,
BT_INFO_STATE_ACL_INQ_OR_PAG = 7,
BT_INFO_STATE_MAX = 8
} BT_STATE_1ANT, *PBT_STATE_1ANT;
typedef struct _BTDM_8723A_1ANT
{
u8 prePsTdma;
u8 curPsTdma;
u8 psTdmaDuAdjType;
u8 bPrePsTdmaOn;
u8 bCurPsTdmaOn;
u8 preWifiPara;
u8 curWifiPara;
u8 preCoexWifiCon;
u8 curCoexWifiCon;
u8 wifiRssiThresh;
u32 psTdmaMonitorCnt;
u32 psTdmaGlobalCnt;
//DurationAdjust For SCO
u32 psTdmaMonitorCntForSCO;
u8 psTdmaDuAdjTypeForSCO;
u8 RSSI_WiFi_Last;
u8 RSSI_BT_Last;
u8 bWiFiHalt;
u8 bRAChanged;
} BTDM_8723A_1ANT, *PBTDM_8723A_1ANT;
void BTDM_1AntSignalCompensation(PADAPTER padapter, u8 *rssi_wifi, u8 *rssi_bt);
void BTDM_1AntForDhcp(PADAPTER padapter);
void BTDM_1AntBtCoexist8723A(PADAPTER padapter);
// ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.h =====
#endif // __HALBTC87231ANT_C__
#ifdef __HALBTC87232ANT_C__ // HAL/BTCoexist/HalBtc87232Ant.h
// ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.h =====
typedef enum _BT_2ANT_BT_STATUS{
BT_2ANT_BT_STATUS_IDLE = 0x0,
BT_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
BT_2ANT_BT_STATUS_NON_IDLE = 0x2,
BT_2ANT_BT_STATUS_MAX
}BT_2ANT_BT_STATUS,*PBT_2ANT_BT_STATUS;
typedef enum _BT_2ANT_COEX_ALGO{
BT_2ANT_COEX_ALGO_UNDEFINED = 0x0,
BT_2ANT_COEX_ALGO_SCO = 0x1,
BT_2ANT_COEX_ALGO_HID = 0x2,
BT_2ANT_COEX_ALGO_A2DP = 0x3,
BT_2ANT_COEX_ALGO_PANEDR = 0x4,
BT_2ANT_COEX_ALGO_PANHS = 0x5,
BT_2ANT_COEX_ALGO_PANEDR_A2DP = 0x6,
BT_2ANT_COEX_ALGO_PANEDR_HID = 0x7,
BT_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x8,
BT_2ANT_COEX_ALGO_HID_A2DP = 0x9,
BT_2ANT_COEX_ALGO_HID_A2DP_PANHS = 0xA,
BT_2ANT_COEX_ALGO_MAX = 0xB,
}BT_2ANT_COEX_ALGO,*PBT_2ANT_COEX_ALGO;
typedef struct _BTDM_8723A_2ANT
{
u8 bPreDecBtPwr;
u8 bCurDecBtPwr;
u8 preWlanActHi;
u8 curWlanActHi;
u8 preWlanActLo;
u8 curWlanActLo;
u8 preFwDacSwingLvl;
u8 curFwDacSwingLvl;
u8 bPreRfRxLpfShrink;
u8 bCurRfRxLpfShrink;
u8 bPreLowPenaltyRa;
u8 bCurLowPenaltyRa;
u8 preBtRetryIndex;
u8 curBtRetryIndex;
u8 bPreDacSwingOn;
u32 preDacSwingLvl;
u8 bCurDacSwingOn;
u32 curDacSwingLvl;
u8 bPreAdcBackOff;
u8 bCurAdcBackOff;
u8 bPreAgcTableEn;
u8 bCurAgcTableEn;
u32 preVal0x6c0;
u32 curVal0x6c0;
u32 preVal0x6c8;
u32 curVal0x6c8;
u8 preVal0x6cc;
u8 curVal0x6cc;
u8 bCurIgnoreWlanAct;
u8 bPreIgnoreWlanAct;
u8 prePsTdma;
u8 curPsTdma;
u8 psTdmaDuAdjType;
u8 bPrePsTdmaOn;
u8 bCurPsTdmaOn;
u8 preAlgorithm;
u8 curAlgorithm;
u8 bResetTdmaAdjust;
u8 btStatus;
} BTDM_8723A_2ANT, *PBTDM_8723A_2ANT;
void BTDM_2AntBtCoexist8723A(PADAPTER padapter);
// ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.h =====
#endif // __HALBTC87232ANT_C__
#ifdef __HALBTC8723_C__ // HAL/BTCoexist/HalBtc8723.h
// ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc8723.h =====
#define BT_Q_PKT_OFF 0
#define BT_Q_PKT_ON 1
#define BT_TX_PWR_OFF 0
#define BT_TX_PWR_ON 1
// TDMA mode definition
#define TDMA_2ANT 0
#define TDMA_1ANT 1
#define TDMA_NAV_OFF 0
#define TDMA_NAV_ON 1
#define TDMA_DAC_SWING_OFF 0
#define TDMA_DAC_SWING_ON 1
#define BT_RSSI_LEVEL_H 0
#define BT_RSSI_LEVEL_M 1
#define BT_RSSI_LEVEL_L 2
// PTA mode related definition
#define BT_PTA_MODE_OFF 0
#define BT_PTA_MODE_ON 1
// Penalty Tx Rate Adaptive
#define BT_TX_RATE_ADAPTIVE_NORMAL 0
#define BT_TX_RATE_ADAPTIVE_LOW_PENALTY 1
// RF Corner
#define BT_RF_RX_LPF_CORNER_RESUME 0
#define BT_RF_RX_LPF_CORNER_SHRINK 1
#define BT_INFO_ACL BIT(0)
#define BT_INFO_SCO BIT(1)
#define BT_INFO_INQ_PAG BIT(2)
#define BT_INFO_ACL_BUSY BIT(3)
#define BT_INFO_SCO_BUSY BIT(4)
#define BT_INFO_HID BIT(5)
#define BT_INFO_A2DP BIT(6)
#define BT_INFO_FTP BIT(7)
typedef struct _BT_COEXIST_8723A
{
u32 highPriorityTx;
u32 highPriorityRx;
u32 lowPriorityTx;
u32 lowPriorityRx;
u8 btRssi;
u8 TotalAntNum;
u8 bC2hBtInfoSupport;
u8 c2hBtInfo;
u8 c2hBtInfoOriginal;
u8 prec2hBtInfo; // for 1Ant
u8 bC2hBtInquiryPage;
u64 btInqPageStartTime; // for 2Ant
u8 c2hBtProfile; // for 1Ant
u8 btRetryCnt;
u16 AclTp;
u8 btInfoExt;
u8 bC2hBtInfoReqSent;
u8 bForceFwBtInfo;
u8 bForceA2dpSink;
// u8 bForceLps;
// u8 bBtPwrSaveMode;
BTDM_8723A_2ANT btdm2Ant;
BTDM_8723A_1ANT btdm1Ant;
} BT_COEXIST_8723A, *PBT_COEXIST_8723A;
void BTDM_SetFwChnlInfo(PADAPTER padapter, RT_MEDIA_STATUS mstatus);
u8 BTDM_IsWifiConnectionExist(PADAPTER padapter);
void BTDM_SetFw3a(PADAPTER padapter, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5);
void BTDM_QueryBtInformation(PADAPTER padapter);
void BTDM_SetSwRfRxLpfCorner(PADAPTER padapter, u8 type);
void BTDM_SetSwPenaltyTxRateAdaptive(PADAPTER padapter, u8 raType);
void BTDM_SetFwDecBtPwr(PADAPTER padapter, u8 bDecBtPwr);
u8 BTDM_BtProfileSupport(PADAPTER padapter);
void BTDM_LpsLeave(PADAPTER padapter);
u8 BTDM_1Ant8723A(PADAPTER padapter);
u8 BTDM_GetBtState8723A(PADAPTER padapter);
u8 BTDM_IsBtInquiryPage8723A(PADAPTER padapter);
#define BT_1Ant BTDM_1Ant8723A
#define BT_GetBtState BTDM_GetBtState8723A
#define BT_IsBtInquiryPage BTDM_IsBtInquiryPage8723A
// ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc8723.h =====
#endif // __HALBTC8723_C__
#ifdef __HALBTCCSR1ANT_C__ // HAL/BTCoexist/HalBtcCsr1Ant.h
// ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.h =====
enum BT_A2DP_INDEX{
BT_A2DP_INDEX0 =0, // 32,12; the most critical for BT
BT_A2DP_INDEX1, // 12,24
BT_A2DP_INDEX2, // 0,0
BT_A2DP_INDEX_MAX
};
#define BT_A2DP_STATE_NOT_ENTERED 0
#define BT_A2DP_STATE_DETECTING 1
#define BT_A2DP_STATE_DETECTED 2
#define BTDM_ANT_BT_IDLE 0
#define BTDM_ANT_WIFI 1
#define BTDM_ANT_BT 2
void BTDM_SingleAnt(PADAPTER padapter, u8 bSingleAntOn, u8 bInterruptOn, u8 bMultiNAVOn);
void BTDM_CheckBTIdleChange1Ant(PADAPTER padapter);
// ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.h =====
#endif // __HALBTCCSR1ANT_C__
#ifdef __HALBTCCSR2ANT_C__ // HAL/BTCoexist/HalBtcCsr2Ant.h
// ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.h =====
//===========================================
// For old core stack before v251
//===========================================
#define BT_RSSI_STATE_NORMAL_POWER BIT0
#define BT_RSSI_STATE_AMDPU_OFF BIT1
#define BT_RSSI_STATE_SPECIAL_LOW BIT2
#define BT_RSSI_STATE_BG_EDCA_LOW BIT3
#define BT_RSSI_STATE_TXPOWER_LOW BIT4
#define BT_DACSWING_OFF 0
#define BT_DACSWING_M4 1
#define BT_DACSWING_M7 2
#define BT_DACSWING_M10 3
void BTDM_DiminishWiFi(PADAPTER Adapter, u8 bDACOn, u8 bInterruptOn, u8 DACSwingLevel, u8 bNAVOn);
// ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.h =====
#endif // __HALBTCCSR2ANT_C__
#ifdef __HALBTCOEXIST_C__ // HAL/BTCoexist/HalBtCoexist.h
// HEADER/TypeDef.h
#define MAX_FW_SUPPORT_MACID_NUM 64
#define WIFI_BUSY_TRAFFIC_TH 25
// ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtCoexist.h =====
#define FW_VER_BT_REG 62
#define FW_VER_BT_REG1 74
#define REG_BT_ACTIVE 0x444
#define REG_BT_STATE 0x448
#define REG_BT_POLLING1 0x44c
#define REG_BT_POLLING 0x700
#define REG_BT_ACTIVE_OLD 0x488
#define REG_BT_STATE_OLD 0x48c
#define REG_BT_POLLING_OLD 0x490
// The reg define is for 8723
#define REG_HIGH_PRIORITY_TXRX 0x770
#define REG_LOW_PRIORITY_TXRX 0x774
#define BT_FW_COEX_THRESH_TOL 6
#define BT_FW_COEX_THRESH_20 20
#define BT_FW_COEX_THRESH_23 23
#define BT_FW_COEX_THRESH_25 25
#define BT_FW_COEX_THRESH_30 30
#define BT_FW_COEX_THRESH_35 35
#define BT_FW_COEX_THRESH_40 40
#define BT_FW_COEX_THRESH_45 45
#define BT_FW_COEX_THRESH_47 47
#define BT_FW_COEX_THRESH_50 50
#define BT_FW_COEX_THRESH_55 55
#define BT_FW_COEX_THRESH_65 65
#define BT_COEX_STATE_BT30 BIT(0)
#define BT_COEX_STATE_WIFI_HT20 BIT(1)
#define BT_COEX_STATE_WIFI_HT40 BIT(2)
#define BT_COEX_STATE_WIFI_LEGACY BIT(3)
#define BT_COEX_STATE_WIFI_RSSI_LOW BIT(4)
#define BT_COEX_STATE_WIFI_RSSI_MEDIUM BIT(5)
#define BT_COEX_STATE_WIFI_RSSI_HIGH BIT(6)
#define BT_COEX_STATE_DEC_BT_POWER BIT(7)
#define BT_COEX_STATE_WIFI_IDLE BIT(8)
#define BT_COEX_STATE_WIFI_UPLINK BIT(9)
#define BT_COEX_STATE_WIFI_DOWNLINK BIT(10)
#define BT_COEX_STATE_BT_INQ_PAGE BIT(11)
#define BT_COEX_STATE_BT_IDLE BIT(12)
#define BT_COEX_STATE_BT_UPLINK BIT(13)
#define BT_COEX_STATE_BT_DOWNLINK BIT(14)
//===========================================
// Todo: Remove these definitions
#define BT_COEX_STATE_BT_PAN_IDLE BIT(15)
#define BT_COEX_STATE_BT_PAN_UPLINK BIT(16)
#define BT_COEX_STATE_BT_PAN_DOWNLINK BIT(17)
#define BT_COEX_STATE_BT_A2DP_IDLE BIT(18)
//===========================================
#define BT_COEX_STATE_BT_RSSI_LOW BIT(19)
#define BT_COEX_STATE_PROFILE_HID BIT(20)
#define BT_COEX_STATE_PROFILE_A2DP BIT(21)
#define BT_COEX_STATE_PROFILE_PAN BIT(22)
#define BT_COEX_STATE_PROFILE_SCO BIT(23)
#define BT_COEX_STATE_WIFI_RSSI_1_LOW BIT(24)
#define BT_COEX_STATE_WIFI_RSSI_1_MEDIUM BIT(25)
#define BT_COEX_STATE_WIFI_RSSI_1_HIGH BIT(26)
#define BT_COEX_STATE_WIFI_RSSI_BEACON_LOW BIT(27)
#define BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM BIT(28)
#define BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH BIT(29)
#define BT_COEX_STATE_BTINFO_COMMON BIT30
#define BT_COEX_STATE_BTINFO_B_HID_SCOESCO BIT31
#define BT_COEX_STATE_BTINFO_B_FTP_A2DP BIT32
#define BT_COEX_STATE_BT_CNT_LEVEL_0 BIT33
#define BT_COEX_STATE_BT_CNT_LEVEL_1 BIT34
#define BT_COEX_STATE_BT_CNT_LEVEL_2 BIT35
#define BT_COEX_STATE_BT_CNT_LEVEL_3 BIT36
#define BT_RSSI_STATE_HIGH 0
#define BT_RSSI_STATE_MEDIUM 1
#define BT_RSSI_STATE_LOW 2
#define BT_RSSI_STATE_STAY_HIGH 3
#define BT_RSSI_STATE_STAY_MEDIUM 4
#define BT_RSSI_STATE_STAY_LOW 5
#define BT_AGCTABLE_OFF 0
#define BT_AGCTABLE_ON 1
#define BT_BB_BACKOFF_OFF 0
#define BT_BB_BACKOFF_ON 1
#define BT_FW_NAV_OFF 0
#define BT_FW_NAV_ON 1
#define BT_COEX_MECH_NONE 0
#define BT_COEX_MECH_SCO 1
#define BT_COEX_MECH_HID 2
#define BT_COEX_MECH_A2DP 3
#define BT_COEX_MECH_PAN 4
#define BT_COEX_MECH_HID_A2DP 5
#define BT_COEX_MECH_HID_PAN 6
#define BT_COEX_MECH_PAN_A2DP 7
#define BT_COEX_MECH_HID_SCO_ESCO 8
#define BT_COEX_MECH_FTP_A2DP 9
#define BT_COEX_MECH_COMMON 10
#define BT_COEX_MECH_MAX 11
//===========================================
// BT Dbg Ctrl
//===========================================
#define BT_DBG_PROFILE_NONE 0
#define BT_DBG_PROFILE_SCO 1
#define BT_DBG_PROFILE_HID 2
#define BT_DBG_PROFILE_A2DP 3
#define BT_DBG_PROFILE_PAN 4
#define BT_DBG_PROFILE_HID_A2DP 5
#define BT_DBG_PROFILE_HID_PAN 6
#define BT_DBG_PROFILE_PAN_A2DP 7
#define BT_DBG_PROFILE_MAX 9
//===========================================
typedef struct _BT_COEXIST_STR
{
u8 BluetoothCoexist;
u8 BT_Ant_Num;
u8 BT_CoexistType;
u8 BT_Ant_isolation; //0:good, 1:bad
u8 BT_RadioSharedType;
u32 Ratio_Tx;
u32 Ratio_PRI;
u8 bInitlized;
u32 BtRfRegOrigin1E;
u32 BtRfRegOrigin1F;
u8 bBTBusyTraffic;
u8 bBTTrafficModeSet;
u8 bBTNonTrafficModeSet;
BT_TRAFFIC_STATISTICS BT21TrafficStatistics;
u64 CurrentState;
u64 PreviousState;
u8 preRssiState;
u8 preRssiState1;
u8 preRssiStateBeacon;
u8 bFWCoexistAllOff;
u8 bSWCoexistAllOff;
u8 bHWCoexistAllOff;
u8 bBalanceOn;
u8 bSingleAntOn;
u8 bInterruptOn;
u8 bMultiNAVOn;
u8 PreWLANActH;
u8 PreWLANActL;
u8 WLANActH;
u8 WLANActL;
u8 A2DPState;
u8 AntennaState;
u32 lastBtEdca;
u16 last_aggr_num;
u8 bEDCAInitialized;
u8 exec_cnt;
u8 b8723aAgcTableOn;
u8 b92DAgcTableOn;
BT_COEXIST_8723A halCoex8723;
u8 btActiveZeroCnt;
u8 bCurBtDisabled;
u8 bPreBtDisabled;
u8 bNeedToRoamForBtDisableEnable;
u8 fw3aVal[5];
}BT_COEXIST_STR, *PBT_COEXIST_STR;
void BTDM_CheckAntSelMode(PADAPTER padapter);
void BTDM_FwC2hBtRssi(PADAPTER padapter, u8 *tmpBuf);
#define BT_FwC2hBtRssi BTDM_FwC2hBtRssi
void BTDM_FwC2hBtInfo(PADAPTER padapter, u8 *tmpBuf, u8 length);
#define BT_FwC2hBtInfo BTDM_FwC2hBtInfo
void BTDM_DisplayBtCoexInfo(PADAPTER padapter);
#define BT_DisplayBtCoexInfo BTDM_DisplayBtCoexInfo
void BTDM_RejectAPAggregatedPacket(PADAPTER padapter, u8 bReject);
u8 BTDM_IsHT40(PADAPTER padapter);
u8 BTDM_Legacy(PADAPTER padapter);
void BTDM_CheckWiFiState(PADAPTER padapter);
s32 BTDM_GetRxSS(PADAPTER padapter);
u8 BTDM_CheckCoexBcnRssiState(PADAPTER padapter, u8 levelNum, u8 RssiThresh, u8 RssiThresh1);
u8 BTDM_CheckCoexRSSIState1(PADAPTER padapter, u8 levelNum, u8 RssiThresh, u8 RssiThresh1);
u8 BTDM_CheckCoexRSSIState(PADAPTER padapter, u8 levelNum, u8 RssiThresh, u8 RssiThresh1);
u8 BTDM_DisableEDCATurbo(PADAPTER padapter);
#define BT_DisableEDCATurbo BTDM_DisableEDCATurbo
void BTDM_Balance(PADAPTER padapter, u8 bBalanceOn, u8 ms0, u8 ms1);
void BTDM_AGCTable(PADAPTER padapter, u8 type);
void BTDM_BBBackOffLevel(PADAPTER padapter, u8 type);
void BTDM_FWCoexAllOff(PADAPTER padapter);
void BTDM_SWCoexAllOff(PADAPTER padapter);
void BTDM_HWCoexAllOff(PADAPTER padapter);
void BTDM_CoexAllOff(PADAPTER padapter);
void BTDM_TurnOffBtCoexistBeforeEnterIPS(PADAPTER padapter);
void BTDM_SignalCompensation(PADAPTER padapter, u8 *rssi_wifi, u8 *rssi_bt);
void BTDM_Coexist(PADAPTER padapter);
#define BT_CoexistMechanism BTDM_Coexist
void BTDM_UpdateCoexState(PADAPTER padapter);
u8 BTDM_IsSameCoexistState(PADAPTER padapter);
void BTDM_PWDBMonitor(PADAPTER padapter);
u8 BTDM_IsBTBusy(PADAPTER padapter);
#define BT_IsBtBusy BTDM_IsBTBusy
u8 BTDM_IsWifiBusy(PADAPTER padapter);
u8 BTDM_IsCoexistStateChanged(PADAPTER padapter);
u8 BTDM_IsWifiUplink(PADAPTER padapter);
u8 BTDM_IsWifiDownlink(PADAPTER padapter);
u8 BTDM_IsBTHSMode(PADAPTER padapter);
u8 BTDM_IsBTUplink(PADAPTER padapter);
u8 BTDM_IsBTDownlink(PADAPTER padapter);
void BTDM_AdjustForBtOperation(PADAPTER padapter);
void BTDM_ForHalt(PADAPTER padapter);
void BTDM_WifiScanNotify(PADAPTER padapter, u8 scanType);
void BTDM_WifiAssociateNotify(PADAPTER padapter, u8 action);
void BTDM_MediaStatusNotify(PADAPTER padapter, RT_MEDIA_STATUS mstatus);
void BTDM_ForDhcp(PADAPTER padapter);
void BTDM_ResetActionProfileState(PADAPTER padapter);
void BTDM_SetBtCoexCurrAntNum(PADAPTER padapter, u8 antNum);
#define BT_SetBtCoexCurrAntNum BTDM_SetBtCoexCurrAntNum
u8 BTDM_IsActionSCO(PADAPTER padapter);
u8 BTDM_IsActionHID(PADAPTER padapter);
u8 BTDM_IsActionA2DP(PADAPTER padapter);
u8 BTDM_IsActionPAN(PADAPTER padapter);
u8 BTDM_IsActionHIDA2DP(PADAPTER padapter);
u8 BTDM_IsActionHIDPAN(PADAPTER padapter);
u8 BTDM_IsActionPANA2DP(PADAPTER padapter);
u8 BTDM_IsBtDisabled(PADAPTER padapter);
#define BT_IsBtDisabled BTDM_IsBtDisabled
sint BTDM_CheckFWState(PADAPTER padapter, sint state);
u32 BTDM_BtTxRxCounterH(PADAPTER padapter);
u32 BTDM_BtTxRxCounterL(PADAPTER padapter);
// ===== End of sync from SD7 driver HAL/BTCoexist/HalBtCoexist.h =====
#endif // __HALBTCOEXIST_C__
#ifdef __HALBT_C__ // HAL/HalBT.h
// ===== Below this line is sync from SD7 driver HAL/HalBT.h =====
#define RTS_CTS_NO_LEN_LIMIT 0
u8 HALBT_GetPGAntNum(PADAPTER padapter);
#define BT_GetPGAntNum HALBT_GetPGAntNum
void HALBT_SetKey(PADAPTER padapter, u8 EntryNum);
void HALBT_RemoveKey(PADAPTER padapter, u8 EntryNum);
void HALBT_InitBTVars8723A(PADAPTER padapter);
#define HALBT_InitHalVars HALBT_InitBTVars8723A
#define BT_InitHalVars HALBT_InitHalVars
u8 HALBT_IsBTExist(PADAPTER padapter);
#define BT_IsBtExist HALBT_IsBTExist
u8 HALBT_BTChipType(PADAPTER padapter);
void HALBT_InitHwConfig(PADAPTER padapter);
#define BT_InitHwConfig HALBT_InitHwConfig
void HALBT_SetRtsCtsNoLenLimit(PADAPTER padapter);
// ===== End of sync from SD7 driver HAL/HalBT.c =====
#endif // __HALBT_C__
#define _bt_dbg_off_ 0
#define _bt_dbg_on_ 1
extern u32 BTCoexDbgLevel;
#endif // __RTL8723A_BT_COEXIST_H__
|