net: wireless: rockchip_wlan: add rtl8188eu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188eu / hal / btc / HalBtc8723b1Ant.h
1 //===========================================
2 // The following is for 8723B 1ANT BT Co-exist definition
3 //===========================================
4 #define BT_AUTO_REPORT_ONLY_8723B_1ANT                          1
5
6 #define BT_INFO_8723B_1ANT_B_FTP                                                BIT7
7 #define BT_INFO_8723B_1ANT_B_A2DP                                       BIT6
8 #define BT_INFO_8723B_1ANT_B_HID                                                BIT5
9 #define BT_INFO_8723B_1ANT_B_SCO_BUSY                           BIT4
10 #define BT_INFO_8723B_1ANT_B_ACL_BUSY                           BIT3
11 #define BT_INFO_8723B_1ANT_B_INQ_PAGE                           BIT2
12 #define BT_INFO_8723B_1ANT_B_SCO_ESCO                           BIT1
13 #define BT_INFO_8723B_1ANT_B_CONNECTION                         BIT0
14
15 #define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_)       \
16                 (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE)
17
18 #define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT             2
19
20 #define  BT_8723B_1ANT_WIFI_NOISY_THRESH                                                                50 //30   //max: 255                                                            
21
22 //for Antenna detection
23 #define BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND                                        50
24 #define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION                         70
25 #define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION                        55
26 #define BT_8723B_1ANT_ANTDET_PSDTHRES_1ANT                                                      35
27 #define BT_8723B_1ANT_ANTDET_RETRY_INTERVAL                                                     10      //retry timer if ant det is fail, unit: second
28 #define BT_8723B_1ANT_ANTDET_ENABLE                                                                     0
29 #define BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE                         0
30
31 typedef enum _BT_INFO_SRC_8723B_1ANT{
32         BT_INFO_SRC_8723B_1ANT_WIFI_FW                  = 0x0,
33         BT_INFO_SRC_8723B_1ANT_BT_RSP                           = 0x1,
34         BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND           = 0x2,
35         BT_INFO_SRC_8723B_1ANT_MAX
36 }BT_INFO_SRC_8723B_1ANT,*PBT_INFO_SRC_8723B_1ANT;
37
38 typedef enum _BT_8723B_1ANT_BT_STATUS{
39         BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE      = 0x0,
40         BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE          = 0x1,
41         BT_8723B_1ANT_BT_STATUS_INQ_PAGE                                = 0x2,
42         BT_8723B_1ANT_BT_STATUS_ACL_BUSY                                = 0x3,
43         BT_8723B_1ANT_BT_STATUS_SCO_BUSY                                = 0x4,
44         BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY                    = 0x5,
45         BT_8723B_1ANT_BT_STATUS_MAX
46 }BT_8723B_1ANT_BT_STATUS,*PBT_8723B_1ANT_BT_STATUS;
47
48 typedef enum _BT_8723B_1ANT_WIFI_STATUS{
49         BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE                            = 0x0,
50         BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN          = 0x1,
51         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN                                        = 0x2,
52         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT                         = 0x3,
53         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE                                        = 0x4,
54         BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY                                        = 0x5,
55         BT_8723B_1ANT_WIFI_STATUS_MAX
56 }BT_8723B_1ANT_WIFI_STATUS,*PBT_8723B_1ANT_WIFI_STATUS;
57
58 typedef enum _BT_8723B_1ANT_COEX_ALGO{
59         BT_8723B_1ANT_COEX_ALGO_UNDEFINED                       = 0x0,
60         BT_8723B_1ANT_COEX_ALGO_SCO                             = 0x1,
61         BT_8723B_1ANT_COEX_ALGO_HID                             = 0x2,
62         BT_8723B_1ANT_COEX_ALGO_A2DP                            = 0x3,
63         BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS              = 0x4,
64         BT_8723B_1ANT_COEX_ALGO_PANEDR                  = 0x5,
65         BT_8723B_1ANT_COEX_ALGO_PANHS                   = 0x6,
66         BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP             = 0x7,
67         BT_8723B_1ANT_COEX_ALGO_PANEDR_HID              = 0x8,
68         BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
69         BT_8723B_1ANT_COEX_ALGO_HID_A2DP                        = 0xa,
70         BT_8723B_1ANT_COEX_ALGO_MAX                             = 0xb,
71 }BT_8723B_1ANT_COEX_ALGO,*PBT_8723B_1ANT_COEX_ALGO;
72
73 typedef struct _COEX_DM_8723B_1ANT{
74         // hw setting
75         u1Byte          preAntPosType;
76         u1Byte          curAntPosType;
77         // fw mechanism
78         BOOLEAN         bCurIgnoreWlanAct;
79         BOOLEAN         bPreIgnoreWlanAct;
80         u1Byte          prePsTdma;
81         u1Byte          curPsTdma;
82         u1Byte          psTdmaPara[5];
83         u1Byte          psTdmaDuAdjType;
84         BOOLEAN         bAutoTdmaAdjust;
85         BOOLEAN         bPrePsTdmaOn;
86         BOOLEAN         bCurPsTdmaOn;
87         BOOLEAN         bPreBtAutoReport;
88         BOOLEAN         bCurBtAutoReport;
89         u1Byte          preLps;
90         u1Byte          curLps;
91         u1Byte          preRpwm;
92         u1Byte          curRpwm;
93
94         // sw mechanism
95         BOOLEAN         bPreLowPenaltyRa;
96         BOOLEAN         bCurLowPenaltyRa;
97         u4Byte          preVal0x6c0;
98         u4Byte          curVal0x6c0;
99         u4Byte          preVal0x6c4;
100         u4Byte          curVal0x6c4;
101         u4Byte          preVal0x6c8;
102         u4Byte          curVal0x6c8;
103         u1Byte          preVal0x6cc;
104         u1Byte          curVal0x6cc;
105         BOOLEAN         bLimitedDig;
106
107         u4Byte          backupArfrCnt1; // Auto Rate Fallback Retry cnt
108         u4Byte          backupArfrCnt2; // Auto Rate Fallback Retry cnt
109         u2Byte          backupRetryLimit;
110         u1Byte          backupAmpduMaxTime;
111
112         // algorithm related
113         u1Byte          preAlgorithm;
114         u1Byte          curAlgorithm;
115         u1Byte          btStatus;
116         u1Byte          wifiChnlInfo[3];
117
118         u4Byte          preRaMask;
119         u4Byte          curRaMask;
120         u1Byte          preArfrType;
121         u1Byte          curArfrType;
122         u1Byte          preRetryLimitType;
123         u1Byte          curRetryLimitType;
124         u1Byte          preAmpduTimeType;
125         u1Byte          curAmpduTimeType;
126         u4Byte          nArpCnt;
127
128         u1Byte          errorCondition;
129 } COEX_DM_8723B_1ANT, *PCOEX_DM_8723B_1ANT;
130
131 typedef struct _COEX_STA_8723B_1ANT{
132         BOOLEAN                                 bBtLinkExist;
133         BOOLEAN                                 bScoExist;
134         BOOLEAN                                 bA2dpExist;
135         BOOLEAN                                 bHidExist;
136         BOOLEAN                                 bPanExist;
137         BOOLEAN                                 bBtHiPriLinkExist;
138         u1Byte                                  nNumOfProfile;
139
140         BOOLEAN                                 bUnderLps;
141         BOOLEAN                                 bUnderIps;
142         u4Byte                                  specialPktPeriodCnt;
143         u4Byte                                  highPriorityTx;
144         u4Byte                                  highPriorityRx;
145         u4Byte                                  lowPriorityTx;
146         u4Byte                                  lowPriorityRx;
147         s1Byte                                  btRssi;
148         BOOLEAN                                 bBtTxRxMask;
149         u1Byte                                  preBtRssiState;
150         u1Byte                                  preWifiRssiState[4];
151         BOOLEAN                                 bC2hBtInfoReqSent;
152         u1Byte                                  btInfoC2h[BT_INFO_SRC_8723B_1ANT_MAX][10];
153         u4Byte                                  btInfoC2hCnt[BT_INFO_SRC_8723B_1ANT_MAX];
154         BOOLEAN                                 bBtWhckTest;
155         BOOLEAN                                 bC2hBtInquiryPage;
156         BOOLEAN                                 bC2hBtRemoteNameReq;                            
157         BOOLEAN                                 bWiFiIsHighPriTask;             //Add for win8.1 page out issue
158         u1Byte                                  btRetryCnt;
159         u1Byte                                  btInfoExt;
160         u4Byte                                  popEventCnt;
161         u1Byte                                  nScanAPNum;
162
163         u4Byte                                  nCRCOK_CCK;
164         u4Byte                                  nCRCOK_11g;
165         u4Byte                                  nCRCOK_11n;
166         u4Byte                                  nCRCOK_11nAgg;
167         
168         u4Byte                                  nCRCErr_CCK;
169         u4Byte                                  nCRCErr_11g;
170         u4Byte                                  nCRCErr_11n;
171         u4Byte                                  nCRCErr_11nAgg; 
172
173         BOOLEAN                                 bCCKLock;
174         BOOLEAN                                 bPreCCKLock;
175         BOOLEAN                                 bCCKEverLock;
176         u1Byte                                  nCoexTableType;
177
178         BOOLEAN                                 bForceLpsOn;
179         u4Byte                                  wrongProfileNotification;
180
181         u1Byte                                  nA2DPBitPool;
182         u1Byte                                  nCutVersion;
183 }COEX_STA_8723B_1ANT, *PCOEX_STA_8723B_1ANT;
184
185 #define  BT_8723B_1ANT_ANTDET_PSD_POINTS                        256     //MAX:1024
186 #define  BT_8723B_1ANT_ANTDET_PSD_AVGNUM                        1       //MAX:3
187 #define BT_8723B_1ANT_ANTDET_BUF_LEN                            16
188
189 typedef struct _PSDSCAN_STA_8723B_1ANT{
190
191 u4Byte                  nAntDet_BTLEChannel;  //BT LE Channel ex:2412
192 u4Byte                  nAntDet_BTTxTime;
193 u4Byte                  nAntDet_PrePSDScanPeakVal;
194 BOOLEAN                 nAntDet_IsAntDetAvailable;
195 u4Byte                  nAntDet_PSDScanPeakVal;
196 BOOLEAN                 nAntDet_IsBTReplyAvailable;
197 u4Byte                  nAntDet_PSDScanPeakFreq;
198
199 u1Byte                  nAntDet_Result;
200 u1Byte                  nAntDet_PeakVal[BT_8723B_1ANT_ANTDET_BUF_LEN];
201 u1Byte                  nAntDet_PeakFreq[BT_8723B_1ANT_ANTDET_BUF_LEN];
202 u4Byte                  bAntDet_TryCount;
203 u4Byte                  bAntDet_FailCount;
204 u4Byte                  nAntDet_IntevalCount;
205 u4Byte                  nAntDet_ThresOffset;
206
207 u4Byte                  nRealCentFreq;
208 s4Byte                  nRealOffset;
209 u4Byte                  nRealSpan;
210         
211 u4Byte                  nPSDBandWidth;  //unit: Hz
212 u4Byte                  nPSDPoint;              //128/256/512/1024
213 u4Byte                  nPSDReport[1024];  //unit:dB (20logx), 0~255
214 u4Byte                  nPSDReport_MaxHold[1024];  //unit:dB (20logx), 0~255
215 u4Byte                  nPSDStartPoint;
216 u4Byte                  nPSDStopPoint;
217 u4Byte                  nPSDMaxValuePoint;
218 u4Byte                  nPSDMaxValue;
219 u4Byte                  nPSDStartBase;
220 u4Byte                  nPSDAvgNum;     // 1/8/16/32
221 u4Byte                  nPSDGenCount;
222 BOOLEAN                 bIsPSDRunning;
223 BOOLEAN                 bIsPSDShowMaxOnly;
224 } PSDSCAN_STA_8723B_1ANT, *PPSDSCAN_STA_8723B_1ANT;
225
226 //===========================================
227 // The following is interface which will notify coex module.
228 //===========================================
229 VOID
230 EXhalbtc8723b1ant_PowerOnSetting(
231         IN      PBTC_COEXIST            pBtCoexist
232         );
233 VOID
234 EXhalbtc8723b1ant_PreLoadFirmware(
235         IN      PBTC_COEXIST            pBtCoexist
236         );
237 VOID
238 EXhalbtc8723b1ant_InitHwConfig(
239         IN      PBTC_COEXIST            pBtCoexist,
240         IN      BOOLEAN                         bWifiOnly
241         );
242 VOID
243 EXhalbtc8723b1ant_InitCoexDm(
244         IN      PBTC_COEXIST            pBtCoexist
245         );
246 VOID
247 EXhalbtc8723b1ant_IpsNotify(
248         IN      PBTC_COEXIST            pBtCoexist,
249         IN      u1Byte                  type
250         );
251 VOID
252 EXhalbtc8723b1ant_LpsNotify(
253         IN      PBTC_COEXIST            pBtCoexist,
254         IN      u1Byte                  type
255         );
256 VOID
257 EXhalbtc8723b1ant_ScanNotify(
258         IN      PBTC_COEXIST            pBtCoexist,
259         IN      u1Byte                  type
260         );
261 VOID
262 EXhalbtc8723b1ant_ConnectNotify(
263         IN      PBTC_COEXIST            pBtCoexist,
264         IN      u1Byte                  type
265         );
266 VOID
267 EXhalbtc8723b1ant_MediaStatusNotify(
268         IN      PBTC_COEXIST                    pBtCoexist,
269         IN      u1Byte                          type
270         );
271 VOID
272 EXhalbtc8723b1ant_SpecialPacketNotify(
273         IN      PBTC_COEXIST                    pBtCoexist,
274         IN      u1Byte                          type
275         );
276 VOID
277 EXhalbtc8723b1ant_BtInfoNotify(
278         IN      PBTC_COEXIST            pBtCoexist,
279         IN      pu1Byte                 tmpBuf,
280         IN      u1Byte                  length
281         );
282 VOID
283 EXhalbtc8723b1ant_RfStatusNotify(
284         IN      PBTC_COEXIST                    pBtCoexist,
285         IN      u1Byte                                  type
286         );
287 VOID
288 EXhalbtc8723b1ant_HaltNotify(
289         IN      PBTC_COEXIST                    pBtCoexist
290         );
291 VOID
292 EXhalbtc8723b1ant_PnpNotify(
293         IN      PBTC_COEXIST                    pBtCoexist,
294         IN      u1Byte                          pnpState
295         );
296 VOID
297 EXhalbtc8723b1ant_CoexDmReset(
298         IN      PBTC_COEXIST                    pBtCoexist
299         );
300 VOID
301 EXhalbtc8723b1ant_Periodical(
302         IN      PBTC_COEXIST                    pBtCoexist
303         );
304 VOID
305 EXhalbtc8723b1ant_DisplayCoexInfo(
306         IN      PBTC_COEXIST            pBtCoexist
307         );
308 VOID
309 EXhalbtc8723b1ant_AntennaDetection(
310         IN      PBTC_COEXIST                    pBtCoexist,
311         IN      u4Byte                                  centFreq,
312         IN      u4Byte                                  offset,
313         IN      u4Byte                                  span,
314         IN      u4Byte                                  seconds
315         );
316 VOID
317 EXhalbtc8723b1ant_AntennaIsolation(
318         IN      PBTC_COEXIST                    pBtCoexist,
319         IN      u4Byte                                  centFreq,
320         IN      u4Byte                                  offset,
321         IN      u4Byte                                  span,
322         IN      u4Byte                                  seconds
323         );
324
325 VOID
326 EXhalbtc8723b1ant_PSDScan(
327         IN      PBTC_COEXIST                    pBtCoexist,
328         IN      u4Byte                                  centFreq,
329         IN      u4Byte                                  offset,
330         IN      u4Byte                                  span,
331         IN      u4Byte                                  seconds
332         );
333 VOID
334 EXhalbtc8723b1ant_DisplayAntDetection(
335         IN      PBTC_COEXIST                    pBtCoexist
336         );
337