xref: /linux/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 /*  The following is for 8723B 1ANT BT Co-exist definition */
8 #define	BT_INFO_8723B_1ANT_B_FTP		BIT7
9 #define	BT_INFO_8723B_1ANT_B_A2DP		BIT6
10 #define	BT_INFO_8723B_1ANT_B_HID		BIT5
11 #define	BT_INFO_8723B_1ANT_B_SCO_BUSY		BIT4
12 #define	BT_INFO_8723B_1ANT_B_ACL_BUSY		BIT3
13 #define	BT_INFO_8723B_1ANT_B_INQ_PAGE		BIT2
14 #define	BT_INFO_8723B_1ANT_B_SCO_ESCO		BIT1
15 #define	BT_INFO_8723B_1ANT_B_CONNECTION		BIT0
16 
17 #define	BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_)	\
18 		(((_BT_INFO_EXT_ & BIT0)) ? true : false)
19 
20 #define	BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2
21 
22 #define  BT_8723B_1ANT_WIFI_NOISY_THRESH 30   /* max: 255 */
23 
24 enum {
25 	BT_INFO_SRC_8723B_1ANT_WIFI_FW			= 0x0,
26 	BT_INFO_SRC_8723B_1ANT_BT_RSP				= 0x1,
27 	BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND		= 0x2,
28 	BT_INFO_SRC_8723B_1ANT_MAX
29 };
30 
31 enum {
32 	BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE	= 0x0,
33 	BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE		= 0x1,
34 	BT_8723B_1ANT_BT_STATUS_INQ_PAGE				= 0x2,
35 	BT_8723B_1ANT_BT_STATUS_ACL_BUSY				= 0x3,
36 	BT_8723B_1ANT_BT_STATUS_SCO_BUSY				= 0x4,
37 	BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY			= 0x5,
38 	BT_8723B_1ANT_BT_STATUS_MAX
39 };
40 
41 enum {
42 	BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE           = 0x0,
43 	BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
44 	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN               = 0x2,
45 	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT        = 0x3,
46 	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE               = 0x4,
47 	BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY               = 0x5,
48 	BT_8723B_1ANT_WIFI_STATUS_MAX
49 };
50 
51 enum {
52 	BT_8723B_1ANT_COEX_ALGO_UNDEFINED		= 0x0,
53 	BT_8723B_1ANT_COEX_ALGO_SCO				= 0x1,
54 	BT_8723B_1ANT_COEX_ALGO_HID				= 0x2,
55 	BT_8723B_1ANT_COEX_ALGO_A2DP			= 0x3,
56 	BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS		= 0x4,
57 	BT_8723B_1ANT_COEX_ALGO_PANEDR			= 0x5,
58 	BT_8723B_1ANT_COEX_ALGO_PANHS			= 0x6,
59 	BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP		= 0x7,
60 	BT_8723B_1ANT_COEX_ALGO_PANEDR_HID		= 0x8,
61 	BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR	= 0x9,
62 	BT_8723B_1ANT_COEX_ALGO_HID_A2DP		= 0xa,
63 	BT_8723B_1ANT_COEX_ALGO_MAX				= 0xb,
64 };
65 
66 struct coex_dm_8723b_1ant {
67 	/*  fw mechanism */
68 	bool bCurIgnoreWlanAct;
69 	bool bPreIgnoreWlanAct;
70 	u8 prePsTdma;
71 	u8 curPsTdma;
72 	u8 psTdmaPara[5];
73 	u8 psTdmaDuAdjType;
74 	bool bAutoTdmaAdjust;
75 	bool bPrePsTdmaOn;
76 	bool bCurPsTdmaOn;
77 	bool bPreBtAutoReport;
78 	bool bCurBtAutoReport;
79 	u8 preLps;
80 	u8 curLps;
81 	u8 preRpwm;
82 	u8 curRpwm;
83 
84 	/*  sw mechanism */
85 	bool bPreLowPenaltyRa;
86 	bool bCurLowPenaltyRa;
87 	u32 preVal0x6c0;
88 	u32 curVal0x6c0;
89 	u32 preVal0x6c4;
90 	u32 curVal0x6c4;
91 	u32 preVal0x6c8;
92 	u32 curVal0x6c8;
93 	u8 preVal0x6cc;
94 	u8 curVal0x6cc;
95 	bool bLimitedDig;
96 
97 	u32 backupArfrCnt1;	/*  Auto Rate Fallback Retry cnt */
98 	u32 backupArfrCnt2;	/*  Auto Rate Fallback Retry cnt */
99 	u16 backupRetryLimit;
100 	u8 backupAmpduMaxTime;
101 
102 	/*  algorithm related */
103 	u8 preAlgorithm;
104 	u8 curAlgorithm;
105 	u8 btStatus;
106 	u8 wifiChnlInfo[3];
107 
108 	u32 preRaMask;
109 	u32 curRaMask;
110 	u8 preArfrType;
111 	u8 curArfrType;
112 	u8 preRetryLimitType;
113 	u8 curRetryLimitType;
114 	u8 preAmpduTimeType;
115 	u8 curAmpduTimeType;
116 	u32 nArpCnt;
117 
118 	u8 errorCondition;
119 };
120 
121 struct coex_sta_8723b_1ant {
122 	bool bBtLinkExist;
123 	bool bScoExist;
124 	bool bA2dpExist;
125 	bool bHidExist;
126 	bool bPanExist;
127 
128 	bool bUnderLps;
129 	bool bUnderIps;
130 	u32 specialPktPeriodCnt;
131 	u32 highPriorityTx;
132 	u32 highPriorityRx;
133 	u32 lowPriorityTx;
134 	u32 lowPriorityRx;
135 	s8 btRssi;
136 	bool bBtTxRxMask;
137 	u8 preBtRssiState;
138 	u8 preWifiRssiState[4];
139 	bool bC2hBtInfoReqSent;
140 	u8 btInfoC2h[BT_INFO_SRC_8723B_1ANT_MAX][10];
141 	u32 btInfoC2hCnt[BT_INFO_SRC_8723B_1ANT_MAX];
142 	bool bC2hBtInquiryPage;
143 	bool bC2hBtPage; /* Add for win8.1 page out issue */
144 	bool bWiFiIsHighPriTask; /* Add for win8.1 page out issue */
145 	u8 btRetryCnt;
146 	u8 btInfoExt;
147 	u32 popEventCnt;
148 	u8 nScanAPNum;
149 
150 	u32 nCRCOK_CCK;
151 	u32 nCRCOK_11g;
152 	u32 nCRCOK_11n;
153 	u32 nCRCOK_11nAgg;
154 
155 	u32 nCRCErr_CCK;
156 	u32 nCRCErr_11g;
157 	u32 nCRCErr_11n;
158 	u32 nCRCErr_11nAgg;
159 
160 	bool bCCKLock;
161 	bool bPreCCKLock;
162 	u8 nCoexTableType;
163 
164 	bool bForceLpsOn;
165 };
166 
167 /*  */
168 /*  The following is interface which will notify coex module. */
169 /*  */
170 void EXhalbtc8723b1ant_PowerOnSetting(struct btc_coexist *pBtCoexist);
171 void EXhalbtc8723b1ant_InitHwConfig(struct btc_coexist *pBtCoexist, bool bWifiOnly);
172 void EXhalbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist);
173 void EXhalbtc8723b1ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type);
174 void EXhalbtc8723b1ant_LpsNotify(struct btc_coexist *pBtCoexist, u8 type);
175 void EXhalbtc8723b1ant_ScanNotify(struct btc_coexist *pBtCoexist, u8 type);
176 void EXhalbtc8723b1ant_ConnectNotify(struct btc_coexist *pBtCoexist, u8 type);
177 void EXhalbtc8723b1ant_MediaStatusNotify(struct btc_coexist *pBtCoexist, u8 type);
178 void EXhalbtc8723b1ant_SpecialPacketNotify(struct btc_coexist *pBtCoexist, u8 type);
179 void EXhalbtc8723b1ant_BtInfoNotify(
180 	struct btc_coexist *pBtCoexist, u8 *tmpBuf, u8 length
181 );
182 void EXhalbtc8723b1ant_HaltNotify(struct btc_coexist *pBtCoexist);
183 void EXhalbtc8723b1ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState);
184 void EXhalbtc8723b1ant_Periodical(struct btc_coexist *pBtCoexist);
185