xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8189es/hal/btc/HalBtc8703b1Ant.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 //===========================================
3 // The following is for 8703B 1ANT BT Co-exist definition
4 //===========================================
5 #define	BT_AUTO_REPORT_ONLY_8703B_1ANT				1
6 
7 #define	BT_INFO_8703B_1ANT_B_FTP						BIT7
8 #define	BT_INFO_8703B_1ANT_B_A2DP					BIT6
9 #define	BT_INFO_8703B_1ANT_B_HID						BIT5
10 #define	BT_INFO_8703B_1ANT_B_SCO_BUSY				BIT4
11 #define	BT_INFO_8703B_1ANT_B_ACL_BUSY				BIT3
12 #define	BT_INFO_8703B_1ANT_B_INQ_PAGE				BIT2
13 #define	BT_INFO_8703B_1ANT_B_SCO_ESCO				BIT1
14 #define	BT_INFO_8703B_1ANT_B_CONNECTION				BIT0
15 
16 #define	BT_INFO_8703B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_)	\
17 		(((_BT_INFO_EXT_&BIT0))? TRUE:FALSE)
18 
19 #define	BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT		2
20 
21 #define  BT_8703B_1ANT_WIFI_NOISY_THRESH							30   //max: 255
22 
23 //for Antenna detection
24 #define	BT_8703B_1ANT_ANTDET_PSDTHRES_BACKGROUND					50
25 #define	BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION				70
26 #define	BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION			55
27 #define	BT_8703B_1ANT_ANTDET_PSDTHRES_1ANT							35
28 #define	BT_8703B_1ANT_ANTDET_RETRY_INTERVAL							10	//retry timer if ant det is fail, unit: second
29 #define	BT_8703B_1ANT_ANTDET_ENABLE									0
30 #define	BT_8703B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE				0
31 
32 typedef enum _BT_INFO_SRC_8703B_1ANT{
33 	BT_INFO_SRC_8703B_1ANT_WIFI_FW			= 0x0,
34 	BT_INFO_SRC_8703B_1ANT_BT_RSP				= 0x1,
35 	BT_INFO_SRC_8703B_1ANT_BT_ACTIVE_SEND		= 0x2,
36 	BT_INFO_SRC_8703B_1ANT_MAX
37 }BT_INFO_SRC_8703B_1ANT,*PBT_INFO_SRC_8703B_1ANT;
38 
39 typedef enum _BT_8703B_1ANT_BT_STATUS{
40 	BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE	= 0x0,
41 	BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE		= 0x1,
42 	BT_8703B_1ANT_BT_STATUS_INQ_PAGE				= 0x2,
43 	BT_8703B_1ANT_BT_STATUS_ACL_BUSY				= 0x3,
44 	BT_8703B_1ANT_BT_STATUS_SCO_BUSY				= 0x4,
45 	BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY			= 0x5,
46 	BT_8703B_1ANT_BT_STATUS_MAX
47 }BT_8703B_1ANT_BT_STATUS,*PBT_8703B_1ANT_BT_STATUS;
48 
49 typedef enum _BT_8703B_1ANT_WIFI_STATUS{
50 	BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE				= 0x0,
51 	BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN		= 0x1,
52 	BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN					= 0x2,
53 	BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT				= 0x3,
54 	BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE					= 0x4,
55 	BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY					= 0x5,
56 	BT_8703B_1ANT_WIFI_STATUS_MAX
57 }BT_8703B_1ANT_WIFI_STATUS,*PBT_8703B_1ANT_WIFI_STATUS;
58 
59 typedef enum _BT_8703B_1ANT_COEX_ALGO{
60 	BT_8703B_1ANT_COEX_ALGO_UNDEFINED			= 0x0,
61 	BT_8703B_1ANT_COEX_ALGO_SCO				= 0x1,
62 	BT_8703B_1ANT_COEX_ALGO_HID				= 0x2,
63 	BT_8703B_1ANT_COEX_ALGO_A2DP				= 0x3,
64 	BT_8703B_1ANT_COEX_ALGO_A2DP_PANHS		= 0x4,
65 	BT_8703B_1ANT_COEX_ALGO_PANEDR			= 0x5,
66 	BT_8703B_1ANT_COEX_ALGO_PANHS			= 0x6,
67 	BT_8703B_1ANT_COEX_ALGO_PANEDR_A2DP		= 0x7,
68 	BT_8703B_1ANT_COEX_ALGO_PANEDR_HID		= 0x8,
69 	BT_8703B_1ANT_COEX_ALGO_HID_A2DP_PANEDR	= 0x9,
70 	BT_8703B_1ANT_COEX_ALGO_HID_A2DP			= 0xa,
71 	BT_8703B_1ANT_COEX_ALGO_MAX				= 0xb,
72 }BT_8703B_1ANT_COEX_ALGO,*PBT_8703B_1ANT_COEX_ALGO;
73 
74 typedef struct _COEX_DM_8703B_1ANT{
75 	// hw setting
76 	u1Byte		preAntPosType;
77 	u1Byte		curAntPosType;
78 	// fw mechanism
79 	BOOLEAN		bCurIgnoreWlanAct;
80 	BOOLEAN		bPreIgnoreWlanAct;
81 	u1Byte		prePsTdma;
82 	u1Byte		curPsTdma;
83 	u1Byte		psTdmaPara[5];
84 	u1Byte		psTdmaDuAdjType;
85 	BOOLEAN		bAutoTdmaAdjust;
86 	BOOLEAN		bPrePsTdmaOn;
87 	BOOLEAN		bCurPsTdmaOn;
88 	BOOLEAN		bPreBtAutoReport;
89 	BOOLEAN		bCurBtAutoReport;
90 	u1Byte		preLps;
91 	u1Byte		curLps;
92 	u1Byte		preRpwm;
93 	u1Byte		curRpwm;
94 
95 	// sw mechanism
96 	BOOLEAN 	bPreLowPenaltyRa;
97 	BOOLEAN		bCurLowPenaltyRa;
98 	u4Byte		preVal0x6c0;
99 	u4Byte		curVal0x6c0;
100 	u4Byte		preVal0x6c4;
101 	u4Byte		curVal0x6c4;
102 	u4Byte		preVal0x6c8;
103 	u4Byte		curVal0x6c8;
104 	u1Byte		preVal0x6cc;
105 	u1Byte		curVal0x6cc;
106 	BOOLEAN		bLimitedDig;
107 
108 	u4Byte		backupArfrCnt1;	// Auto Rate Fallback Retry cnt
109 	u4Byte		backupArfrCnt2;	// Auto Rate Fallback Retry cnt
110 	u2Byte		backupRetryLimit;
111 	u1Byte		backupAmpduMaxTime;
112 
113 	// algorithm related
114 	u1Byte		preAlgorithm;
115 	u1Byte		curAlgorithm;
116 	u1Byte		btStatus;
117 	u1Byte		wifiChnlInfo[3];
118 
119 	u4Byte		preRaMask;
120 	u4Byte		curRaMask;
121 	u1Byte		preArfrType;
122 	u1Byte		curArfrType;
123 	u1Byte		preRetryLimitType;
124 	u1Byte		curRetryLimitType;
125 	u1Byte		preAmpduTimeType;
126 	u1Byte		curAmpduTimeType;
127 	u4Byte		nArpCnt;
128 
129 	u1Byte		errorCondition;
130 } COEX_DM_8703B_1ANT, *PCOEX_DM_8703B_1ANT;
131 
132 typedef struct _COEX_STA_8703B_1ANT{
133 	BOOLEAN					bBtLinkExist;
134 	BOOLEAN					bScoExist;
135 	BOOLEAN					bA2dpExist;
136 	BOOLEAN					bHidExist;
137 	BOOLEAN					bPanExist;
138 	BOOLEAN					bBtHiPriLinkExist;
139 	u1Byte					nNumOfProfile;
140 
141 	BOOLEAN					bUnderLps;
142 	BOOLEAN					bUnderIps;
143 	u4Byte					specialPktPeriodCnt;
144 	u4Byte					highPriorityTx;
145 	u4Byte					highPriorityRx;
146 	u4Byte					lowPriorityTx;
147 	u4Byte					lowPriorityRx;
148 	s1Byte					btRssi;
149 	BOOLEAN					bBtTxRxMask;
150 	u1Byte					preBtRssiState;
151 	u1Byte					preWifiRssiState[4];
152 	BOOLEAN					bC2hBtInfoReqSent;
153 	u1Byte					btInfoC2h[BT_INFO_SRC_8703B_1ANT_MAX][10];
154 	u4Byte					btInfoC2hCnt[BT_INFO_SRC_8703B_1ANT_MAX];
155 	BOOLEAN					bBtWhckTest;
156 	BOOLEAN					bC2hBtInquiryPage;
157 	BOOLEAN					bC2hBtPage;				//Add for win8.1 page out issue
158 	BOOLEAN					bWiFiIsHighPriTask;		//Add for win8.1 page out issue
159 	u1Byte					btRetryCnt;
160 	u1Byte					btInfoExt;
161 	u4Byte					popEventCnt;
162 	u1Byte					nScanAPNum;
163 
164 	u4Byte					nCRCOK_CCK;
165 	u4Byte					nCRCOK_11g;
166 	u4Byte					nCRCOK_11n;
167 	u4Byte					nCRCOK_11nAgg;
168 
169 	u4Byte					nCRCErr_CCK;
170 	u4Byte					nCRCErr_11g;
171 	u4Byte					nCRCErr_11n;
172 	u4Byte					nCRCErr_11nAgg;
173 
174 	BOOLEAN					bCCKLock;
175 	BOOLEAN					bPreCCKLock;
176 	BOOLEAN					bCCKEverLock;
177 	u1Byte					nCoexTableType;
178 
179 	BOOLEAN					bForceLpsOn;
180 	u4Byte					wrongProfileNotification;
181 }COEX_STA_8703B_1ANT, *PCOEX_STA_8703B_1ANT;
182 
183 #define  BT_8703B_1ANT_ANTDET_PSD_POINTS			256	//MAX:1024
184 #define  BT_8703B_1ANT_ANTDET_PSD_AVGNUM			1	//MAX:3
185 #define	BT_8703B_1ANT_ANTDET_BUF_LEN				16
186 
187 typedef struct _PSDSCAN_STA_8703B_1ANT{
188 
189 u4Byte		 	nAntDet_BTLEChannel;  //BT LE Channel ex:2412
190 u4Byte			nAntDet_BTTxTime;
191 u4Byte			nAntDet_PrePSDScanPeakVal;
192 BOOLEAN			nAntDet_IsAntDetAvailable;
193 u4Byte			nAntDet_PSDScanPeakVal;
194 BOOLEAN			nAntDet_IsBTReplyAvailable;
195 u4Byte			nAntDet_PSDScanPeakFreq;
196 
197 u1Byte			nAntDet_Result;
198 u1Byte			nAntDet_PeakVal[BT_8703B_1ANT_ANTDET_BUF_LEN];
199 u1Byte			nAntDet_PeakFreq[BT_8703B_1ANT_ANTDET_BUF_LEN];
200 u4Byte			bAntDet_TryCount;
201 u4Byte			bAntDet_FailCount;
202 u4Byte			nAntDet_IntevalCount;
203 u4Byte			nAntDet_ThresOffset;
204 
205 u4Byte			nRealCentFreq;
206 s4Byte			nRealOffset;
207 u4Byte			nRealSpan;
208 
209 u4Byte			nPSDBandWidth;  //unit: Hz
210 u4Byte			nPSDPoint;		//128/256/512/1024
211 u4Byte			nPSDReport[1024];  //unit:dB (20logx), 0~255
212 u4Byte			nPSDReport_MaxHold[1024];  //unit:dB (20logx), 0~255
213 u4Byte			nPSDStartPoint;
214 u4Byte			nPSDStopPoint;
215 u4Byte			nPSDMaxValuePoint;
216 u4Byte			nPSDMaxValue;
217 u4Byte			nPSDStartBase;
218 u4Byte			nPSDAvgNum;	// 1/8/16/32
219 u4Byte			nPSDGenCount;
220 BOOLEAN			bIsPSDRunning;
221 BOOLEAN			bIsPSDShowMaxOnly;
222 } PSDSCAN_STA_8703B_1ANT, *PPSDSCAN_STA_8703B_1ANT;
223 
224 //===========================================
225 // The following is interface which will notify coex module.
226 //===========================================
227 VOID
228 EXhalbtc8703b1ant_PowerOnSetting(
229 	IN	PBTC_COEXIST		pBtCoexist
230 	);
231 VOID
232 EXhalbtc8703b1ant_PreLoadFirmware(
233 	IN	PBTC_COEXIST		pBtCoexist
234 	);
235 VOID
236 EXhalbtc8703b1ant_InitHwConfig(
237 	IN	PBTC_COEXIST		pBtCoexist,
238 	IN	BOOLEAN				bWifiOnly
239 	);
240 VOID
241 EXhalbtc8703b1ant_InitCoexDm(
242 	IN	PBTC_COEXIST		pBtCoexist
243 	);
244 VOID
245 EXhalbtc8703b1ant_IpsNotify(
246 	IN	PBTC_COEXIST		pBtCoexist,
247 	IN	u1Byte			type
248 	);
249 VOID
250 EXhalbtc8703b1ant_LpsNotify(
251 	IN	PBTC_COEXIST		pBtCoexist,
252 	IN	u1Byte			type
253 	);
254 VOID
255 EXhalbtc8703b1ant_ScanNotify(
256 	IN	PBTC_COEXIST		pBtCoexist,
257 	IN	u1Byte			type
258 	);
259 VOID
260 EXhalbtc8703b1ant_ConnectNotify(
261 	IN	PBTC_COEXIST		pBtCoexist,
262 	IN	u1Byte			type
263 	);
264 VOID
265 EXhalbtc8703b1ant_MediaStatusNotify(
266 	IN	PBTC_COEXIST			pBtCoexist,
267 	IN	u1Byte				type
268 	);
269 VOID
270 EXhalbtc8703b1ant_SpecialPacketNotify(
271 	IN	PBTC_COEXIST			pBtCoexist,
272 	IN	u1Byte				type
273 	);
274 VOID
275 EXhalbtc8703b1ant_BtInfoNotify(
276 	IN	PBTC_COEXIST		pBtCoexist,
277 	IN	pu1Byte			tmpBuf,
278 	IN	u1Byte			length
279 	);
280 VOID
281 EXhalbtc8703b1ant_RfStatusNotify(
282 	IN	PBTC_COEXIST			pBtCoexist,
283 	IN	u1Byte					type
284 	);
285 VOID
286 EXhalbtc8703b1ant_HaltNotify(
287 	IN	PBTC_COEXIST			pBtCoexist
288 	);
289 VOID
290 EXhalbtc8703b1ant_PnpNotify(
291 	IN	PBTC_COEXIST			pBtCoexist,
292 	IN	u1Byte				pnpState
293 	);
294 VOID
295 EXhalbtc8703b1ant_CoexDmReset(
296 	IN	PBTC_COEXIST			pBtCoexist
297 	);
298 VOID
299 EXhalbtc8703b1ant_Periodical(
300 	IN	PBTC_COEXIST			pBtCoexist
301 	);
302 VOID
303 EXhalbtc8703b1ant_DisplayCoexInfo(
304 	IN	PBTC_COEXIST		pBtCoexist
305 	);
306 VOID
307 EXhalbtc8703b1ant_AntennaDetection(
308 	IN	PBTC_COEXIST			pBtCoexist,
309 	IN	u4Byte					centFreq,
310 	IN	u4Byte					offset,
311 	IN	u4Byte					span,
312 	IN	u4Byte					seconds
313 	);
314 VOID
315 EXhalbtc8703b1ant_AntennaIsolation(
316 	IN	PBTC_COEXIST			pBtCoexist,
317 	IN	u4Byte					centFreq,
318 	IN	u4Byte					offset,
319 	IN	u4Byte					span,
320 	IN	u4Byte					seconds
321 	);
322 
323 VOID
324 EXhalbtc8703b1ant_PSDScan(
325 	IN	PBTC_COEXIST			pBtCoexist,
326 	IN	u4Byte					centFreq,
327 	IN	u4Byte					offset,
328 	IN	u4Byte					span,
329 	IN	u4Byte					seconds
330 	);
331 VOID
332 EXhalbtc8703b1ant_DisplayAntDetection(
333 	IN	PBTC_COEXIST			pBtCoexist
334 	);
335 
336