net: wireless: rockchip_wlan: add rtl8188fu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188fu / hal / btc / HalBtc8821a2Ant.c
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8188fu/hal/btc/HalBtc8821a2Ant.c b/drivers/net/wireless/rockchip_wlan/rtl8188fu/hal/btc/HalBtc8821a2Ant.c
new file mode 100644 (file)
index 0000000..f107bb8
--- /dev/null
@@ -0,0 +1,4858 @@
+//============================================================\r
+// Description:\r
+//\r
+// This file is for RTL8821A Co-exist mechanism\r
+//\r
+// History\r
+// 2012/11/15 Cosa first check in.\r
+//\r
+//============================================================\r
+\r
+//============================================================\r
+// include files\r
+//============================================================\r
+#include "Mp_Precomp.h"\r
+\r
+#if WPP_SOFTWARE_TRACE\r
+#include "HalBtc8821a2Ant.tmh"\r
+#endif\r
+\r
+#if (RTL8821A_SUPPORT == 1)\r
+\r
+#if(BT_30_SUPPORT == 1)\r
+//============================================================\r
+// Global variables, these are static variables\r
+//============================================================\r
+static COEX_DM_8821A_2ANT              GLCoexDm8821a2Ant;\r
+static PCOEX_DM_8821A_2ANT     pCoexDm=&GLCoexDm8821a2Ant;\r
+static COEX_STA_8821A_2ANT             GLCoexSta8821a2Ant;\r
+static PCOEX_STA_8821A_2ANT    pCoexSta=&GLCoexSta8821a2Ant;\r
+\r
+const char *const GLBtInfoSrc8821a2Ant[]={\r
+       "BT Info[wifi fw]",\r
+       "BT Info[bt rsp]",\r
+       "BT Info[bt auto report]",\r
+};\r
+\r
+u4Byte GLCoexVerDate8821a2Ant=20150921;\r
+u4Byte GLCoexVer8821a2Ant=0x58;\r
+//modify 20140903v43 a2dpandhid tdmaonoff a2dp glitch _ tdma off 778=3(case1)->778=1(case0)\r
+//and to improve tp while a2dphid case23->case25 , case123->case125 for asus spec\r
+//and modify for asus bt WHQL test _ tdma off_ 778=3->1_\r
+//============================================================\r
+// local function proto type if needed\r
+//============================================================\r
+//============================================================\r
+// local function start with halbtc8821a2ant_\r
+//============================================================\r
+u1Byte\r
+halbtc8821a2ant_BtRssiState(\r
+       u1Byte                  levelNum,\r
+       u1Byte                  rssiThresh,\r
+       u1Byte                  rssiThresh1\r
+       )\r
+{\r
+       s4Byte                  btRssi=0;\r
+       u1Byte                  btRssiState=pCoexSta->preBtRssiState;\r
+\r
+       btRssi = pCoexSta->btRssi;\r
+\r
+       if(levelNum == 2)\r
+       {                       \r
+               if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||\r
+                       (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))\r
+               {\r
+                       if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_HIGH;\r
+                       }\r
+                       else\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_STAY_LOW;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if(btRssi < rssiThresh)\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_LOW;\r
+                       }\r
+                       else\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_STAY_HIGH;\r
+                       }\r
+               }\r
+       }\r
+       else if(levelNum == 3)\r
+       {\r
+               if(rssiThresh > rssiThresh1)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n"));\r
+                       return pCoexSta->preBtRssiState;\r
+               }\r
+               \r
+               if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||\r
+                       (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))\r
+               {\r
+                       if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_MEDIUM;\r
+                       }\r
+                       else\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_STAY_LOW;\r
+                       }\r
+               }\r
+               else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||\r
+                       (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))\r
+               {\r
+                       if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_HIGH;\r
+                       }\r
+                       else if(btRssi < rssiThresh)\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_LOW;\r
+                       }\r
+                       else\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if(btRssi < rssiThresh1)\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_MEDIUM;\r
+                       }\r
+                       else\r
+                       {\r
+                               btRssiState = BTC_RSSI_STATE_STAY_HIGH;\r
+                       }\r
+               }\r
+       }\r
+               \r
+       pCoexSta->preBtRssiState = btRssiState;\r
+\r
+       return btRssiState;\r
+}\r
+\r
+u1Byte\r
+halbtc8821a2ant_WifiRssiState(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  index,\r
+       IN      u1Byte                  levelNum,\r
+       IN      u1Byte                  rssiThresh,\r
+       IN      u1Byte                  rssiThresh1\r
+       )\r
+{\r
+       s4Byte                  wifiRssi=0;\r
+       u1Byte                  wifiRssiState=pCoexSta->preWifiRssiState[index];\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);\r
+       \r
+       if(levelNum == 2)\r
+       {\r
+               if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||\r
+                       (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))\r
+               {\r
+                       if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_HIGH;\r
+                       }\r
+                       else\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_STAY_LOW;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if(wifiRssi < rssiThresh)\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_LOW;\r
+                       }\r
+                       else\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;\r
+                       }\r
+               }\r
+       }\r
+       else if(levelNum == 3)\r
+       {\r
+               if(rssiThresh > rssiThresh1)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n"));\r
+                       return pCoexSta->preWifiRssiState[index];\r
+               }\r
+               \r
+               if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||\r
+                       (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))\r
+               {\r
+                       if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_MEDIUM;\r
+                       }\r
+                       else\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_STAY_LOW;\r
+                       }\r
+               }\r
+               else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||\r
+                       (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))\r
+               {\r
+                       if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT))\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_HIGH;\r
+                       }\r
+                       else if(wifiRssi < rssiThresh)\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_LOW;\r
+                       }\r
+                       else\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if(wifiRssi < rssiThresh1)\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_MEDIUM;\r
+                       }\r
+                       else\r
+                       {\r
+                               wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;\r
+                       }\r
+               }\r
+       }\r
+               \r
+       pCoexSta->preWifiRssiState[index] = wifiRssiState;\r
+\r
+       return wifiRssiState;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_MonitorBtEnableDisable(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       static BOOLEAN  bPreBtDisabled=FALSE;\r
+       static u4Byte   btDisableCnt=0;\r
+       BOOLEAN                 bBtActive=TRUE, bBtDisabled=FALSE;\r
+\r
+       // This function check if bt is disabled\r
+\r
+       if(     pCoexSta->highPriorityTx == 0 &&\r
+               pCoexSta->highPriorityRx == 0 &&\r
+               pCoexSta->lowPriorityTx == 0 &&\r
+               pCoexSta->lowPriorityRx == 0)\r
+       {\r
+               bBtActive = FALSE;\r
+       }\r
+       if(     pCoexSta->highPriorityTx == 0xffff &&\r
+               pCoexSta->highPriorityRx == 0xffff &&\r
+               pCoexSta->lowPriorityTx == 0xffff &&\r
+               pCoexSta->lowPriorityRx == 0xffff)\r
+       {\r
+               bBtActive = FALSE;\r
+       }\r
+       if(bBtActive)\r
+       {\r
+               btDisableCnt = 0;\r
+               bBtDisabled = FALSE;\r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n"));\r
+       }\r
+       else\r
+       {\r
+               btDisableCnt++;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", \r
+                               btDisableCnt));\r
+               if(btDisableCnt >= 2)\r
+               {\r
+                       bBtDisabled = TRUE;\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n"));\r
+               }\r
+       }\r
+       if(bPreBtDisabled != bBtDisabled)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", \r
+                       (bPreBtDisabled ? "disabled":"enabled"), \r
+                       (bBtDisabled ? "disabled":"enabled")));\r
+               bPreBtDisabled = bBtDisabled;\r
+               if(!bBtDisabled)\r
+               {\r
+               }\r
+               else\r
+               {\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_LimitedRx(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      BOOLEAN                         bRejApAggPkt,\r
+       IN      BOOLEAN                         bBtCtrlAggBufSize,\r
+       IN      u1Byte                          aggBufSize\r
+       )\r
+{\r
+       BOOLEAN bRejectRxAgg=bRejApAggPkt;\r
+       BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize;\r
+       u1Byte  rxAggSize=aggBufSize;\r
+\r
+       //============================================\r
+       //      Rx Aggregation related setting\r
+       //============================================\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg);\r
+       // decide BT control aggregation buf size or not\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize);\r
+       // aggregation buf size, only work when BT control Rx aggregation size.\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);\r
+       // real update aggregation setting\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_MonitorBtCtr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u4Byte                  regHPTxRx, regLPTxRx, u4Tmp;\r
+       u4Byte                  regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;\r
+       u1Byte                  u1Tmp;\r
+       \r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       \r
+       regHPTxRx = 0x770;\r
+       regLPTxRx = 0x774;\r
+\r
+       u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx);\r
+       regHPTx = u4Tmp & bMaskLWord;\r
+       regHPRx = (u4Tmp & bMaskHWord)>>16;\r
+\r
+       u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx);\r
+       regLPTx = u4Tmp & bMaskLWord;\r
+       regLPRx = (u4Tmp & bMaskHWord)>>16;\r
+               \r
+       pCoexSta->highPriorityTx = regHPTx;\r
+       pCoexSta->highPriorityRx = regHPRx;\r
+       pCoexSta->lowPriorityTx = regLPTx;\r
+       pCoexSta->lowPriorityRx = regLPRx;\r
+\r
+       if ( (pCoexSta->lowPriorityRx >= 950)  &&  (pCoexSta->lowPriorityRx >= pCoexSta->lowPriorityTx) && (!pCoexSta->bUnderIps) )\r
+       {\r
+               pBtLinkInfo->bSlaveRole = TRUE;\r
+       }\r
+       else\r
+       {\r
+               pBtLinkInfo->bSlaveRole = FALSE;\r
+       }\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", \r
+               regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", \r
+               regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));\r
+\r
+       // reset counter\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_MonitorWiFiCtr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u4Byte  u4Tmp;\r
+       u2Byte  u2Tmp[3];\r
+       s4Byte  wifiRssi=0;\r
+       BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE;\r
+       static u1Byte nCCKLockCounter = 0;\r
+\r
+\r
+       if (pCoexSta->bUnderIps)\r
+       {\r
+               pCoexSta->nCRCOK_CCK = 0;\r
+               pCoexSta->nCRCOK_11g = 0;\r
+               pCoexSta->nCRCOK_11n = 0;\r
+               pCoexSta->nCRCOK_11nAgg = 0;\r
+\r
+               pCoexSta->nCRCErr_CCK = 0;\r
+               pCoexSta->nCRCErr_11g = 0;\r
+               pCoexSta->nCRCErr_11n = 0;\r
+               pCoexSta->nCRCErr_11nAgg = 0;   \r
+       }\r
+       else\r
+       {\r
+               pCoexSta->nCRCOK_CCK    = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88);\r
+               pCoexSta->nCRCOK_11g    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94);\r
+               pCoexSta->nCRCOK_11n    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90);\r
+               pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8);\r
+\r
+               pCoexSta->nCRCErr_CCK    = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84);\r
+               pCoexSta->nCRCErr_11g    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96);\r
+               pCoexSta->nCRCErr_11n    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92);\r
+               pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba);                \r
+       }\r
+\r
+       //reset counter\r
+       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1);\r
+       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_QueryBtInfo(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[1] ={0};\r
+\r
+       pCoexSta->bC2hBtInfoReqSent = TRUE;\r
+\r
+       H2C_Parameter[0] |= BIT0;       // trigger\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", \r
+               H2C_Parameter[0]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter);\r
+}\r
+\r
+BOOLEAN\r
+halbtc8821a2ant_IsWifiStatusChanged(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       static BOOLEAN  bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;\r
+       BOOLEAN                 bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;\r
+       BOOLEAN                 bWifiConnected=FALSE;\r
+       u1Byte                  wifiRssiState=BTC_RSSI_STATE_HIGH;\r
+       \r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);\r
+\r
+       if(bWifiConnected)\r
+       {\r
+               if(bWifiBusy != bPreWifiBusy)\r
+               {\r
+                       bPreWifiBusy = bWifiBusy;\r
+                       return TRUE;\r
+               }\r
+               if(bUnder4way != bPreUnder4way)\r
+               {\r
+                       bPreUnder4way = bUnder4way;\r
+                       return TRUE;\r
+               }\r
+               if(bBtHsOn != bPreBtHsOn)\r
+               {\r
+                       bPreBtHsOn = bBtHsOn;\r
+                       return TRUE;\r
+               }\r
+\r
+\r
+               wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist,3, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);    \r
+\r
+               if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) ||  (BTC_RSSI_STATE_LOW ==wifiRssiState ))\r
+               {\r
+                       return TRUE;\r
+               }\r
+       \r
+       }\r
+\r
+       return FALSE;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_UpdateBtLinkInfo(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_STACK_INFO         pStackInfo=&pBtCoexist->stackInfo;\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                         bBtHsOn=FALSE;\r
+\r
+#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 1)       // profile from bt patch\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+\r
+       pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;\r
+       pBtLinkInfo->bScoExist = pCoexSta->bScoExist;\r
+       pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;\r
+       pBtLinkInfo->bPanExist = pCoexSta->bPanExist;\r
+       pBtLinkInfo->bHidExist = pCoexSta->bHidExist;\r
+\r
+       // work around for HS mode.\r
+       if(bBtHsOn)\r
+       {\r
+               pBtLinkInfo->bPanExist = TRUE;\r
+               pBtLinkInfo->bBtLinkExist = TRUE;\r
+       }\r
+#else  // profile from bt stack\r
+       pBtLinkInfo->bBtLinkExist = pStackInfo->bBtLinkExist;\r
+       pBtLinkInfo->bScoExist = pStackInfo->bScoExist;\r
+       pBtLinkInfo->bA2dpExist = pStackInfo->bA2dpExist;\r
+       pBtLinkInfo->bPanExist = pStackInfo->bPanExist;\r
+       pBtLinkInfo->bHidExist = pStackInfo->bHidExist;\r
+\r
+       //for win-8 stack HID report error\r
+       if(!pStackInfo->bHidExist)\r
+               pStackInfo->bHidExist = pCoexSta->bHidExist;  //sync  BTInfo with BT firmware and stack\r
+       // when stack HID report error, here we use the info from bt fw.\r
+       if(!pStackInfo->bBtLinkExist)\r
+               pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist;      \r
+#endif\r
+       // check if Sco only\r
+       if( pBtLinkInfo->bScoExist &&\r
+               !pBtLinkInfo->bA2dpExist &&\r
+               !pBtLinkInfo->bPanExist &&\r
+               !pBtLinkInfo->bHidExist )\r
+               pBtLinkInfo->bScoOnly = TRUE;\r
+       else\r
+               pBtLinkInfo->bScoOnly = FALSE;\r
+\r
+       // check if A2dp only\r
+       if( !pBtLinkInfo->bScoExist &&\r
+               pBtLinkInfo->bA2dpExist &&\r
+               !pBtLinkInfo->bPanExist &&\r
+               !pBtLinkInfo->bHidExist )\r
+               pBtLinkInfo->bA2dpOnly = TRUE;\r
+       else\r
+               pBtLinkInfo->bA2dpOnly = FALSE;\r
+\r
+       // check if Pan only\r
+       if( !pBtLinkInfo->bScoExist &&\r
+               !pBtLinkInfo->bA2dpExist &&\r
+               pBtLinkInfo->bPanExist &&\r
+               !pBtLinkInfo->bHidExist )\r
+               pBtLinkInfo->bPanOnly = TRUE;\r
+       else\r
+               pBtLinkInfo->bPanOnly = FALSE;\r
+       \r
+       // check if Hid only\r
+       if( !pBtLinkInfo->bScoExist &&\r
+               !pBtLinkInfo->bA2dpExist &&\r
+               !pBtLinkInfo->bPanExist &&\r
+               pBtLinkInfo->bHidExist )\r
+               pBtLinkInfo->bHidOnly = TRUE;\r
+       else\r
+               pBtLinkInfo->bHidOnly = FALSE;\r
+}\r
+\r
+u1Byte\r
+halbtc8821a2ant_ActionAlgorithm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                         bBtHsOn=FALSE;\r
+       u1Byte                          algorithm=BT_8821A_2ANT_COEX_ALGO_UNDEFINED;\r
+       u1Byte                          numOfDiffProfile=0;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+               \r
+       if(!pBtLinkInfo->bBtLinkExist)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n"));\r
+               return algorithm;\r
+       }\r
+\r
+       if(pBtLinkInfo->bScoExist)\r
+               numOfDiffProfile++;\r
+       if(pBtLinkInfo->bHidExist)\r
+               numOfDiffProfile++;\r
+       if(pBtLinkInfo->bPanExist)\r
+               numOfDiffProfile++;\r
+       if(pBtLinkInfo->bA2dpExist)\r
+               numOfDiffProfile++;\r
+       \r
+       if(numOfDiffProfile == 1)\r
+       {\r
+               if(pBtLinkInfo->bScoExist)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n"));\r
+                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+               }\r
+               else\r
+               {\r
+                       if(pBtLinkInfo->bHidExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n"));\r
+                               algorithm = BT_8821A_2ANT_COEX_ALGO_HID;\r
+                       }\r
+                       else if(pBtLinkInfo->bA2dpExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n"));\r
+                               algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP;\r
+                       }\r
+                       else if(pBtLinkInfo->bPanExist)\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_PANHS;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       else if(numOfDiffProfile == 2)\r
+       {\r
+               if(pBtLinkInfo->bScoExist)\r
+               {\r
+                       if(pBtLinkInfo->bHidExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n"));\r
+                               algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                       }\r
+                       else if(pBtLinkInfo->bA2dpExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n"));\r
+                               algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                       }\r
+                       else if(pBtLinkInfo->bPanExist)\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+#if 0\r
+                               if(pStackInfo->numOfHid >= 2)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;\r
+                               }\r
+                               else\r
+#endif\r
+                               {                       \r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP;\r
+                               }\r
+                       }\r
+                       else if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bPanExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_HID;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID;\r
+                               }\r
+                       }\r
+                       else if( pBtLinkInfo->bPanExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       else if(numOfDiffProfile == 3)\r
+       {\r
+               if(pBtLinkInfo->bScoExist)\r
+               {\r
+                       if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> SCO\n"));\r
+                               algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                       }\r
+                       else if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bPanExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS) ==> SCO\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR) ==> SCO\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                       }\r
+                       else if( pBtLinkInfo->bPanExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bPanExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       else if(numOfDiffProfile >= 3)\r
+       {\r
+               if(pBtLinkInfo->bScoExist)\r
+               {\r
+                       if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bPanExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));\r
+\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));\r
+                                       algorithm = BT_8821A_2ANT_COEX_ALGO_SCO;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       return algorithm;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetFwDacSwingLevel(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  dacSwingLvl\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[1] ={0};\r
+\r
+       // There are several type of dacswing\r
+       // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6\r
+       H2C_Parameter[0] = dacSwingLvl;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetFwDecBtPwr(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          decBtPwrLvl\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[1] ={0};\r
+       \r
+       H2C_Parameter[0] = decBtPwrLvl;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n", \r
+               decBtPwrLvl, H2C_Parameter[0]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter);    \r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_DecBtPwr(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          decBtPwrLvl\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n",  \r
+               (bForceExec? "force to":""), decBtPwrLvl));\r
+       pCoexDm->curBtDecPwrLvl = decBtPwrLvl;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) \r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);\r
+\r
+       pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetBtAutoReport(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bEnableAutoReport\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[1] ={0};\r
+       \r
+       H2C_Parameter[0] = 0;\r
+\r
+       if(bEnableAutoReport)\r
+       {\r
+               H2C_Parameter[0] |= BIT0;\r
+       }\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", \r
+               (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter);    \r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_BtAutoReport(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bEnableAutoReport\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n",  \r
+               (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));\r
+       pCoexDm->bCurBtAutoReport = bEnableAutoReport;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) \r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);\r
+\r
+       pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_FwDacSwingLvl(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      u1Byte                  fwDacSwingLvl\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n",  \r
+               (bForceExec? "force to":""), fwDacSwingLvl));\r
+       pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) \r
+                       return;\r
+       }\r
+\r
+       halbtc8821a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);\r
+\r
+       pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetSwRfRxLpfCorner(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bRxRfShrinkOn\r
+       )\r
+{\r
+       if(bRxRfShrinkOn)\r
+       {\r
+               //Shrink RF Rx LPF corner\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc);\r
+       }\r
+       else\r
+       {\r
+               //Resume RF Rx LPF corner\r
+               // After initialized, we can use pCoexDm->btRf0x1eBackup\r
+               if(pBtCoexist->bInitilized)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n"));\r
+                       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_RfShrink(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bRxRfShrinkOn\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n",  \r
+               (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));\r
+       pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) \r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);\r
+\r
+       pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetSwPenaltyTxRateAdaptive(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bLowPenaltyRa\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[6] ={0};\r
+       \r
+       H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty\r
+\r
+       if(bLowPenaltyRa)\r
+       {\r
+               H2C_Parameter[1] |= BIT0;\r
+               H2C_Parameter[2] = 0x00;  //normal rate except MCS7/6/5, OFDM54/48/36\r
+                H2C_Parameter[3] = 0xf5;  //MCS7 or OFDM54\r
+               H2C_Parameter[4] = 0xa0;  //MCS6 or OFDM48\r
+               H2C_Parameter[5] = 0xa0;        //MCS5 or OFDM36\r
+               //H2C_Parameter[3] = 0xf7;  //MCS7 or OFDM54\r
+               //H2C_Parameter[4] = 0xf8;  //MCS6 or OFDM48\r
+               //H2C_Parameter[5] = 0xf9;      //MCS5 or OFDM36        \r
+       }\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", \r
+               (bLowPenaltyRa? "ON!!":"OFF!!")) );\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_LowPenaltyRa(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bLowPenaltyRa\r
+       )\r
+{\r
+       //return;\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n",  \r
+               (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));\r
+       pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) \r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);\r
+\r
+       pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetDacSwingReg(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u4Byte                  level\r
+       )\r
+{\r
+       u1Byte  val=(u1Byte)level;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));\r
+       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc5b, 0x3e, val);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetSwFullTimeDacSwing(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bSwDacSwingOn,\r
+       IN      u4Byte                  swDacSwingLvl\r
+       )\r
+{\r
+       if(bSwDacSwingOn)\r
+       {\r
+               halbtc8821a2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);\r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_SetDacSwingReg(pBtCoexist, 0x18);\r
+       }\r
+}\r
+\r
+\r
+VOID\r
+halbtc8821a2ant_DacSwing(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bDacSwingOn,\r
+       IN      u4Byte                  dacSwingLvl\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",  \r
+               (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));\r
+       pCoexDm->bCurDacSwingOn = bDacSwingOn;\r
+       pCoexDm->curDacSwingLvl = dacSwingLvl;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&\r
+                       (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )\r
+                       return;\r
+       }\r
+       delay_ms(30);\r
+       halbtc8821a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);\r
+\r
+       pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;\r
+       pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetAdcBackOff(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bAdcBackOff\r
+       )\r
+{\r
+       if(bAdcBackOff)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n"));\r
+               pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x3);\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n"));\r
+               pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x1);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_AdcBackOff(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bAdcBackOff\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n",  \r
+               (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));\r
+       pCoexDm->bCurAdcBackOff = bAdcBackOff;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) \r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);\r
+\r
+       pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetAgcTable(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bAgcTableEn\r
+       )\r
+{\r
+       u1Byte          rssiAdjustVal=0;\r
+\r
+       //=================BB AGC Gain Table\r
+       if(bAgcTableEn)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n"));\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001);\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n"));\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001);\r
+       }\r
+       \r
+       \r
+       //=================RF Gain\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);\r
+       if(bAgcTableEn)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff);\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe);\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3);\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6);\r
+       }\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);\r
+       if(bAgcTableEn)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n"));\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff);\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe);\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n"));\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3);\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6);\r
+       }\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);\r
+\r
+       // set rssiAdjustVal for wifi module.\r
+       if(bAgcTableEn)\r
+       {\r
+               rssiAdjustVal = 8;\r
+       }\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_AgcTable(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bAgcTableEn\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n",  \r
+               (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));\r
+       pCoexDm->bCurAgcTableEn = bAgcTableEn;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) \r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetAgcTable(pBtCoexist, bAgcTableEn);\r
+\r
+       pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetCoexTable(\r
+       IN      PBTC_COEXIST    pBtCoexist,\r
+       IN      u4Byte          val0x6c0,\r
+       IN      u4Byte          val0x6c4,\r
+       IN      u4Byte          val0x6c8,\r
+       IN      u1Byte          val0x6cc\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));\r
+       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0);\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));\r
+       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4);\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));\r
+       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8);\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_CoexTable(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      u4Byte                  val0x6c0,\r
+       IN      u4Byte                  val0x6c4,\r
+       IN      u4Byte                  val0x6c8,\r
+       IN      u1Byte                  val0x6cc\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", \r
+               (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));\r
+       pCoexDm->curVal0x6c0 = val0x6c0;\r
+       pCoexDm->curVal0x6c4 = val0x6c4;\r
+       pCoexDm->curVal0x6c8 = val0x6c8;\r
+       pCoexDm->curVal0x6cc = val0x6cc;\r
+\r
+       if(!bForceExec)\r
+       {       \r
+               if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&\r
+                       (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&\r
+                       (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&\r
+                       (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )\r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);\r
+\r
+       pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;\r
+       pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;\r
+       pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;\r
+       pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_CoexTableWithType(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       pCoexSta->nCoexTableType = type;\r
+       \r
+       switch(type)\r
+       {\r
+               case 0:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);\r
+                       break;\r
+               case 1:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffffff, 0x3);\r
+                       break;\r
+               case 2:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 3:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);\r
+                       break;\r
+               case 4:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3);\r
+                       break;\r
+               case 5:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);\r
+                       break;\r
+               case 6:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);\r
+                       break;\r
+               case 7:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 8:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 9:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 10:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 11:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 12:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 13:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3);\r
+                       break;\r
+               case 14:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3);\r
+                       break;\r
+               case 15:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3);\r
+                       break;\r
+               case 16:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3);\r
+                       break;\r
+               case 17:\r
+                       halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xfafafafa, 0xfafafafa, 0xffffff, 0x3);\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetFwIgnoreWlanAct(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bEnable\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[1] ={0};\r
+               \r
+       if(bEnable)\r
+       {\r
+               H2C_Parameter[0] |= BIT0;               // function enable\r
+       }\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", \r
+               H2C_Parameter[0]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetLpsRpwm(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  lpsVal,\r
+       IN      u1Byte                  rpwmVal\r
+       )\r
+{\r
+       u1Byte  lps=lpsVal;\r
+       u1Byte  rpwm=rpwmVal;\r
+       \r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps);\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_LpsRpwm(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      u1Byte                  lpsVal,\r
+       IN      u1Byte                  rpwmVal\r
+       )\r
+{\r
+       BOOLEAN bForceExecPwrCmd=FALSE;\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", \r
+               (bForceExec? "force to":""), lpsVal, rpwmVal));\r
+       pCoexDm->curLps = lpsVal;\r
+       pCoexDm->curRpwm = rpwmVal;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if( (pCoexDm->preLps == pCoexDm->curLps) &&\r
+                       (pCoexDm->preRpwm == pCoexDm->curRpwm) )\r
+               {\r
+                       return;\r
+               }\r
+       }\r
+       halbtc8821a2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);\r
+\r
+       pCoexDm->preLps = pCoexDm->curLps;\r
+       pCoexDm->preRpwm = pCoexDm->curRpwm;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_IgnoreWlanAct(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bEnable\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", \r
+               (bForceExec? "force to":""), (bEnable? "ON":"OFF")));\r
+       pCoexDm->bCurIgnoreWlanAct = bEnable;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)\r
+                       return;\r
+       }\r
+       halbtc8821a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);\r
+\r
+       pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetFwPstdma(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  byte1,\r
+       IN      u1Byte                  byte2,\r
+       IN      u1Byte                  byte3,\r
+       IN      u1Byte                  byte4,\r
+       IN      u1Byte                  byte5\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[5] ={0};\r
+        \r
+       H2C_Parameter[0] = byte1;       \r
+       H2C_Parameter[1] = byte2;       \r
+       H2C_Parameter[2] = byte3;\r
+       H2C_Parameter[3] = byte4;\r
+       H2C_Parameter[4] = byte5;\r
+\r
+       pCoexDm->psTdmaPara[0] = byte1;\r
+       pCoexDm->psTdmaPara[1] = byte2;\r
+       pCoexDm->psTdmaPara[2] = byte3;\r
+       pCoexDm->psTdmaPara[3] = byte4;\r
+       pCoexDm->psTdmaPara[4] = byte5;\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n", \r
+               H2C_Parameter[0], \r
+               H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SwMechanism1(\r
+       IN      PBTC_COEXIST    pBtCoexist,     \r
+       IN      BOOLEAN         bShrinkRxLPF,\r
+       IN      BOOLEAN         bLowPenaltyRA,\r
+       IN      BOOLEAN         bLimitedDIG, \r
+       IN      BOOLEAN         bBTLNAConstrain\r
+       ) \r
+{\r
+       /*\r
+       u4Byte  wifiBw;\r
+       \r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+       \r
+       if(BTC_WIFI_BW_HT40 != wifiBw)  //only shrink RF Rx LPF for HT40\r
+       {\r
+               if (bShrinkRxLPF)\r
+                       bShrinkRxLPF = FALSE;\r
+       }\r
+       */\r
+       \r
+       //halbtc8821a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);\r
+       halbtc8821a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SwMechanism2(\r
+       IN      PBTC_COEXIST    pBtCoexist,     \r
+       IN      BOOLEAN         bAGCTableShift,\r
+       IN      BOOLEAN         bADCBackOff,\r
+       IN      BOOLEAN         bSWDACSwing,\r
+       IN      u4Byte          dacSwingLvl\r
+       ) \r
+{\r
+       //halbtc8821a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);\r
+       //halbtc8821a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff);\r
+       halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_SetAntPath(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          antPosType,\r
+       IN      BOOLEAN                         bInitHwCfg,\r
+       IN      BOOLEAN                         bWifiOff\r
+       )\r
+{\r
+       PBTC_BOARD_INFO         pBoardInfo=&pBtCoexist->boardInfo;\r
+       u4Byte                          u4Tmp=0;\r
+       u1Byte                          H2C_Parameter[2] ={0};\r
+       \r
+       if(bInitHwCfg)\r
+       {\r
+               // 0x4c[23]=0, 0x4c[24]=1  Antenna control by WL/BT\r
+               u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);\r
+               u4Tmp &=~BIT23;\r
+               u4Tmp |= BIT24;\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp);\r
+\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x974, 0x3ff);\r
+               //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77);\r
+\r
+               if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) \r
+               {\r
+                       //tell firmware "antenna inverse"  ==> WRONG firmware antenna control code.==>need fw to fix\r
+                       H2C_Parameter[0] = 1;\r
+                       H2C_Parameter[1] = 1;\r
+                       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);\r
+               }\r
+               else\r
+               {\r
+                       //tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix\r
+                       H2C_Parameter[0] = 0;\r
+                       H2C_Parameter[1] = 1;\r
+                       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter);\r
+               }\r
+       }\r
+       \r
+       // ext switch setting\r
+       switch(antPosType)\r
+       {\r
+               case BTC_ANT_WIFI_AT_MAIN:\r
+                       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1);\r
+                       break;\r
+               case BTC_ANT_WIFI_AT_AUX:\r
+                       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2);\r
+                       break;\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_PsTdma(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bTurnOn,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       BOOLEAN                 bTurnOnByCnt=FALSE;\r
+       u1Byte                  psTdmaTypeByCnt=0;\r
+       u1Byte                  wifiRssiState1, btRssiState;\r
+\r
+       \r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);\r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       if (!(BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) && bTurnOn)\r
+       {\r
+               type = type +100;  //for WiFi RSSI low or BT RSSI low\r
+       }\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", \r
+               (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));\r
+       pCoexDm->bCurPsTdmaOn = bTurnOn;\r
+       pCoexDm->curPsTdma = type;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&\r
+                       (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )\r
+                       return;\r
+       }       \r
+       if(bTurnOn)\r
+       {\r
+               switch(type)\r
+               {\r
+                       case 1:\r
+                       default:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 2:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 3:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);\r
+                               break;\r
+                       case 4:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 5:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90);                           \r
+                               break;\r
+                       case 6:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90);\r
+                               break;\r
+                       case 7:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);\r
+                               break;\r
+                       case 8: \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90);\r
+                               break;\r
+                       case 9: \r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 10:        \r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 11:        \r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90);\r
+                               break;\r
+                       case 12:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0xf1, 0x90);\r
+                               break;\r
+                       case 13:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90);           \r
+                               break;\r
+                       case 14:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90);           \r
+                               break;\r
+                       case 15:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90);           \r
+                               break;\r
+                       case 16:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90);\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0x70, 0x90);           \r
+                               break;\r
+                       case 17:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90);\r
+                               break;\r
+                       case 18:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90);\r
+                               break;                  \r
+                       case 19:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90);\r
+                               break;\r
+                       case 20:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90);\r
+                               break;\r
+                       case 21:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);\r
+                               break;  \r
+                       case 23:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0xf0, 0x14);\r
+                               break;\r
+                       case 24:\r
+                       case 124:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3c, 0x03, 0x70, 0x50);\r
+                               break;\r
+                               //case25/case125 : for lenovo bt pan tp degrade<30% while wifi downlink\r
+                       case 25:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x14, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                        case 26:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x30, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 71:\r
+                               //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90);\r
+\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 101:\r
+                       case 105:\r
+                       case 171:       \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3a, 0x03, 0x70, 0x50);\r
+                               break;\r
+                       case 102:\r
+                       case 106:\r
+                       case 110:\r
+                       case 114:       \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x2d, 0x03, 0x70, 0x50);\r
+                               break;  \r
+                       case 103:\r
+                       case 107:\r
+                       case 111:\r
+                       case 115:       \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50);\r
+                               break;          \r
+                       case 104:\r
+                       case 108:\r
+                       case 112:\r
+                       case 116:       \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x10, 0x03, 0x70, 0x50);\r
+                               break;  \r
+                       case 109:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90);\r
+                               break;\r
+                       case 113:       \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x70, 0x90);\r
+                               break;\r
+                       case 121:       \r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90);\r
+                               break;  \r
+                       case 22:\r
+                       case 122:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x35, 0x03, 0x71, 0x11);\r
+                               break;\r
+                       case 123:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x54);\r
+                               break;\r
+                               //case25/case125 : for lenovo bt pan tp degrade<30% while wifi downlink\r
+                       case 125:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x14, 0x03, 0x70, 0x50);\r
+                               break;\r
+                        case 126:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x30, 0x03, 0x70, 0x50);\r
+                               break;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               // disable PS tdma\r
+               switch(type)\r
+               {\r
+                       case 0:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);\r
+                               break;\r
+                       case 1:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0);\r
+                               break;\r
+                       default:\r
+                               halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0);\r
+                               break;\r
+               }\r
+       }\r
+\r
+       // update pre state\r
+       pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;\r
+       pCoexDm->prePsTdma = pCoexDm->curPsTdma;\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_PsTdmaCheckForPowerSaveState(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bNewPsState\r
+       )\r
+{\r
+       u1Byte  lpsMode=0x0;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);\r
+       \r
+       if(lpsMode)     // already under LPS state\r
+       {\r
+               if(bNewPsState)         \r
+               {\r
+                       // keep state under LPS, do nothing.\r
+               }\r
+               else\r
+               {\r
+                       // will leave LPS state, turn off psTdma first\r
+                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+               }\r
+       }\r
+       else                                            // NO PS state\r
+       {\r
+               if(bNewPsState)\r
+               {\r
+                       // will enter LPS state, turn off psTdma first\r
+                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+               }\r
+               else\r
+               {\r
+                       // keep state under NO PS state, do nothing.\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_PowerSaveState(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          psType,\r
+       IN      u1Byte                          lpsVal,\r
+       IN      u1Byte                          rpwmVal\r
+       )\r
+{\r
+       BOOLEAN         bLowPwrDisable=FALSE;\r
+       \r
+       switch(psType)\r
+       {\r
+               case BTC_PS_WIFI_NATIVE:\r
+                       // recover to original 32k low power setting\r
+                       bLowPwrDisable = FALSE;\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);\r
+                       pCoexSta->bForceLpsOn = FALSE;\r
+                       break;\r
+               case BTC_PS_LPS_ON:\r
+                       halbtc8821a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);\r
+                       halbtc8821a2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);                      \r
+                       // when coex force to enter LPS, do not enter 32k low power.\r
+                       bLowPwrDisable = TRUE;\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+                       // power save must executed before psTdma.                      \r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);\r
+                       pCoexSta->bForceLpsOn = TRUE;\r
+                       break;\r
+               case BTC_PS_LPS_OFF:\r
+                       halbtc8821a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);\r
+                       pCoexSta->bForceLpsOn = FALSE;\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+}\r
+\r
+\r
+VOID\r
+halbtc8821a2ant_CoexAllOff(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       // fw all off\r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       // sw all off\r
+       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+       // hw all off\r
+       //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_CoexUnder5G(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8821a2ant_CoexAllOff(pBtCoexist);\r
+\r
+       halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_InitCoexDm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{      \r
+       // force to reset coex mechanism\r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+       \r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1);\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);\r
+       halbtc8821a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);\r
+\r
+       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionBtInquiry(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       BOOLEAN bWifiConnected=FALSE;\r
+       BOOLEAN bLowPwrDisable=TRUE;\r
+       BOOLEAN         bScan=FALSE, bLink=FALSE, bRoam=FALSE;\r
+\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);\r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+       \r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);\r
+               \r
+       \r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+\r
+       if(bScan || bLink || bRoam)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi link process + BT Inq/Page!!\n"));\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);         \r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);\r
+       }\r
+       else if(bWifiConnected)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT Inq/Page!!\n"));\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);         \r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi no-link + BT Inq/Page!!\n"));\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+       }       \r
+       \r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);\r
+       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+       \r
+}\r
+\r
+\r
+VOID\r
+halbtc8821a2ant_ActionWiFiLinkProcess(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte  u1Tmpa, u1Tmpb;\r
+       \r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15);         \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);\r
+\r
+       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+\r
+\r
+       u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);\r
+       u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u1Tmpa, u1Tmpb));\r
+}\r
+\r
+BOOLEAN\r
+halbtc8821a2ant_ActionWifiIdleProcess(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{      \r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+       u1Byte          apNum=0;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       //wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES-20, 0);\r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);\r
+\r
+       // define the office environment\r
+       if(BTC_RSSI_HIGH(wifiRssiState1) && \r
+                       (pCoexSta->bHidExist == TRUE) && (pCoexSta->bA2dpExist == TRUE))\r
+       {\r
+\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi  idle process for BT HID+A2DP exist!!\n"));\r
+               \r
+               halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6);\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               // sw all off\r
+               halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+               halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+\r
+               return TRUE;\r
+       }\r
+\r
+        //\r
+       else if (pCoexSta->bPanExist== TRUE)\r
+       {\r
+\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi  idle process for BT PAN exist!!\n"));\r
+               \r
+               halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6);\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               // sw all off\r
+               halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+               halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+\r
+               return TRUE;\r
+       }\r
+       \r
+       else\r
+       {\r
+               halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18);\r
+               return FALSE;   \r
+       }\r
+       \r
+       \r
+}\r
+\r
+\r
+\r
+BOOLEAN\r
+halbtc8821a2ant_IsCommonAction(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte                  btRssiState=BTC_RSSI_STATE_HIGH;\r
+       BOOLEAN                 bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;\r
+       BOOLEAN                 bBtHsOn=FALSE, bLowPwrDisable=FALSE;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
+\r
+       if(!bWifiConnected)\r
+       {\r
+               bLowPwrDisable = FALSE;\r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+               halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+               \r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n"));\r
+\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+               \r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                       \r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+               halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+               \r
+               halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+               halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+               bCommon = TRUE;\r
+       }\r
+       else\r
+       {\r
+               if(BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)\r
+               {\r
+                       bLowPwrDisable = FALSE;\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+                       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+                       \r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));\r
+\r
+                       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+                       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+                       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                       \r
+                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);              \r
+                       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);\r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+                       bCommon = TRUE;\r
+               }\r
+               else if(BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)\r
+               {\r
+                       bLowPwrDisable = TRUE;\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+\r
+                       if(bBtHsOn)\r
+                               return FALSE;\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));\r
+                       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+                       \r
+                       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+                       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+                       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                       \r
+                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+                       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb);\r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+                       bCommon = TRUE;\r
+               }\r
+               else\r
+               {\r
+                       bLowPwrDisable = TRUE;\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);\r
+\r
+                       if(bWifiBusy)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));\r
+                               bCommon = FALSE;\r
+                               //bCommon = halbtc8821a2ant_ActionWifiIdleProcess(pBtCoexist);  \r
+                       }\r
+                       else\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));\r
+                               //bCommon = FALSE;      \r
+                               bCommon = halbtc8821a2ant_ActionWifiIdleProcess(pBtCoexist);                    \r
+                       }\r
+               }       \r
+       }\r
+\r
+       return bCommon;\r
+}\r
+VOID\r
+halbtc8821a2ant_TdmaDurationAdjust(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bScoHid,\r
+       IN      BOOLEAN                 bTxPause,\r
+       IN      u1Byte                  maxInterval\r
+       )\r
+{\r
+       static s4Byte           up,dn,m,n,WaitCount;\r
+       s4Byte                  result;   //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration\r
+       u1Byte                  retryCount=0;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));\r
+\r
+       if(!pCoexDm->bAutoTdmaAdjust)\r
+       {\r
+               pCoexDm->bAutoTdmaAdjust = TRUE;\r
+               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));\r
+               {\r
+                       if(bScoHid)\r
+                       {\r
+                               if(bTxPause)\r
+                               {\r
+                                       if(maxInterval == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);\r
+                                               pCoexDm->psTdmaDuAdjType = 13;  \r
+                                       }\r
+                                       else if(maxInterval == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                               pCoexDm->psTdmaDuAdjType = 14;  \r
+                                       }\r
+                                       else if(maxInterval == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;  \r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(maxInterval == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                                               pCoexDm->psTdmaDuAdjType = 9;   \r
+                                       }\r
+                                       else if(maxInterval == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                               pCoexDm->psTdmaDuAdjType = 10;  \r
+                                       }\r
+                                       else if(maxInterval == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               if(bTxPause)\r
+                               {\r
+                                       if(maxInterval == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);\r
+                                               pCoexDm->psTdmaDuAdjType = 5;   \r
+                                       }\r
+                                       else if(maxInterval == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                               pCoexDm->psTdmaDuAdjType = 6;   \r
+                                       }\r
+                                       else if(maxInterval == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       if(maxInterval == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);\r
+                                               pCoexDm->psTdmaDuAdjType = 1;   \r
+                                       }\r
+                                       else if(maxInterval == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                               pCoexDm->psTdmaDuAdjType = 2;   \r
+                                       }\r
+                                       else if(maxInterval == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               //============\r
+               up = 0;\r
+               dn = 0;\r
+               m = 1;\r
+               n= 3;\r
+               result = 0;\r
+               WaitCount = 0;\r
+       }\r
+       else\r
+       {\r
+               //accquire the BT TRx retry count from BT_Info byte2\r
+               retryCount = pCoexSta->btRetryCnt;\r
+               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));\r
+               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", \r
+                       up, dn, m, n, WaitCount));\r
+               result = 0;\r
+               WaitCount++; \r
+                 \r
+               if(retryCount == 0)  // no retry in the last 2-second duration\r
+               {\r
+                       up++;\r
+                       dn--;\r
+\r
+                       if (dn <= 0)\r
+                               dn = 0;                          \r
+\r
+                       if(up >= n)     // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration\r
+                       {\r
+                               WaitCount = 0; \r
+                               n = 3;\r
+                               up = 0;\r
+                               dn = 0;\r
+                               result = 1; \r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n"));\r
+                       }\r
+               }\r
+               else if (retryCount <= 3)       // <=3 retry in the last 2-second duration\r
+               {\r
+                       up--; \r
+                       dn++;\r
+\r
+                       if (up <= 0)\r
+                               up = 0;\r
+\r
+                       if (dn == 2)    // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration\r
+                       {\r
+                               if (WaitCount <= 2)\r
+                                       m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^\r
+                               else\r
+                                       m = 1;\r
+\r
+                               if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.\r
+                                       m = 20;\r
+\r
+                               n = 3*m;\r
+                               up = 0;\r
+                               dn = 0;\r
+                               WaitCount = 0;\r
+                               result = -1; \r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));\r
+                       }\r
+               }\r
+               else  //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration\r
+               {\r
+                       if (WaitCount == 1)\r
+                               m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^\r
+                       else\r
+                               m = 1;\r
+\r
+                       if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.\r
+                               m = 20;\r
+\r
+                       n = 3*m;\r
+                       up = 0;\r
+                       dn = 0;\r
+                       WaitCount = 0; \r
+                       result = -1;\r
+                       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));\r
+               }\r
+\r
+               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval));\r
+               if(maxInterval == 1)\r
+               {\r
+                       if(bTxPause)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));\r
+\r
+                               if(pCoexDm->curPsTdma == 71)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);\r
+                                       pCoexDm->psTdmaDuAdjType = 5;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 1)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);\r
+                                       pCoexDm->psTdmaDuAdjType = 5;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 2)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                       pCoexDm->psTdmaDuAdjType = 6;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 3)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                       pCoexDm->psTdmaDuAdjType = 7;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 4)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);\r
+                                       pCoexDm->psTdmaDuAdjType = 8;\r
+                               }\r
+                               if(pCoexDm->curPsTdma == 9)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);\r
+                                       pCoexDm->psTdmaDuAdjType = 13;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 10)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                       pCoexDm->psTdmaDuAdjType = 14;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 11)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                       pCoexDm->psTdmaDuAdjType = 15;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 12)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);\r
+                                       pCoexDm->psTdmaDuAdjType = 16;\r
+                               }\r
+                               \r
+                               if(result == -1)\r
+                               {                                       \r
+                                       if(pCoexDm->curPsTdma == 5)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                               pCoexDm->psTdmaDuAdjType = 6;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 6)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 7)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);\r
+                                               pCoexDm->psTdmaDuAdjType = 8;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 13)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                               pCoexDm->psTdmaDuAdjType = 14;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 14)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 15)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);\r
+                                               pCoexDm->psTdmaDuAdjType = 16;\r
+                                       }\r
+                               } \r
+                               else if (result == 1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 8)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 7)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                               pCoexDm->psTdmaDuAdjType = 6;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 6)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);\r
+                                               pCoexDm->psTdmaDuAdjType = 5;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 16)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 15)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                               pCoexDm->psTdmaDuAdjType = 14;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 14)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);\r
+                                               pCoexDm->psTdmaDuAdjType = 13;\r
+                                       }\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));\r
+                               if(pCoexDm->curPsTdma == 5)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71);\r
+                                       pCoexDm->psTdmaDuAdjType = 71;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 6)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                       pCoexDm->psTdmaDuAdjType = 2;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 7)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                       pCoexDm->psTdmaDuAdjType = 3;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 8)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);\r
+                                       pCoexDm->psTdmaDuAdjType = 4;\r
+                               }\r
+                               if(pCoexDm->curPsTdma == 13)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                                       pCoexDm->psTdmaDuAdjType = 9;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 14)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                       pCoexDm->psTdmaDuAdjType = 10;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 15)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                       pCoexDm->psTdmaDuAdjType = 11;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 16)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);\r
+                                       pCoexDm->psTdmaDuAdjType = 12;\r
+                               }\r
+                               \r
+                               if(result == -1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 71)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);\r
+                                               pCoexDm->psTdmaDuAdjType = 1;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                               pCoexDm->psTdmaDuAdjType = 2;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);\r
+                                               pCoexDm->psTdmaDuAdjType = 4;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 9)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                               pCoexDm->psTdmaDuAdjType = 10;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 10)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 11)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);\r
+                                               pCoexDm->psTdmaDuAdjType = 12;\r
+                                       }\r
+                               } \r
+                               else if (result == 1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 4)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                               pCoexDm->psTdmaDuAdjType = 2;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);\r
+                                               pCoexDm->psTdmaDuAdjType = 1;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71);\r
+                                               pCoexDm->psTdmaDuAdjType = 71;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 12)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 11)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                               pCoexDm->psTdmaDuAdjType = 10;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 10)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                                               pCoexDm->psTdmaDuAdjType = 9;\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               else if(maxInterval == 2)\r
+               {\r
+                       if(bTxPause)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));\r
+                               if(pCoexDm->curPsTdma == 1)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                       pCoexDm->psTdmaDuAdjType = 6;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 2)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                       pCoexDm->psTdmaDuAdjType = 6;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 3)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                       pCoexDm->psTdmaDuAdjType = 7;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 4)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);\r
+                                       pCoexDm->psTdmaDuAdjType = 8;\r
+                               }\r
+                               if(pCoexDm->curPsTdma == 9)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                       pCoexDm->psTdmaDuAdjType = 14;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 10)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                       pCoexDm->psTdmaDuAdjType = 14;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 11)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                       pCoexDm->psTdmaDuAdjType = 15;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 12)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);\r
+                                       pCoexDm->psTdmaDuAdjType = 16;\r
+                               }\r
+                               if(result == -1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 5) \r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                               pCoexDm->psTdmaDuAdjType = 6;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 6)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 7)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);\r
+                                               pCoexDm->psTdmaDuAdjType = 8;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 13)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                               pCoexDm->psTdmaDuAdjType = 14;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 14)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 15)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);\r
+                                               pCoexDm->psTdmaDuAdjType = 16;\r
+                                       }\r
+                               } \r
+                               else if (result == 1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 8)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 7)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                               pCoexDm->psTdmaDuAdjType = 6;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 6)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+                                               pCoexDm->psTdmaDuAdjType = 6;\r
+                                       }                                       \r
+                                       else if(pCoexDm->curPsTdma == 16)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 15)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                               pCoexDm->psTdmaDuAdjType = 14;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 14)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+                                               pCoexDm->psTdmaDuAdjType = 14;\r
+                                       }\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));\r
+                               if(pCoexDm->curPsTdma == 5)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                       pCoexDm->psTdmaDuAdjType = 2;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 6)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                       pCoexDm->psTdmaDuAdjType = 2;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 7)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                       pCoexDm->psTdmaDuAdjType = 3;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 8)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);\r
+                                       pCoexDm->psTdmaDuAdjType = 4;\r
+                               }\r
+                               if(pCoexDm->curPsTdma == 13)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                       pCoexDm->psTdmaDuAdjType = 10;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 14)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                       pCoexDm->psTdmaDuAdjType = 10;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 15)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                       pCoexDm->psTdmaDuAdjType = 11;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 16)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);\r
+                                       pCoexDm->psTdmaDuAdjType = 12;\r
+                               }\r
+                               if(result == -1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                               pCoexDm->psTdmaDuAdjType = 2;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);\r
+                                               pCoexDm->psTdmaDuAdjType = 4;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 9)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                               pCoexDm->psTdmaDuAdjType = 10;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 10)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 11)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);\r
+                                               pCoexDm->psTdmaDuAdjType = 12;\r
+                                       }\r
+                               } \r
+                               else if (result == 1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 4)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                               pCoexDm->psTdmaDuAdjType = 2;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                                               pCoexDm->psTdmaDuAdjType = 2;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 12)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 11)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                               pCoexDm->psTdmaDuAdjType = 10;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 10)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10);\r
+                                               pCoexDm->psTdmaDuAdjType = 10;\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               else if(maxInterval == 3)\r
+               {\r
+                       if(bTxPause)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n"));\r
+                               if(pCoexDm->curPsTdma == 1)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                       pCoexDm->psTdmaDuAdjType = 7;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 2)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                       pCoexDm->psTdmaDuAdjType = 7;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 3)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                       pCoexDm->psTdmaDuAdjType = 7;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 4)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);\r
+                                       pCoexDm->psTdmaDuAdjType = 8;\r
+                               }\r
+                               if(pCoexDm->curPsTdma == 9)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                       pCoexDm->psTdmaDuAdjType = 15;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 10)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                       pCoexDm->psTdmaDuAdjType = 15;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 11)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                       pCoexDm->psTdmaDuAdjType = 15;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 12)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);\r
+                                       pCoexDm->psTdmaDuAdjType = 16;\r
+                               }\r
+                               if(result == -1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 5) \r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 6)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 7)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8);\r
+                                               pCoexDm->psTdmaDuAdjType = 8;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 13)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 14)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 15)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16);\r
+                                               pCoexDm->psTdmaDuAdjType = 16;\r
+                                       }\r
+                               } \r
+                               else if (result == 1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 8)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 7)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 6)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7);\r
+                                               pCoexDm->psTdmaDuAdjType = 7;\r
+                                       }                                       \r
+                                       else if(pCoexDm->curPsTdma == 16)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 15)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 14)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15);\r
+                                               pCoexDm->psTdmaDuAdjType = 15;\r
+                                       }\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n"));\r
+                               if(pCoexDm->curPsTdma == 5)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                       pCoexDm->psTdmaDuAdjType = 3;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 6)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                       pCoexDm->psTdmaDuAdjType = 3;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 7)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                       pCoexDm->psTdmaDuAdjType = 3;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 8)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);\r
+                                       pCoexDm->psTdmaDuAdjType = 4;\r
+                               }\r
+                               if(pCoexDm->curPsTdma == 13)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                       pCoexDm->psTdmaDuAdjType = 11;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 14)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                       pCoexDm->psTdmaDuAdjType = 11;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 15)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                       pCoexDm->psTdmaDuAdjType = 11;\r
+                               }\r
+                               else if(pCoexDm->curPsTdma == 16)\r
+                               {\r
+                                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);\r
+                                       pCoexDm->psTdmaDuAdjType = 12;\r
+                               }\r
+                               if(result == -1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 1)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4);\r
+                                               pCoexDm->psTdmaDuAdjType = 4;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 9)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 10)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 11)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12);\r
+                                               pCoexDm->psTdmaDuAdjType = 12;\r
+                                       }\r
+                               } \r
+                               else if (result == 1)\r
+                               {\r
+                                       if(pCoexDm->curPsTdma == 4)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 3)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 2)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+                                               pCoexDm->psTdmaDuAdjType = 3;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 12)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 11)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                                       else if(pCoexDm->curPsTdma == 10)\r
+                                       {\r
+                                               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                                               pCoexDm->psTdmaDuAdjType = 11;\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       // if current PsTdma not match with the recorded one (when scan, dhcp...), \r
+       // then we have to adjust it back to the previous record one.\r
+       if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)\r
+       {\r
+               BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", \r
+                       pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));\r
+\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);\r
+               \r
+               if( !bScan && !bLink && !bRoam)\r
+               {\r
+                       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);\r
+               }\r
+               else\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));\r
+               }\r
+       }\r
+}\r
+\r
+// SCO only or SCO+PAN(HS)\r
+VOID\r
+halbtc8821a2ant_ActionSco(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       u1Byte  wifiRssiState, btRssiState;\r
+       u4Byte  wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+       \r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+       \r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+\r
+       if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+       }\r
+       else  //for SCO quality & wifi performance balance at 11n mode\r
+       {\r
+               if(BTC_WIFI_BW_HT40 == wifiBw)\r
+                       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8);\r
+               else\r
+               {\r
+                       if(pBtLinkInfo->bScoOnly)\r
+                               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 17);\r
+                       else\r
+                               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);\r
+               }\r
+       }\r
+\r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                       \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality\r
+\r
+       // sw mechanism\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18);                  \r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18); \r
+               }               \r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18);\r
+               }               \r
+       }\r
+}\r
+\r
+\r
+VOID\r
+halbtc8821a2ant_ActionHid(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte  wifiRssiState, btRssiState;     \r
+       u4Byte  wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+       \r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+\r
+       if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+       }\r
+       else  //for HID quality & wifi performance balance at 11n mode\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+       }\r
+\r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                       \r
+\r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24);\r
+\r
+       // sw mechanism\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }       \r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }               \r
+       }\r
+}\r
+\r
+//A2DP only / PAN(EDR) only/ A2DP+PAN(HS)\r
+VOID\r
+halbtc8821a2ant_ActionA2dp(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+       u1Byte          apNum=0;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);\r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);\r
+\r
+       // define the office environment\r
+       if( (apNum >= 10) && BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))\r
+       {\r
+               //DbgPrint(" AP#>10(%d)\n", apNum);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                       \r
+               \r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+               halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+               halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);      \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);                   \r
+                                       \r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+               //halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);\r
+\r
+               // sw mechanism\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+               if(BTC_WIFI_BW_HT40 == wifiBw)\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6);           \r
+               }\r
+               return;\r
+               \r
+       }\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);      \r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+               \r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);           \r
+       }\r
+       \r
+\r
+       if( (btRssiState == BTC_RSSI_STATE_HIGH) ||\r
+               (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+       {\r
+               //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);\r
+       }\r
+       else\r
+       {\r
+               //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1);\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);\r
+       }\r
+\r
+       // sw mechanism\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }               \r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionA2dpPanHs(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+       \r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);           \r
+       }\r
+\r
+       halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2);\r
+\r
+       // sw mechanism\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }               \r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionPanEdr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState,wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);           \r
+       }\r
+       \r
+       if( (btRssiState == BTC_RSSI_STATE_HIGH) ||\r
+               (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+       {\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 26);      \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 26);      \r
+       }\r
+       \r
+       // sw mechanism\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+}\r
+\r
+\r
+//PAN(HS) only\r
+VOID\r
+halbtc8821a2ant_ActionPanHs(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+       \r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+       \r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+}\r
+\r
+//PAN(EDR)+A2DP\r
+VOID\r
+halbtc8821a2ant_ActionPanEdrA2dp(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))                \r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       else\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+\r
+       if( (btRssiState == BTC_RSSI_STATE_HIGH) ||\r
+               (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12);\r
+               \r
+               if(BTC_WIFI_BW_HT40 == wifiBw)\r
+                       halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);\r
+               else\r
+                       halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);\r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13);\r
+               halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3);\r
+       }\r
+       \r
+       // sw mechanism \r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionPanEdrHid(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))        \r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);\r
+       }\r
+\r
+       if( (btRssiState == BTC_RSSI_STATE_HIGH) ||\r
+               (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+       {\r
+               if(BTC_WIFI_BW_HT40 == wifiBw)\r
+               {\r
+                       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3);\r
+                       //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11);\r
+                       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+                       //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+                       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+               }\r
+               halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2);\r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+               //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);\r
+               pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+               halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2);\r
+       }\r
+       \r
+       // sw mechanism\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+}\r
+\r
+// HID+A2DP+PAN(EDR)\r
+VOID\r
+halbtc8821a2ant_ActionHidA2dpPanEdr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState,wifiRssiState1,  btRssiState;\r
+       u4Byte          wifiBw;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+\r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8);\r
+\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       if(BTC_RSSI_HIGH(btRssiState))\r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+       else    \r
+               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);           \r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+\r
+       if( (btRssiState == BTC_RSSI_STATE_HIGH) ||\r
+               (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+       {\r
+               if(BTC_WIFI_BW_HT40 == wifiBw)\r
+                       halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);\r
+               else\r
+                       halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);\r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);\r
+       }\r
+\r
+       // sw mechanism\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionHidA2dp(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte          wifiRssiState, wifiRssiState1, btRssiState;\r
+       u4Byte          wifiBw;\r
+       u1Byte          apNum=0;\r
+\r
+       wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0);\r
+       //btRssiState = halbtc8821a2ant_BtRssiState(2, 29, 0);\r
+       wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);  \r
+       btRssiState = halbtc8821a2ant_BtRssiState(3, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 37);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+       \r
+       halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5);\r
+\r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+       if(BTC_WIFI_BW_LEGACY == wifiBw)\r
+       {\r
+               if(BTC_RSSI_HIGH(btRssiState))\r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+               else if(BTC_RSSI_MEDIUM(btRssiState))\r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+               else    \r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+       }\r
+       else\r
+       {       // only 802.11N mode we have to dec bt power to 4 degree\r
+               if(BTC_RSSI_HIGH(btRssiState))\r
+               {\r
+                       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);\r
+                       // need to check ap Number of Not\r
+                       if(apNum < 10)\r
+                               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4);\r
+                       else\r
+                               halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+               }\r
+               else if(BTC_RSSI_MEDIUM(btRssiState))\r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);\r
+               else    \r
+                       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+       }\r
+\r
+       if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState))\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       }\r
+       else\r
+       {\r
+               halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14);\r
+               halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);           \r
+       }\r
+\r
+       if( (btRssiState == BTC_RSSI_STATE_HIGH) ||\r
+               (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+       {\r
+               //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3);\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);\r
+       }\r
+       else\r
+       {\r
+               //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3);\r
+               halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23);\r
+       }\r
+       \r
+       // sw mechanism\r
+       if(BTC_WIFI_BW_HT40 == wifiBw)\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||\r
+                       (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE);\r
+                       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionBtWhckTest(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       // sw all off\r
+       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+       \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_ActionWifiMultiPort(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{              \r
+       halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6);\r
+       halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       // sw all off\r
+       halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);\r
+       halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);\r
+\r
+       // hw all off\r
+       //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);\r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+\r
+       halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);               \r
+       halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1);\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_RunCoexistMechanism(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       BOOLEAN                         bWifiUnder5G=FALSE, bBtHsOn=FALSE;\r
+       u1Byte                          btInfoOriginal=0, btRetryCnt=0;\r
+       u1Byte                          algorithm=0;\r
+       u4Byte                          numOfWifiLink=0;\r
+       u4Byte                          wifiLinkStatus=0;\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                         bMiracastPlusBt=FALSE;\r
+       BOOLEAN                         bScan=FALSE, bLink=FALSE, bRoam=FALSE;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n"));\r
+\r
+       if(pBtCoexist->bManualControl)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));\r
+               return;\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);\r
+       if(bWifiUnder5G)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n"));\r
+               halbtc8821a2ant_CoexUnder5G(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       if(pCoexSta->bUnderIps)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n"));\r
+               return;\r
+       }\r
+\r
+       if(pCoexSta->bBtWhckTest)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n"));\r
+               halbtc8821a2ant_ActionBtWhckTest(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       algorithm = halbtc8821a2ant_ActionAlgorithm(pBtCoexist);\r
+       if(pCoexSta->bC2hBtInquiryPage && (BT_8821A_2ANT_COEX_ALGO_PANHS!=algorithm))\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n"));\r
+               halbtc8821a2ant_ActionBtInquiry(pBtCoexist);\r
+               return;\r
+       }\r
+       else\r
+       {\r
+\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);\r
+\r
+       if(bScan || bLink || bRoam)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], WiFi is under Link Process !!\n"));\r
+               halbtc8821a2ant_ActionWiFiLinkProcess(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       //for P2P\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);\r
+       numOfWifiLink = wifiLinkStatus>>16;\r
+       \r
+       if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED))\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex],  Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) );\r
+\r
+               if(pBtLinkInfo->bBtLinkExist)\r
+               {\r
+                       bMiracastPlusBt = TRUE;\r
+               }\r
+               else\r
+               {\r
+                       bMiracastPlusBt = FALSE;\r
+               }\r
+               \r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);\r
+               halbtc8821a2ant_ActionWifiMultiPort(pBtCoexist);\r
+               \r
+               return;\r
+       }\r
+       else\r
+       {\r
+               bMiracastPlusBt = FALSE;\r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);\r
+       }\r
+\r
+       pCoexDm->curAlgorithm = algorithm;\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));\r
+\r
+       if(halbtc8821a2ant_IsCommonAction(pBtCoexist))\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n"));\r
+               pCoexDm->bAutoTdmaAdjust = FALSE;\r
+       }\r
+       else\r
+       {\r
+               if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", \r
+                               pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));\r
+                       pCoexDm->bAutoTdmaAdjust = FALSE;\r
+               }\r
+               switch(pCoexDm->curAlgorithm)\r
+               {\r
+                       case BT_8821A_2ANT_COEX_ALGO_SCO:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));\r
+                               halbtc8821a2ant_ActionSco(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_HID:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));\r
+                               halbtc8821a2ant_ActionHid(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_A2DP:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));\r
+                               halbtc8821a2ant_ActionA2dp(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"));\r
+                               halbtc8821a2ant_ActionA2dpPanHs(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_PANEDR:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));\r
+                               halbtc8821a2ant_ActionPanEdr(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_PANHS:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));\r
+                               halbtc8821a2ant_ActionPanHs(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));\r
+                               halbtc8821a2ant_ActionPanEdrA2dp(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));\r
+                               halbtc8821a2ant_ActionPanEdrHid(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));\r
+                               halbtc8821a2ant_ActionHidA2dpPanEdr(pBtCoexist);\r
+                               break;\r
+                       case BT_8821A_2ANT_COEX_ALGO_HID_A2DP:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));\r
+                               halbtc8821a2ant_ActionHidA2dp(pBtCoexist);\r
+                               break;\r
+                       default:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));\r
+                               halbtc8821a2ant_CoexAllOff(pBtCoexist);\r
+                               break;\r
+               }\r
+               pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_WifiOffHwCfg(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       BOOLEAN bIsInMpMode = FALSE;\r
+       u1Byte H2C_Parameter[2] ={0};\r
+       u4Byte fwVer=0;\r
+\r
+       // set wlan_act to low\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);\r
+\r
+       pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);\r
+       if(fwVer >= 0x180000)\r
+       {\r
+               /* Use H2C to set GNT_BT to HIGH */\r
+               H2C_Parameter[0] = 1;\r
+               pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter);\r
+       }\r
+       else\r
+       {\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8821a2ant_InitHwConfig(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bBackUp\r
+       )\r
+{\r
+       PBTC_BOARD_INFO         pBoardInfo=&pBtCoexist->boardInfo;\r
+       u4Byte  u4Tmp=0, fwVer;\r
+       u2Byte                          u2Tmp=0;\r
+       u1Byte  u1Tmp=0;\r
+       u1Byte                          H2C_Parameter[2] ={0};\r
+               \r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n"));\r
+\r
+       // backup rf 0x1e value\r
+       pCoexDm->btRf0x1eBackup = \r
+               pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);  \r
+\r
+       // 0x790[5:0]=0x5\r
+       u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790);\r
+       u1Tmp &= 0xc0;\r
+       u1Tmp |= 0x5;\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp);\r
+\r
+       //Antenna config        \r
+       halbtc8821a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE);\r
+       pCoexSta->disVerInfoCnt = 0;\r
+\r
+       // PTA parameter\r
+       halbtc8821a2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);\r
+       \r
+       // Enable counter statistics\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); //0x76e[3] =1, WLAN_Act control by PTA\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3);\r
+       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1);\r
+}\r
+\r
+//============================================================\r
+// work around function start with wa_halbtc8821a2ant_\r
+//============================================================\r
+//============================================================\r
+// extern function start with EXhalbtc8821a2ant_\r
+//============================================================\r
+VOID\r
+EXhalbtc8821a2ant_PowerOnSetting(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_PreLoadFirmware(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BOARD_INFO         pBoardInfo=&pBtCoexist->boardInfo;\r
+       u1Byte u1Tmp=0x4; /* Set BIT2 by default since it's 2ant case */\r
+\r
+       // \r
+       // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info)\r
+       // Local setting bit define\r
+       //      BIT0: "0" for no antenna inverse; "1" for antenna inverse \r
+       //      BIT1: "0" for internal switch; "1" for external switch\r
+       //      BIT2: "0" for one antenna; "1" for two antenna\r
+       // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0\r
+       if(pBtCoexist->chipInterface == BTC_INTF_USB)\r
+       {\r
+               // fixed at S0 for USB interface\r
+               u1Tmp |= 0x1;   // antenna inverse\r
+               pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp);\r
+       }\r
+       else\r
+       {\r
+               // for PCIE and SDIO interface, we check efuse 0xc3[6]\r
+               if(pBoardInfo->singleAntPath == 0)\r
+               {\r
+               }\r
+               else if(pBoardInfo->singleAntPath == 1)\r
+               {\r
+                       // set to S0\r
+                       u1Tmp |= 0x1;   // antenna inverse\r
+               }\r
+\r
+               if(pBtCoexist->chipInterface == BTC_INTF_PCI)\r
+               {       \r
+                       pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp);\r
+               }\r
+               else if(pBtCoexist->chipInterface == BTC_INTF_SDIO)\r
+               {\r
+                       pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp);\r
+               }                       \r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_InitHwConfig(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bWifiOnly\r
+       )\r
+{\r
+       halbtc8821a2ant_InitHwConfig(pBtCoexist, TRUE);\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_InitCoexDm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));\r
+       \r
+       halbtc8821a2ant_InitCoexDm(pBtCoexist);\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_DisplayCoexInfo(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BOARD_INFO         pBoardInfo=&pBtCoexist->boardInfo;\r
+       PBTC_STACK_INFO         pStackInfo=&pBtCoexist->stackInfo;\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       pu1Byte                         cliBuf=pBtCoexist->cliBuf;\r
+       u1Byte                          u1Tmp[4], i, btInfoExt, psTdmaCase=0;\r
+       u4Byte                          u4Tmp[4];\r
+       u4Byte                          faOfdm, faCck;\r
+       u4Byte                          fwVer=0, btPatchVer=0;\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");\r
+       CL_PRINTF(cliBuf);\r
+\r
+       if(pBtCoexist->bManualControl)\r
+       {\r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");\r
+               CL_PRINTF(cliBuf);\r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");\r
+               CL_PRINTF(cliBuf);\r
+       }\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \\r
+               pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum);\r
+       CL_PRINTF(cliBuf);\r
+       \r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \\r
+               ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \\r
+               GLCoexVerDate8821a2Ant, GLCoexVer8821a2Ant, fwVer, btPatchVer, btPatchVer);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \\r
+               pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],\r
+               pCoexDm->wifiChnlInfo[2]);\r
+       CL_PRINTF(cliBuf);\r
+       \r
+       // wifi status\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============");\r
+       CL_PRINTF(cliBuf);\r
+       pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============");\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %ddBm/ %d] ", "BT [status/ rssi/ retryCnt]", \\r
+               ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"):        ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":\r
+               (  (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),\r
+               pCoexSta->btRssi-100, pCoexSta->btRetryCnt);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \\r
+               pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       if (pStackInfo->bProfileNotified)\r
+       {\r
+               pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);      \r
+       }\r
+       else\r
+       {\r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \\r
+               (pBtLinkInfo->bSlaveRole )? "Slave":"Master");\r
+               CL_PRINTF(cliBuf);      \r
+       }       \r
+\r
+       btInfoExt = pCoexSta->btInfoExt;\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \\r
+               (btInfoExt&BIT0)? "Basic rate":"EDR rate");\r
+       CL_PRINTF(cliBuf);      \r
+\r
+       for(i=0; i<BT_INFO_SRC_8821A_2ANT_MAX; i++)\r
+       {\r
+               if(pCoexSta->btInfoC2hCnt[i])\r
+               {                               \r
+                       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8821a2Ant[i], \\r
+                               pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],\r
+                               pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],\r
+                               pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],\r
+                               pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);\r
+                       CL_PRINTF(cliBuf);\r
+               }\r
+       }\r
+\r
+       // Sw mechanism \r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");\r
+       CL_PRINTF(cliBuf);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \\r
+               pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig);\r
+       CL_PRINTF(cliBuf);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \\r
+               pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       // Fw mechanism         \r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");\r
+       CL_PRINTF(cliBuf);      \r
+\r
+       psTdmaCase = pCoexDm->curPsTdma;\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \\r
+               pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],\r
+               pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],\r
+               pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \\r
+                       pCoexSta->nCoexTableType);\r
+               CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \\r
+               pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       // Hw setting           \r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");\r
+       CL_PRINTF(cliBuf);      \r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \\r
+               pCoexDm->btRf0x1eBackup);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);\r
+       u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xc5b);\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x880[29:25]/0xc58[29:25]", \\r
+               u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25, ((u1Tmp[1]&0x3e)>>1));\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u4Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x764);\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x764/ 0x765/ 0x76e", \\r
+               (u4Tmp[0]&0xff), (u4Tmp[0]&0xff00)>>8, u1Tmp[0]);\r
+       CL_PRINTF(cliBuf);\r
+       \r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcb4);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)", \\r
+               u4Tmp[0]&0xff, ((u4Tmp[0]&0x30000000)>>28));\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c);\r
+       u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x974);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/ 0x4c[24:23]/ 0x974", \\r
+               u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u4Tmp[1]);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550);\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \\r
+               u4Tmp[0], u1Tmp[0]);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50);\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \\r
+               u4Tmp[0]&0xff, u1Tmp[0]);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0);\r
+       u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4);\r
+       u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8);\r
+       u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0);\r
+\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b);\r
+       u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c);\r
+\r
+       faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) +  ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) +  (u4Tmp[2] & 0xffff) + \\r
+                            ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ;\r
+       faCck = (u1Tmp[0] << 8) + u1Tmp[1];\r
+       \r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \\r
+               u4Tmp[0]&0xffff, faOfdm, faCck);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \\r
+               pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \\r
+               pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg);\r
+       CL_PRINTF(cliBuf);      \r
+\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0);\r
+       u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4);\r
+       u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8);\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \\r
+               u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \\r
+               pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);\r
+       CL_PRINTF(cliBuf);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \\r
+               pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);\r
+       CL_PRINTF(cliBuf);\r
+#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 1)\r
+       //halbtc8821a2ant_MonitorBtCtr(pBtCoexist);\r
+#endif\r
+       pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);\r
+}\r
+\r
+\r
+VOID\r
+EXhalbtc8821a2ant_IpsNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       if(BTC_IPS_ENTER == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n"));\r
+               pCoexSta->bUnderIps = TRUE;\r
+               halbtc8821a2ant_WifiOffHwCfg(pBtCoexist);\r
+               halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);\r
+               halbtc8821a2ant_CoexAllOff(pBtCoexist);\r
+       }\r
+       else if(BTC_IPS_LEAVE == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));\r
+               pCoexSta->bUnderIps = FALSE;\r
+               halbtc8821a2ant_InitHwConfig(pBtCoexist, FALSE);\r
+               halbtc8821a2ant_InitCoexDm(pBtCoexist);\r
+               halbtc8821a2ant_QueryBtInfo(pBtCoexist);\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_LpsNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       if(BTC_LPS_ENABLE == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n"));\r
+               pCoexSta->bUnderLps = TRUE;\r
+       }\r
+       else if(BTC_LPS_DISABLE == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n"));\r
+               pCoexSta->bUnderLps = FALSE;\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_ScanNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       u1Byte  u1Tmpa, u1Tmpb; \r
+       \r
+       u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765);\r
+       u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e);\r
+        \r
+       if(BTC_SCAN_START == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));\r
+       }\r
+       else if(BTC_SCAN_FINISH == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));\r
+       }\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u1Tmpa, u1Tmpb));\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_ConnectNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       if(BTC_ASSOCIATE_START == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));\r
+       }\r
+       else if(BTC_ASSOCIATE_FINISH == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_MediaStatusNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       u1Byte                  H2C_Parameter[3] ={0};\r
+       u4Byte                  wifiBw;\r
+       u1Byte                  wifiCentralChnl;\r
+       u1Byte                  apNum=0;\r
+\r
+       if(BTC_MEDIA_CONNECT == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));\r
+       }\r
+\r
+       // only 2.4G we need to inform bt the chnl mask\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);\r
+       if( (BTC_MEDIA_CONNECT == type) &&\r
+               (wifiCentralChnl <= 14) )\r
+       {\r
+               H2C_Parameter[0] = 0x1;\r
+               H2C_Parameter[1] = wifiCentralChnl;\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+               if(BTC_WIFI_BW_HT40 == wifiBw)\r
+                       H2C_Parameter[2] = 0x30;\r
+               else\r
+               {\r
+                       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum);\r
+                       if(apNum < 10)\r
+                               H2C_Parameter[2] = 0x30;\r
+                       else\r
+                               H2C_Parameter[2] = 0x20;\r
+               }\r
+       }\r
+       \r
+       pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];\r
+       pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];\r
+       pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", \r
+               H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));\r
+\r
+       pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter);    \r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_SpecialPacketNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       if(type == BTC_PACKET_DHCP)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n"));\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_BtInfoNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      pu1Byte                 tmpBuf,\r
+       IN      u1Byte                  length\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       u1Byte                  btInfo=0;\r
+       u1Byte                  i, rspSource=0;\r
+       BOOLEAN                 bBtBusy=FALSE, bLimitedDig=FALSE;\r
+       BOOLEAN                 bWifiConnected=FALSE, bWifiUnder5G=FALSE;\r
+       static BOOLEAN          bPreScoExist=FALSE;\r
+       u4Byte                          raMask=0x0;\r
+\r
+       pCoexSta->bC2hBtInfoReqSent = FALSE;\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+\r
+       rspSource = tmpBuf[0]&0xf;\r
+       if(rspSource >= BT_INFO_SRC_8821A_2ANT_MAX)\r
+               rspSource = BT_INFO_SRC_8821A_2ANT_WIFI_FW;\r
+       pCoexSta->btInfoC2hCnt[rspSource]++;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));\r
+       for(i=0; i<length; i++)\r
+       {\r
+               pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];\r
+               if(i == 1)\r
+                       btInfo = tmpBuf[i];\r
+               if(i == length-1)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i]));\r
+               }\r
+               else\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i]));\r
+               }\r
+       }\r
+\r
+       if(pBtCoexist->bManualControl)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));\r
+               return;\r
+       }\r
+\r
+       // if 0xff, it means BT is under WHCK test\r
+       if (btInfo == 0xff)\r
+               pCoexSta->bBtWhckTest = TRUE;\r
+       else\r
+               pCoexSta->bBtWhckTest = FALSE;\r
+\r
+       if(BT_INFO_SRC_8821A_2ANT_WIFI_FW != rspSource)\r
+       {\r
+               pCoexSta->btRetryCnt =  // [3:0]\r
+                       pCoexSta->btInfoC2h[rspSource][2]&0xf;\r
+\r
+               pCoexSta->btRssi =\r
+                       pCoexSta->btInfoC2h[rspSource][3]*2+10;\r
+\r
+               pCoexSta->btInfoExt = \r
+                       pCoexSta->btInfoC2h[rspSource][4];\r
+\r
+               pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40);\r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask);\r
+               if(pCoexSta->bBtTxRxMask)\r
+               {\r
+                       /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */                            \r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n"));\r
+                       pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01);\r
+               }\r
+\r
+               // Here we need to resend some wifi info to BT\r
+               // because bt is reset and loss of the info.\r
+               if( (pCoexSta->btInfoExt & BIT1) )\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));\r
+                       if(bWifiConnected)\r
+                       {\r
+                               EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);\r
+                       }\r
+                       else\r
+                       {\r
+                               EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);\r
+                       }\r
+               }\r
+\r
+               \r
+               if(!pBtCoexist->bManualControl && !bWifiUnder5G)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info = 0x%x!!\n", pCoexSta->btInfoExt));\r
+                       if( (pCoexSta->btInfoExt&BIT3) )\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3=1, bWifiConnected=%d\n", bWifiConnected));\r
+                               if(bWifiConnected)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));\r
+                                       halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3=0, bWifiConnected=%d\n", bWifiConnected));\r
+                               // BT already NOT ignore Wlan active, do nothing here.\r
+                               if(!bWifiConnected)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT to ignore Wlan active!!\n"));\r
+                                       halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);\r
+                               }\r
+                       }\r
+               }\r
+\r
+#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 0)\r
+               if( (pCoexSta->btInfoExt & BIT4) )\r
+               {\r
+                       // BT auto report already enabled, do nothing\r
+               }\r
+               else\r
+               {\r
+                       halbtc8821a2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE);\r
+               }\r
+#endif\r
+       }\r
+\r
+       // check BIT2 first ==> check if bt is under inquiry or page scan\r
+       if(btInfo & BT_INFO_8821A_2ANT_B_INQ_PAGE)\r
+               pCoexSta->bC2hBtInquiryPage = TRUE;\r
+       else\r
+               pCoexSta->bC2hBtInquiryPage = FALSE;\r
+\r
+       // set link exist status\r
+       if(!(btInfo&BT_INFO_8821A_2ANT_B_CONNECTION))\r
+       {\r
+               pCoexSta->bBtLinkExist = FALSE;\r
+               pCoexSta->bPanExist = FALSE;\r
+               pCoexSta->bA2dpExist = FALSE;\r
+               pCoexSta->bHidExist = FALSE;\r
+               pCoexSta->bScoExist = FALSE;\r
+       }\r
+       else    // connection exists\r
+       {\r
+               pCoexSta->bBtLinkExist = TRUE;\r
+               if(btInfo & BT_INFO_8821A_2ANT_B_FTP)\r
+                       pCoexSta->bPanExist = TRUE;\r
+               else\r
+                       pCoexSta->bPanExist = FALSE;\r
+               if(btInfo & BT_INFO_8821A_2ANT_B_A2DP)\r
+                       pCoexSta->bA2dpExist = TRUE;\r
+               else\r
+                       pCoexSta->bA2dpExist = FALSE;\r
+               if(btInfo & BT_INFO_8821A_2ANT_B_HID)\r
+                       pCoexSta->bHidExist = TRUE;\r
+               else\r
+                       pCoexSta->bHidExist = FALSE;\r
+               if(btInfo & BT_INFO_8821A_2ANT_B_SCO_ESCO)\r
+                       pCoexSta->bScoExist = TRUE;\r
+               else\r
+                       pCoexSta->bScoExist = FALSE;\r
+       \r
+               if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) && (pCoexSta->bScoExist == FALSE))\r
+               {\r
+                       if (pCoexSta->highPriorityTx  + pCoexSta->highPriorityRx >= 160) \r
+                               pCoexSta->bHidExist = TRUE;\r
+               }\r
+       }\r
+\r
+       halbtc8821a2ant_UpdateBtLinkInfo(pBtCoexist);\r
+       \r
+       if(!(btInfo&BT_INFO_8821A_2ANT_B_CONNECTION))\r
+       {\r
+               pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"));\r
+       }\r
+       else if(btInfo == BT_INFO_8821A_2ANT_B_CONNECTION)      // connection exists but no busy\r
+       {\r
+               pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));\r
+       }\r
+       else if((btInfo&BT_INFO_8821A_2ANT_B_SCO_ESCO) ||\r
+               (btInfo&BT_INFO_8821A_2ANT_B_SCO_BUSY))\r
+       {\r
+               pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_SCO_BUSY;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));\r
+       }\r
+       else if(btInfo&BT_INFO_8821A_2ANT_B_ACL_BUSY)\r
+       {\r
+               pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_ACL_BUSY;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"));\r
+       }\r
+       else\r
+       {\r
+               pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_MAX;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));\r
+       }\r
+       \r
+       if( (BT_8821A_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||\r
+               (BT_8821A_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+               (BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+       {\r
+               bBtBusy = TRUE;\r
+               bLimitedDig = TRUE;\r
+       }\r
+       else\r
+       {\r
+               bBtBusy = FALSE;\r
+               bLimitedDig = FALSE;\r
+       }\r
+\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);\r
+\r
+       pCoexDm->bLimitedDig = bLimitedDig;\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig);\r
+\r
+       halbtc8821a2ant_RunCoexistMechanism(pBtCoexist);\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_HaltNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));\r
+\r
+       halbtc8821a2ant_WifiOffHwCfg(pBtCoexist);\r
+       //remove due to interrupt is disabled that polling c2h will fail and delay 100ms.\r
+       //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0\r
+       halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);\r
+       \r
+       EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_PnpNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          pnpState\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n"));\r
+\r
+       if(BTC_WIFI_PNP_SLEEP == pnpState)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n"));\r
+       }\r
+       else if(BTC_WIFI_PNP_WAKE_UP == pnpState)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n"));\r
+               halbtc8821a2ant_InitHwConfig(pBtCoexist, FALSE);\r
+               halbtc8821a2ant_InitCoexDm(pBtCoexist);\r
+               halbtc8821a2ant_QueryBtInfo(pBtCoexist);\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8821a2ant_Periodical(\r
+       IN      PBTC_COEXIST                    pBtCoexist\r
+       )\r
+{\r
+       //static u1Byte         disVerInfoCnt=0;\r
+       u4Byte                          fwVer=0, btPatchVer=0;\r
+       PBTC_BOARD_INFO         pBoardInfo=&pBtCoexist->boardInfo;\r
+       PBTC_STACK_INFO         pStackInfo=&pBtCoexist->stackInfo;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n"));\r
+\r
+       if(pCoexSta->disVerInfoCnt <= 5)\r
+       {\r
+               pCoexSta->disVerInfoCnt += 1;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",\r
+                       pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos));\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n",\r
+                       ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",\r
+                       GLCoexVerDate8821a2Ant, GLCoexVer8821a2Ant, fwVer, btPatchVer, btPatchVer));\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));\r
+\r
+               if (pCoexSta->disVerInfoCnt == 3)\r
+               {\r
+                       //Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial \r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set GNT_BT control by PTA\n"));\r
+                       halbtc8821a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, FALSE, FALSE);\r
+               }\r
+       }\r
+\r
+#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 0)\r
+       halbtc8821a2ant_QueryBtInfo(pBtCoexist);        \r
+       halbtc8821a2ant_MonitorBtEnableDisable(pBtCoexist);\r
+#else\r
+       halbtc8821a2ant_MonitorBtCtr(pBtCoexist);\r
+       halbtc8821a2ant_MonitorWiFiCtr(pBtCoexist);\r
+       \r
+       if( halbtc8821a2ant_IsWifiStatusChanged(pBtCoexist) ||\r
+               pCoexDm->bAutoTdmaAdjust)\r
+       {\r
+               halbtc8821a2ant_RunCoexistMechanism(pBtCoexist);\r
+       }\r
+#endif\r
+}\r
+\r
+\r
+#endif\r
+\r
+#else  // #if (RTL8821A_SUPPORT == 1)\r
+VOID\r
+EXhalbtc8821a2ant_PowerOnSetting(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_PreLoadFirmware(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_InitHwConfig(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bWifiOnly\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_InitCoexDm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_IpsNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_LpsNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_ScanNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_ConnectNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_MediaStatusNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          type\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_SpecialPacketNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          type\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_BtInfoNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      pu1Byte                 tmpBuf,\r
+       IN      u1Byte                  length\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_HaltNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_PnpNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          pnpState\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_Periodical(\r
+       IN      PBTC_COEXIST                    pBtCoexist\r
+       ){}\r
+VOID\r
+EXhalbtc8821a2ant_DisplayCoexInfo(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       ){}\r
+#endif // #if (RTL8821A_SUPPORT == 1)
\ No newline at end of file