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