net: wireless: rockchip_wlan: add rtl8188fu support
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8188fu / hal / btc / HalBtc8812a1Ant.c
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8188fu/hal/btc/HalBtc8812a1Ant.c b/drivers/net/wireless/rockchip_wlan/rtl8188fu/hal/btc/HalBtc8812a1Ant.c
new file mode 100644 (file)
index 0000000..b911f31
--- /dev/null
@@ -0,0 +1,3717 @@
+//============================================================\r
+// Description:\r
+//\r
+// This file is for RTL8812A 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 "HalBtc8812a1Ant.tmh"\r
+#endif\r
+\r
+#if(BT_30_SUPPORT == 1)\r
+//============================================================\r
+// Global variables, these are static variables\r
+//============================================================\r
+static COEX_DM_8812A_1ANT              GLCoexDm8812a1Ant;\r
+static PCOEX_DM_8812A_1ANT     pCoexDm=&GLCoexDm8812a1Ant;\r
+static COEX_STA_8812A_1ANT             GLCoexSta8812a1Ant;\r
+static PCOEX_STA_8812A_1ANT    pCoexSta=&GLCoexSta8812a1Ant;\r
+\r
+const char *const GLBtInfoSrc8812a1Ant[]={\r
+       "BT Info[wifi fw]",\r
+       "BT Info[bt rsp]",\r
+       "BT Info[bt auto report]",\r
+};\r
+\r
+u4Byte GLCoexVerDate8812a1Ant=20140708;\r
+u4Byte GLCoexVer8812a1Ant=0x52;\r
+\r
+//============================================================\r
+// local function proto type if needed\r
+//============================================================\r
+//============================================================\r
+// local function start with halbtc8812a1ant_\r
+//============================================================\r
+u1Byte\r
+halbtc8812a1ant_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_8812A_1ANT))\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_8812A_1ANT))\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_8812A_1ANT))\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
+halbtc8812a1ant_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_8812A_1ANT))\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_8812A_1ANT))\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_8812A_1ANT))\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
+halbtc8812a1ant_UpdateRaMask(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u4Byte                          disRateMask\r
+       )\r
+{\r
+       pCoexDm->curRaMask = disRateMask;\r
+       \r
+       if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask))\r
+       {\r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask);\r
+       }\r
+       pCoexDm->preRaMask = pCoexDm->curRaMask;\r
+}\r
+\r
+//to check 0x430/0x434 is correct??\r
+VOID\r
+halbtc8812a1ant_AutoRateFallbackRetry(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       BOOLEAN bWifiUnderBMode=FALSE;\r
+       \r
+       pCoexDm->curArfrType = type;\r
+\r
+       if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType))\r
+       {\r
+               switch(pCoexDm->curArfrType)\r
+               {\r
+                       case 0: // normal mode\r
+                               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1);\r
+                               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2);\r
+                               break;\r
+                       case 1: \r
+                               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);\r
+                               if(bWifiUnderBMode)\r
+                               {\r
+                                       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);\r
+                                       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101);\r
+                               }\r
+                               else\r
+                               {\r
+                                       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0);\r
+                                       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201);\r
+                               }\r
+                               break;\r
+                       default:\r
+                               break;\r
+               }\r
+       }\r
+\r
+       pCoexDm->preArfrType = pCoexDm->curArfrType;\r
+}\r
+\r
+//to check 0x42a ??\r
+VOID\r
+halbtc8812a1ant_RetryLimit(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       pCoexDm->curRetryLimitType = type;\r
+\r
+       if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType))\r
+       {\r
+               switch(pCoexDm->curRetryLimitType)\r
+               {\r
+                       case 0: // normal mode\r
+                               pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit);\r
+                               break;\r
+                       case 1: // retry limit=8\r
+                               pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808);\r
+                               break;\r
+                       default:\r
+                               break;\r
+               }\r
+       }\r
+\r
+       pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType;\r
+}\r
+\r
+//to check 0x456??\r
+VOID\r
+halbtc8812a1ant_AmpduMaxTime(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       pCoexDm->curAmpduTimeType = type;\r
+\r
+       if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType))\r
+       {\r
+               switch(pCoexDm->curAmpduTimeType)\r
+               {\r
+                       case 0: // normal mode\r
+                               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime);\r
+                               break;\r
+                       case 1: // AMPDU timw = 0x38 * 32us\r
+                               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38);\r
+                               break;\r
+                       default:\r
+                               break;\r
+               }\r
+       }\r
+\r
+       pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_LimitedTx(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          raMaskType,\r
+       IN      u1Byte                          arfrType,\r
+       IN      u1Byte                          retryLimitType,\r
+       IN      u1Byte                          ampduTimeType\r
+       )\r
+{\r
+       switch(raMaskType)\r
+       {\r
+               case 0: // normal mode\r
+                       halbtc8812a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0);\r
+                       break;\r
+               case 1: // disable cck 1/2\r
+                       halbtc8812a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003);\r
+                       break;\r
+               case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4\r
+                       halbtc8812a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7);\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+\r
+       halbtc8812a1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType);\r
+       halbtc8812a1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType);\r
+       halbtc8812a1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+}\r
+\r
+VOID\r
+halbtc8812a1ant_QueryBtInfo(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{      \r
+       u1Byte  dataLen=3;\r
+       u1Byte  buf[5] = {0};\r
+\r
+       if(!pBtCoexist->btInfo.bBtDisabled)\r
+       {\r
+               if(!pCoexSta->btInfoQueryCnt ||\r
+                       (pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8812A_1ANT_BT_RSP]-pCoexSta->btInfoQueryCnt)>2)\r
+               {\r
+                       buf[0] = dataLen;\r
+                       buf[1] = 0x1;   // polling enable, 1=enable, 0=disable\r
+                       buf[2] = 0x2;   // polling time in seconds\r
+                       buf[3] = 0x1;   // auto report enable, 1=enable, 0=disable\r
+                               \r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_INFO, (PVOID)&buf[0]);\r
+               }\r
+       }\r
+       pCoexSta->btInfoQueryCnt++;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_MonitorBtCtr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u4Byte                  regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1;\r
+       u4Byte                  regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;\r
+       u1Byte                  u1Tmp, u1Tmp1;\r
+       s4Byte                  wifiRssi;\r
+       static u1Byte           NumOfBtCounterChk = 0;\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->lowPriorityTx > 1150)  && (!pCoexSta->bC2hBtInquiryPage))\r
+               pCoexSta->popEventCnt++;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n",\r
+               regHPRx, regHPTx, regLPRx, regLPTx));\r
+\r
+       // reset counter\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc);\r
+\r
+       if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0))\r
+       {\r
+               NumOfBtCounterChk++;\r
+               if (NumOfBtCounterChk >= 3)\r
+               {\r
+                       halbtc8812a1ant_QueryBtInfo(pBtCoexist);\r
+                       NumOfBtCounterChk = 0;\r
+               }\r
+       }\r
+}\r
+\r
+//to check registers\r
+VOID\r
+halbtc8812a1ant_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
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);\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->fBtcRead2Byte(pBtCoexist, 0xf04);\r
+               pCoexSta->nCRCOK_11g    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf14);\r
+               pCoexSta->nCRCOK_11n    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf10);\r
+               pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf40);\r
+\r
+               pCoexSta->nCRCErr_CCK    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf06);\r
+               pCoexSta->nCRCErr_11g    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf16);\r
+               pCoexSta->nCRCErr_11n    = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf12);\r
+               pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf42);                \r
+       }\r
+\r
+\r
+       //reset counter\r
+       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xb58, 0x1, 0x1);\r
+       pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xb58, 0x1, 0x0);\r
+\r
+       if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode))\r
+       {\r
+               if ( (pCoexDm->btStatus == BT_8812A_1ANT_BT_STATUS_ACL_BUSY) ||\r
+                       (pCoexDm->btStatus == BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY) ||\r
+                       (pCoexDm->btStatus == BT_8812A_1ANT_BT_STATUS_SCO_BUSY) )\r
+               {\r
+                       if (pCoexSta->nCRCOK_CCK >(pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n + \r
+                               pCoexSta->nCRCOK_11nAgg) )\r
+                       {\r
+                               if (nCCKLockCounter < 5)\r
+                                nCCKLockCounter++;\r
+                       }\r
+                       else\r
+                       {\r
+                               if (nCCKLockCounter > 0)\r
+                                nCCKLockCounter--;\r
+                       }\r
+\r
+               }\r
+               else\r
+               {\r
+                       if (nCCKLockCounter > 0)\r
+                         nCCKLockCounter--;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               if (nCCKLockCounter > 0)\r
+                       nCCKLockCounter--;\r
+       }\r
+\r
+       if (!pCoexSta->bPreCCKLock)\r
+       {\r
+\r
+               if (nCCKLockCounter >= 5)\r
+                pCoexSta->bCCKLock = TRUE;\r
+               else\r
+                pCoexSta->bCCKLock = FALSE;                    \r
+       }\r
+       else\r
+       {\r
+               if (nCCKLockCounter == 0)\r
+                pCoexSta->bCCKLock = FALSE;\r
+               else\r
+                pCoexSta->bCCKLock = TRUE;             \r
+       }\r
+\r
+       pCoexSta->bPreCCKLock =  pCoexSta->bCCKLock;    \r
+               \r
+\r
+}\r
+\r
+BOOLEAN\r
+halbtc8812a1ant_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
+\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
+       return FALSE;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_UpdateBtLinkInfo(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                         bBtHsOn=FALSE;\r
+\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
+\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
+halbtc8812a1ant_ActionAlgorithm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO       pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                         bBtHsOn=FALSE;\r
+       u1Byte                          algorithm=BT_8812A_1ANT_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], BT Profile = SCO only\n"));\r
+                       algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;\r
+               }\r
+               else\r
+               {\r
+                       if(pBtLinkInfo->bHidExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n"));\r
+                               algorithm = BT_8812A_1ANT_COEX_ALGO_HID;\r
+                       }\r
+                       else if(pBtLinkInfo->bA2dpExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n"));\r
+                               algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP;\r
+                       }\r
+                       else if(pBtLinkInfo->bPanExist)\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_PANHS;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n"));\r
+                                       algorithm = BT_8812A_1ANT_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], BT Profile = SCO + HID\n"));\r
+                               algorithm = BT_8812A_1ANT_COEX_ALGO_HID;\r
+                       }\r
+                       else if(pBtLinkInfo->bA2dpExist)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"));\r
+                               algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;\r
+                       }\r
+                       else if(pBtLinkInfo->bPanExist)\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bA2dpExist )\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n"));\r
+                               algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;\r
+                       }\r
+                       else if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bPanExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n"));\r
+                                       algorithm = BT_8812A_1ANT_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], BT Profile = A2DP + PAN(HS)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n"));\r
+                                       algorithm = BT_8812A_1ANT_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], BT Profile = SCO + HID + A2DP ==> HID\n"));\r
+                               algorithm = BT_8812A_1ANT_COEX_ALGO_HID;\r
+                       }\r
+                       else if( pBtLinkInfo->bHidExist &&\r
+                               pBtLinkInfo->bPanExist )\r
+                       {\r
+                               if(bBtHsOn)\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"));\r
+                                       algorithm = BT_8812A_1ANT_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], BT Profile = SCO + A2DP + PAN(HS)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;\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], BT Profile = HID + A2DP + PAN(HS)\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"));\r
+                                       algorithm = BT_8812A_1ANT_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!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"));\r
+\r
+                               }\r
+                               else\r
+                               {\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));\r
+                                       algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       return algorithm;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+halbtc8812a1ant_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
+       halbtc8812a1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);\r
+\r
+       pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;\r
+}\r
+\r
+//to check\r
+VOID\r
+halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bLowPenaltyRa\r
+       )\r
+{\r
+       u1Byte  tmpU1;\r
+\r
+       tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd);\r
+       tmpU1 |= BIT0;\r
+       if(bLowPenaltyRa)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));\r
+               tmpU1 &= ~BIT2;\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n"));\r
+               tmpU1 |= BIT2;\r
+       }\r
+\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_LowPenaltyRa(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bLowPenaltyRa\r
+       )\r
+{\r
+       pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;\r
+\r
+       if(!bForceExec)\r
+       {\r
+               if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) \r
+                       return;\r
+       }\r
+       halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);\r
+\r
+       pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+halbtc8812a1ant_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, 0x6cc=0x%x\n", \r
+               (bForceExec? "force to":""), val0x6c0, val0x6c4, 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
+       halbtc8812a1ant_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
+halbtc8812a1ant_CoexTableWithType(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** CoexTable(%d) **********\n", type));\r
+       \r
+       pCoexSta->nCoexTableType = type;\r
+       \r
+       switch(type)\r
+       {\r
+               case 0:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);\r
+                       break;\r
+               case 1:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);\r
+                       break;\r
+               case 2:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);\r
+                       break;\r
+               case 3:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);\r
+                       break;\r
+               case 4:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3);\r
+                       break;\r
+               case 5:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaa5a5a5a, 0xffffff, 0x3);\r
+                       break;\r
+               case 6:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3);\r
+                       break;\r
+               case 7:\r
+                       halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_SetFwIgnoreWlanAct(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bEnable\r
+       )\r
+{\r
+       u1Byte  dataLen=3;\r
+       u1Byte  buf[5] = {0};\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Ignore Wlan_Act\n",\r
+               (bEnable? "Enable":"Disable")));\r
+\r
+       buf[0] = dataLen;\r
+       buf[1] = 0x1;                   // OP_Code\r
+       buf[2] = 0x1;                   // OP_Code_Length\r
+       if(bEnable)\r
+               buf[3] = 0x1;           // OP_Code_Content\r
+       else\r
+               buf[3] = 0x0;\r
+               \r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);      \r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+       halbtc8812a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);\r
+\r
+       pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+halbtc8812a1ant_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
+       halbtc8812a1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);\r
+\r
+       pCoexDm->preLps = pCoexDm->curLps;\r
+       pCoexDm->preRpwm = pCoexDm->curRpwm;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_SwMechanism(\r
+       IN      PBTC_COEXIST    pBtCoexist,     \r
+       IN      BOOLEAN                 bLowPenaltyRA\r
+       ) \r
+{\r
+       halbtc8812a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);\r
+}\r
+\r
+//to check bForceExec\r
+VOID\r
+halbtc8812a1ant_SetAntPath(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          antPosType,\r
+       IN      BOOLEAN                         bForceExec,\r
+       IN      BOOLEAN                         bInitHwCfg,\r
+       IN      BOOLEAN                         bWifiOff\r
+       )\r
+{\r
+       u1Byte                  u1Tmp=0;\r
+\r
+       pCoexDm->curAntPosType = antPosType;\r
+       \r
+       if(bInitHwCfg)\r
+       {\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb3, 0x77);\r
+               pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x900, 0x00000400);\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76d, 0x1);\r
+       }\r
+       else if(bWifiOff)\r
+       {\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb3, 0x77);\r
+               u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);\r
+               u1Tmp &= ~BIT3;\r
+               u1Tmp |= BIT2;\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);\r
+       }\r
+\r
+       if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType))\r
+       {               \r
+               // ext switch setting\r
+               switch(antPosType)\r
+               {\r
+                       case BTC_ANT_PATH_WIFI:\r
+                               u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);\r
+                               u1Tmp |= BIT3;\r
+                               u1Tmp &= ~BIT2;                 \r
+                               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);\r
+                               break;\r
+                       case BTC_ANT_PATH_BT:\r
+                               u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);\r
+                               u1Tmp &= ~BIT3;\r
+                               u1Tmp |= BIT2;\r
+                               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);\r
+                               break;\r
+                       default:\r
+                       case BTC_ANT_PATH_PTA:\r
+                               u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);\r
+                               u1Tmp |= BIT3;\r
+                               u1Tmp &= ~BIT2;                 \r
+                               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp);\r
+                               break;\r
+               }\r
+       }\r
+       \r
+       pCoexDm->preAntPosType = pCoexDm->curAntPosType;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+       u1Byte                  realByte1=byte1, realByte5=byte5;\r
+       BOOLEAN                 bApEnable=FALSE;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);\r
+\r
+       if(bApEnable)\r
+       {\r
+               if(byte1&BIT4 && !(byte1&BIT5))\r
+               {                       \r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n"));\r
+                       realByte1 &= ~BIT4;\r
+                       realByte1 |= BIT5;\r
+\r
+                       realByte5 |= BIT5;\r
+                       realByte5 &= ~BIT6;\r
+               }\r
+       }\r
+\r
+       H2C_Parameter[0] = realByte1;   \r
+       H2C_Parameter[1] = byte2;       \r
+       H2C_Parameter[2] = byte3;\r
+       H2C_Parameter[3] = byte4;\r
+       H2C_Parameter[4] = realByte5;\r
+\r
+       pCoexDm->psTdmaPara[0] = realByte1;\r
+       pCoexDm->psTdmaPara[1] = byte2;\r
+       pCoexDm->psTdmaPara[2] = byte3;\r
+       pCoexDm->psTdmaPara[3] = byte4;\r
+       pCoexDm->psTdmaPara[4] = realByte5;\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =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
+\r
+VOID\r
+halbtc8812a1ant_PsTdma(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                 bForceExec,\r
+       IN      BOOLEAN                 bTurnOn,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo;\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                 bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE;\r
+       u1Byte                  psTdmaTypeByCnt=0, rssiAdjustVal=0;\r
+       u1Byte                  psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val =  0x10;\r
+       s1Byte                  nWiFiDurationAdjust = 0x0;\r
+       static BOOLEAN   bPreWifiBusy=FALSE;\r
+\r
+       pCoexDm->bCurPsTdmaOn = bTurnOn;\r
+       pCoexDm->curPsTdma = type;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);      \r
+\r
+       if (bWifiBusy != bPreWifiBusy)\r
+       {\r
+                bForceExec = TRUE;     \r
+                bPreWifiBusy = bWifiBusy;\r
+       }\r
+\r
+       if (pCoexDm->bCurPsTdmaOn)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", \r
+                       pCoexDm->curPsTdma));\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n", \r
+                       pCoexDm->curPsTdma));\r
+       }\r
+                       \r
+       if(!bForceExec)\r
+       {\r
+               if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&\r
+                       (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )\r
+                       return;\r
+       }\r
+\r
+       if (pCoexSta->nScanAPNum <= 5)\r
+               nWiFiDurationAdjust = 2;\r
+       else if  (pCoexSta->nScanAPNum >= 40)\r
+               nWiFiDurationAdjust = -15;      \r
+       else if  (pCoexSta->nScanAPNum >= 20)\r
+               nWiFiDurationAdjust = -10;      \r
+       \r
+       if (!pCoexSta->bForceLpsOn)  //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30\r
+       {\r
+               psTdmaByte0Val = 0x61;  //no null-pkt\r
+               psTdmaByte3Val = 0x11; // no tx-pause at BT-slot\r
+               psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle\r
+       }\r
+       \r
+       if (  (type == 3) || (type == 13) || (type == 14) )\r
+       {\r
+               psTdmaByte4Val = psTdmaByte4Val & 0xbf;  //no dynamic slot for multi-profile\r
+       \r
+               if (!bWifiBusy)\r
+                psTdmaByte4Val = psTdmaByte4Val | 0x1;  //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)\r
+       }\r
+       \r
+       if (pBtLinkInfo->bSlaveRole == TRUE)\r
+               psTdmaByte4Val = psTdmaByte4Val | 0x1;  //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts)\r
+               \r
+       if(bTurnOn)\r
+       {        \r
+               switch(type)\r
+               {\r
+                       default:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val);\r
+                               break;\r
+                       case 1:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val);                                                                \r
+                               break;\r
+                       case 2:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val);                                                        \r
+                               break;\r
+                       case 3:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val);\r
+                               break;\r
+                       case 4:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);\r
+                               break;\r
+                       case 5:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x11);\r
+                               break;\r
+                       case 6:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11);\r
+                               break;\r
+                       case 7:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);\r
+                               break;\r
+                       case 8: \r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);\r
+                               break;\r
+                       case 9: \r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val);                             \r
+                               break;\r
+                       case 10:        \r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);\r
+                               break;\r
+                       case 11:        \r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val);                    \r
+                               break;\r
+                       case 12:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50);\r
+                               break;\r
+                       case 13:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val);\r
+                               break;\r
+                       case 14:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val);\r
+                               break;\r
+                       case 15:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);\r
+                               break;\r
+                       case 16:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);\r
+                               break;\r
+                       case 18:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);\r
+                               break;                  \r
+                       case 20:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10);\r
+                               break;\r
+                       case 21:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11);\r
+                               break;\r
+                       case 22:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10);\r
+                               break;\r
+                       case 23:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);\r
+                               break;\r
+                       case 24:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);\r
+                               break;\r
+                       case 25:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);\r
+                               break;\r
+                       case 26:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);\r
+                               break;\r
+                       case 27:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);\r
+                               break;\r
+                       case 28:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);\r
+                               break;\r
+                       case 29:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);\r
+                               break;\r
+                       case 30:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10);\r
+                               break;\r
+                       case 31:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);\r
+                               break;\r
+                       case 32:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11);\r
+                               break;\r
+                       case 33:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);\r
+                               break;\r
+                       case 34:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10);\r
+                               break;\r
+                       case 35:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10);\r
+                               break;\r
+                       case 36:\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);\r
+                               break;\r
+                       case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving\r
+                               /* here softap mode screen off will cost 70-80mA for phone */\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24);\r
+                               break;  \r
+               }\r
+       }\r
+       else\r
+       {               \r
+\r
+               // disable PS tdma\r
+               switch(type)\r
+               {\r
+                       case 8: //PTA Control\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);\r
+                               break;\r
+                       case 0:\r
+                       default:  //Software control, Antenna at BT side\r
+                               halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);\r
+                               break;\r
+               }\r
+       }\r
+       rssiAdjustVal =0;\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);\r
+\r
+\r
+       // update pre state\r
+       pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;\r
+       pCoexDm->prePsTdma = pCoexDm->curPsTdma;\r
+}\r
+\r
+BOOLEAN\r
+halbtc8812a1ant_IsCommonAction(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       BOOLEAN                 bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;\r
+\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
+               BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));\r
+               \r
+               //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+\r
+               bCommon = TRUE;\r
+       }\r
+       else if(bWifiConnected && \r
+               (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));\r
+\r
+               //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+\r
+               bCommon = TRUE;\r
+       }\r
+       else if(!bWifiConnected && \r
+               (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));\r
+\r
+               //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+\r
+               bCommon = TRUE;\r
+       }\r
+       else if(bWifiConnected && \r
+               (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));\r
+\r
+               //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+\r
+               bCommon = TRUE;\r
+       }\r
+       else if(!bWifiConnected && \r
+               (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));\r
+\r
+               //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+               \r
+               bCommon = TRUE;\r
+       }\r
+       else\r
+       {\r
+               if (bWifiBusy)                  \r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n"));\r
+               }\r
+               else\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n"));\r
+               }\r
+               \r
+               bCommon = FALSE;\r
+       }\r
+       \r
+       return bCommon;\r
+}\r
+\r
+\r
+VOID\r
+halbtc8812a1ant_TdmaDurationAdjustForAcl(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          wifiStatus\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, btInfoExt;\r
+       static BOOLEAN  bPreWifiBusy=FALSE;\r
+       BOOLEAN                 bWifiBusy = FALSE;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));\r
+\r
+       if(BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus) \r
+               bWifiBusy = TRUE;\r
+       else\r
+               bWifiBusy = FALSE;              \r
+\r
+       if( (BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||\r
+               (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||\r
+               (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )\r
+       {\r
+               if( pCoexDm->curPsTdma != 1 &&\r
+                       pCoexDm->curPsTdma != 2 &&\r
+                       pCoexDm->curPsTdma != 3 &&\r
+                       pCoexDm->curPsTdma != 9 )\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                       pCoexDm->psTdmaDuAdjType = 9;\r
+\r
+                       up = 0;\r
+                       dn = 0;\r
+                       m = 1;\r
+                       n= 3;\r
+                       result = 0;\r
+                       WaitCount = 0;\r
+               }               \r
+               return;\r
+       }\r
+\r
+       if(!pCoexDm->bAutoTdmaAdjust)\r
+       {\r
+               pCoexDm->bAutoTdmaAdjust = TRUE;\r
+               RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));\r
+\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+               pCoexDm->psTdmaDuAdjType = 2;\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
+               btInfoExt = pCoexSta->btInfoExt;\r
+\r
+               if ( (pCoexSta->lowPriorityTx) > 1150 ||  (pCoexSta->lowPriorityRx) > 1250 )\r
+                       retryCount++;   \r
+               \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
+               if(result == -1)\r
+               {\r
+                       if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&\r
+                               ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                               pCoexDm->psTdmaDuAdjType = 9;\r
+                       }\r
+                       else if(pCoexDm->curPsTdma == 1)\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                               pCoexDm->psTdmaDuAdjType = 2;\r
+                       }\r
+                       else if(pCoexDm->curPsTdma == 2)\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                               pCoexDm->psTdmaDuAdjType = 9;\r
+                       }\r
+                       else if(pCoexDm->curPsTdma == 9)\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11);\r
+                               pCoexDm->psTdmaDuAdjType = 11;\r
+                       }\r
+               }\r
+               else if(result == 1)\r
+               {\r
+                       if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&\r
+                               ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                               pCoexDm->psTdmaDuAdjType = 9;\r
+                       }\r
+                       else if(pCoexDm->curPsTdma == 11)\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9);\r
+                               pCoexDm->psTdmaDuAdjType = 9;\r
+                       }\r
+                       else if(pCoexDm->curPsTdma == 9)\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2);\r
+                               pCoexDm->psTdmaDuAdjType = 2;\r
+                       }\r
+                       else if(pCoexDm->curPsTdma == 2)\r
+                       {\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1);\r
+                               pCoexDm->psTdmaDuAdjType = 1;\r
+                       }\r
+               }\r
+               else      //no change\r
+               {\r
+                       /* Bryant Modify        \r
+                       if(bWifiBusy != bPreWifiBusy)  //if busy / idle change\r
+                       {\r
+                               bPreWifiBusy = bWifiBusy;\r
+                               halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma);\r
+                       }\r
+                       */\r
+               \r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", \r
+                               pCoexDm->curPsTdma));\r
+               }\r
+\r
+               if( pCoexDm->curPsTdma != 1 &&\r
+                       pCoexDm->curPsTdma != 2 &&\r
+                       pCoexDm->curPsTdma != 9 &&\r
+                       pCoexDm->curPsTdma != 11 )\r
+               {\r
+                       // recover to previous adjust type\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType);\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               }\r
+       }\r
+       else                                            // NO PS state\r
+       {\r
+               if(bNewPsState)\r
+               {\r
+                       // will enter LPS state, turn off psTdma first\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               }\r
+               else\r
+               {\r
+                       // keep state under NO PS state, do nothing.\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+                       halbtc8812a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE);\r
+                       halbtc8812a1ant_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
+                       halbtc8812a1ant_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
+VOID\r
+halbtc8812a1ant_ActionWifiOnly(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);\r
+       halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);\r
+       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_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
+                       halbtc8812a1ant_ActionWifiOnly(pBtCoexist);\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
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);\r
+                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);\r
+               }\r
+       }\r
+}\r
+\r
+//=============================================\r
+//\r
+//     Software Coex Mechanism start\r
+//\r
+//=============================================\r
+\r
+// SCO only or SCO+PAN(HS)\r
+\r
+/*\r
+VOID\r
+halbtc8812a1ant_ActionSco(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE);\r
+}\r
+\r
+\r
+VOID\r
+halbtc8812a1ant_ActionHid(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE);\r
+}\r
+\r
+//A2DP only / PAN(EDR) only/ A2DP+PAN(HS)\r
+VOID\r
+halbtc8812a1ant_ActionA2dp(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionA2dpPanHs(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionPanEdr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+}\r
+\r
+//PAN(HS) only\r
+VOID\r
+halbtc8812a1ant_ActionPanHs(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+}\r
+\r
+//PAN(EDR)+A2DP\r
+VOID\r
+halbtc8812a1ant_ActionPanEdrA2dp(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionPanEdrHid(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE);\r
+}\r
+\r
+// HID+A2DP+PAN(EDR)\r
+VOID\r
+halbtc8812a1ant_ActionHidA2dpPanEdr(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionHidA2dp(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE);\r
+}\r
+\r
+*/\r
+\r
+//=============================================\r
+//\r
+//     Non-Software Coex Mechanism start\r
+//\r
+//=============================================\r
+VOID\r
+halbtc8812a1ant_ActionWifiMultiPort(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+       \r
+       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionHs(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);\r
+       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionBtInquiry(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{      \r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN                 bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);\r
+\r
+       if((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask))\r
+       {\r
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);          \r
+       }\r
+       else if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist))\r
+       {\r
+               // SCO/HID/A2DP  busy\r
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);\r
+\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);          \r
+       }\r
+       else if ((pBtLinkInfo->bPanExist) || (bWifiBusy))\r
+       {\r
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);              \r
+               \r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+       }\r
+       else\r
+       {\r
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionBtScoHidOnlyBusy(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          wifiStatus\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN bWifiConnected=FALSE;\r
+       u1Byte  wifiRssiState=BTC_RSSI_STATE_HIGH;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+\r
+       // tdma and coex table\r
+\r
+       if(pBtLinkInfo->bScoExist)\r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);\r
+       }\r
+       else //HID\r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiConnectedBtAclBusy(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                          wifiStatus\r
+       )\r
+{\r
+       u1Byte          btRssiState;\r
+       \r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       btRssiState = halbtc8812a1ant_BtRssiState(2, 28, 0);    \r
+\r
+       if ( (pCoexSta->lowPriorityRx >= 950)  && (!pCoexSta->bUnderIps) )\r
+       {\r
+               pBtLinkInfo->bSlaveRole = TRUE;\r
+       }\r
+       else\r
+       {\r
+               pBtLinkInfo->bSlaveRole = FALSE;\r
+       }\r
+\r
+       if(pBtLinkInfo->bHidOnly)  //HID\r
+       {\r
+               halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);\r
+               pCoexDm->bAutoTdmaAdjust = FALSE;\r
+               return;\r
+       }\r
+       else if(pBtLinkInfo->bA2dpOnly)  //A2DP         \r
+       {\r
+               if(BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus)\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+                       pCoexDm->bAutoTdmaAdjust = FALSE;\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+                       pCoexDm->bAutoTdmaAdjust = TRUE;\r
+               }\r
+       }\r
+       else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) ||\r
+                      (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)\r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               pCoexDm->bAutoTdmaAdjust = FALSE;\r
+       }\r
+       else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist)  //HID+A2DP\r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14);\r
+               pCoexDm->bAutoTdmaAdjust = FALSE;\r
+\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3);\r
+       }\r
+       else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP)                 \r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               pCoexDm->bAutoTdmaAdjust = FALSE;\r
+       }\r
+       else\r
+       {               \r
+               //BT no-profile busy (0x9)\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);      \r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               pCoexDm->bAutoTdmaAdjust = FALSE;\r
+       }       \r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiNotConnected(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       // power save state\r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+\r
+       // tdma and coex table\r
+       halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);\r
+       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiNotConnectedScan(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       \r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+\r
+       // tdma and coex table\r
+       if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)\r
+       {\r
+               if (pBtLinkInfo->bA2dpExist)\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               }\r
+               else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               }\r
+       }\r
+       else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+                       (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+       {\r
+               halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,\r
+                       BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN);\r
+       }\r
+       else\r
+       {\r
+               //Bryant Add\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiNotConnectedAssoAuth(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       \r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+\r
+       // tdma and coex table\r
+       if( (pBtLinkInfo->bScoExist)  || (pBtLinkInfo->bHidExist) ||  (pBtLinkInfo->bA2dpExist) )\r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4);           \r
+       }\r
+       else if (pBtLinkInfo->bPanExist)                        \r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4);           \r
+       }\r
+       else    \r
+       {               \r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 2);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiConnectedScan(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       \r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+\r
+       // tdma and coex table\r
+       if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)\r
+       {\r
+               if (pBtLinkInfo->bA2dpExist)\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               }\r
+               else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist)\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);\r
+                       halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);\r
+               }\r
+       }\r
+       else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+                       (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+       {\r
+               halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,\r
+                       BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN);\r
+       }\r
+       else\r
+       {\r
+               //Bryant Add\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiConnectedSpecialPacket(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+\r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+\r
+       // tdma and coex table\r
+       if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist))\r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);          \r
+       }\r
+       else if(pBtLinkInfo->bPanExist) \r
+       {\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4);          \r
+       }\r
+       else    \r
+       {               \r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_ActionWifiConnected(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       BOOLEAN         bWifiBusy=FALSE;\r
+       BOOLEAN         bScan=FALSE, bLink=FALSE, bRoam=FALSE;\r
+       BOOLEAN         bUnder4way=FALSE, bApEnable=FALSE;\r
+       u4Byte          wifiBw;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n"));\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);\r
+       if(bUnder4way)\r
+       {\r
+               halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));\r
+               return;\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
+       if(bScan || bLink || bRoam)\r
+       {\r
+               if(bScan)       \r
+                       halbtc8812a1ant_ActionWifiConnectedScan(pBtCoexist);\r
+               else\r
+                       halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));\r
+               return;\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);\r
+       \r
+       // power save state\r
+       if(!bApEnable && BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly)\r
+       {\r
+               if(pBtCoexist->btLinkInfo.bA2dpOnly)    //A2DP\r
+                       {                       \r
+                       if(!bWifiBusy)\r
+                               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                               \r
+                       else //busy\r
+                       {\r
+                               if  (pCoexSta->nScanAPNum >= BT_8812A_1ANT_WIFI_NOISY_THRESH)  //no force LPS, no PS-TDMA, use pure TDMA\r
+                               {\r
+                                       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);                                                               \r
+                               }\r
+                               else\r
+                               {\r
+                                       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);                                   \r
+                               }\r
+                       }\r
+               }\r
+               else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE))\r
+                       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               else\r
+                       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4);\r
+       }\r
+       else\r
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+\r
+       // tdma and coex table\r
+       if(!bWifiBusy)\r
+       {\r
+               if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)\r
+               {\r
+                       halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, \r
+                               BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE);\r
+               }\r
+               else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+                       (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+               {\r
+                       halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,\r
+                               BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+                       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);\r
+                       if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 )\r
+                               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+                       else\r
+                               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);           \r
+               }\r
+       }\r
+       else\r
+       {\r
+               if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)\r
+               {\r
+                       halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,\r
+                               BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY);\r
+               }\r
+               else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+                       (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+               {\r
+                       halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist,\r
+                               BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY);\r
+               }\r
+               else \r
+               {\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);\r
+                       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE);    \r
+                       if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 )\r
+                               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+                       else\r
+                               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); \r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_RunSwCoexistMechanism(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       u1Byte                          algorithm=0;\r
+\r
+       algorithm = halbtc8812a1ant_ActionAlgorithm(pBtCoexist);\r
+       pCoexDm->curAlgorithm = algorithm;\r
+\r
+       if(halbtc8812a1ant_IsCommonAction(pBtCoexist))\r
+       {\r
+\r
+       }\r
+       else\r
+       {\r
+               switch(pCoexDm->curAlgorithm)\r
+               {\r
+                       case BT_8812A_1ANT_COEX_ALGO_SCO:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n"));\r
+                               //halbtc8812a1ant_ActionSco(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_HID:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n"));\r
+                               //halbtc8812a1ant_ActionHid(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_A2DP:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n"));\r
+                               //halbtc8812a1ant_ActionA2dp(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));\r
+                               //halbtc8812a1ant_ActionA2dpPanHs(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_PANEDR:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n"));\r
+                               //halbtc8812a1ant_ActionPanEdr(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_PANHS:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n"));\r
+                               //halbtc8812a1ant_ActionPanHs(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));\r
+                               //halbtc8812a1ant_ActionPanEdrA2dp(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_PANEDR_HID:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));\r
+                               //halbtc8812a1ant_ActionPanEdrHid(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));\r
+                               //halbtc8812a1ant_ActionHidA2dpPanEdr(pBtCoexist);\r
+                               break;\r
+                       case BT_8812A_1ANT_COEX_ALGO_HID_A2DP:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n"));\r
+                               //halbtc8812a1ant_ActionHidA2dp(pBtCoexist);\r
+                               break;\r
+                       default:\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n"));\r
+                               //halbtc8812a1ant_CoexAllOff(pBtCoexist);\r
+                               break;\r
+               }\r
+               pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_RunCoexistMechanism(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo;\r
+       BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;\r
+       BOOLEAN bIncreaseScanDevNum=FALSE;\r
+       BOOLEAN bBtCtrlAggBufSize=FALSE;\r
+       BOOLEAN bMiracastPlusBt=FALSE;\r
+       u1Byte  aggBufSize=5;\r
+       u1Byte  wifiRssiState=BTC_RSSI_STATE_HIGH;\r
+       u4Byte  wifiLinkStatus=0;\r
+       u4Byte  numOfWifiLink=0, wifiBw;\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
+       if(pBtCoexist->bStopCoexDm)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));\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( (BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||\r
+               (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+               (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+       {\r
+               bIncreaseScanDevNum = TRUE;\r
+       }\r
+\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\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
+                       halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1);\r
+                       bMiracastPlusBt = TRUE;\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);\r
+                       bMiracastPlusBt = FALSE;\r
+               }\r
+               pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt);\r
+               halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);\r
+\r
+               if ( (pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage) )\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex],  BT Is Inquirying \n") );       \r
+                       halbtc8812a1ant_ActionBtInquiry(pBtCoexist);\r
+               }\r
+               else\r
+                       halbtc8812a1ant_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
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);\r
+\r
+       if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) )\r
+       {\r
+               halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); \r
+\r
+               if(pBtLinkInfo->bScoExist)\r
+                       halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5);\r
+               else\r
+               {\r
+                       if (BTC_WIFI_BW_HT40==wifiBw)\r
+                        halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x10); \r
+                       else\r
+                        halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8);          \r
+               }\r
+\r
+               halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE);\r
+               halbtc8812a1ant_RunSwCoexistMechanism(pBtCoexist);  //just print debug message\r
+       }\r
+       else\r
+       {\r
+               halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); \r
+\r
+               halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5);\r
+\r
+               halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+               halbtc8812a1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+       if(pCoexSta->bC2hBtInquiryPage)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex],  BT Is Inquirying \n") );               \r
+               halbtc8812a1ant_ActionBtInquiry(pBtCoexist);\r
+               return;\r
+       }\r
+       else if(bBtHsOn)\r
+       {\r
+               halbtc8812a1ant_ActionHs(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       \r
+       if(!bWifiConnected)\r
+       {\r
+               BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;\r
+               \r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n"));\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
+                        if (bScan)     \r
+                               halbtc8812a1ant_ActionWifiNotConnectedScan(pBtCoexist); \r
+                        else\r
+                               halbtc8812a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);     \r
+               }\r
+               else\r
+                       halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist);\r
+       }\r
+       else    // wifi LPS/Busy\r
+       {\r
+               halbtc8812a1ant_ActionWifiConnected(pBtCoexist);\r
+       }\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_InitCoexDm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{      \r
+       // force to reset coex mechanism\r
+\r
+       // sw all off\r
+       halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE);\r
+       \r
+       //halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);\r
+       //halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);\r
+\r
+       pCoexSta->popEventCnt = 0;\r
+}\r
+\r
+VOID\r
+halbtc8812a1ant_InitHwConfig(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bBackUp,\r
+       IN      BOOLEAN                         bWifiOnly\r
+       )\r
+{\r
+       u4Byte  u4Tmp=0;\r
+       u2Byte  u2Tmp=0;\r
+       u1Byte  u1Tmp=0;\r
+\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n"));\r
+       \r
+       //ant sw control to BT\r
+       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, TRUE, FALSE);\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
+       // PTA parameter\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0);\r
+       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff);\r
+       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555);\r
+       pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, 0x55555555);\r
+\r
+       // coex parameters\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1);\r
+\r
+       // enable counter statistics\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4);\r
+\r
+       // enable PTA\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20);\r
+\r
+       // bt clock related\r
+       u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4);\r
+       u1Tmp |= BIT7;\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4, u1Tmp);\r
+\r
+       // bt clock related\r
+       u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7);\r
+       u1Tmp |= BIT1;\r
+       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp);\r
+}\r
+\r
+//============================================================\r
+// work around function start with wa_halbtc8812a1ant_\r
+//============================================================\r
+//============================================================\r
+// extern function start with EXhalbtc8812a1ant_\r
+//============================================================\r
+VOID\r
+EXhalbtc8812a1ant_PowerOnSetting(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_PreLoadFirmware(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_InitHwConfig(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      BOOLEAN                         bWifiOnly\r
+       )\r
+{\r
+       halbtc8812a1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly);\r
+       pBtCoexist->bStopCoexDm = FALSE;\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_InitCoexDm(\r
+       IN      PBTC_COEXIST            pBtCoexist\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n"));\r
+\r
+       pBtCoexist->bStopCoexDm = FALSE;\r
+       \r
+       halbtc8812a1ant_InitCoexDm(pBtCoexist);\r
+\r
+       halbtc8812a1ant_QueryBtInfo(pBtCoexist);\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_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                          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
+       if(pBtCoexist->bStopCoexDm)\r
+       {\r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");\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_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \\r
+               GLCoexVerDate8812a1Ant, GLCoexVer8812a1Ant, 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/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \\r
+               ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"):        ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":\r
+               (  (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),\r
+               pCoexSta->btRssi, 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
+       pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);\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_8812A_1ANT_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)", GLBtInfoSrc8812a1Ant[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
+       if(!pBtCoexist->bManualControl)\r
+       {\r
+               // Sw mechanism \r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");\r
+               CL_PRINTF(cliBuf);\r
+       \r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \\r
+                       (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"),\r
+                               pBtCoexist->btInfo.aggBufSize);\r
+               CL_PRINTF(cliBuf);\r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \\r
+                               pBtCoexist->btInfo.raMask);\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", "PS TDMA", \\r
+                       pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],\r
+                       pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],\r
+                       pCoexDm->psTdmaPara[4], psTdmaCase);\r
+               CL_PRINTF(cliBuf);\r
+\r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \\r
+                       pCoexDm->errorCondition);\r
+               CL_PRINTF(cliBuf);\r
+               \r
+               CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \\r
+                       pCoexDm->bCurIgnoreWlanAct);\r
+               CL_PRINTF(cliBuf);\r
+       }\r
+\r
+       // Hw setting           \r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");\r
+       CL_PRINTF(cliBuf);      \r
+\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \\r
+               u1Tmp[0]);\r
+       CL_PRINTF(cliBuf);\r
+       \r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb3);\r
+       u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7);\r
+       u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x900);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xcb3/0xcb7/0x900", \\r
+               u1Tmp[0], u1Tmp[1], u4Tmp[0]);\r
+       CL_PRINTF(cliBuf);\r
+\r
+       u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \\r
+               u1Tmp[0]);\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
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \\r
+               u4Tmp[0]);\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(hp rx[31:16]/tx[15:0])", \\r
+               pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);\r
+       CL_PRINTF(cliBuf);\r
+       CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \\r
+               pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);\r
+       CL_PRINTF(cliBuf);\r
+       \r
+       pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);\r
+}\r
+\r
+\r
+\r
+VOID\r
+EXhalbtc8812a1ant_IpsNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       u4Byte  u4Tmp=0;\r
+\r
+       if(pBtCoexist->bManualControl ||        pBtCoexist->bStopCoexDm)\r
+               return;\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
+               \r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);  \r
+       }\r
+       else if(BTC_IPS_LEAVE == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n"));\r
+\r
+               halbtc8812a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);\r
+               halbtc8812a1ant_InitCoexDm(pBtCoexist);\r
+               halbtc8812a1ant_QueryBtInfo(pBtCoexist);\r
+\r
+               pCoexSta->bUnderIps = FALSE;\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_LpsNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm)\r
+               return;\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
+EXhalbtc8812a1ant_ScanNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;\r
+       u4Byte  wifiLinkStatus=0;\r
+       u4Byte  numOfWifiLink=0;\r
+       BOOLEAN bBtCtrlAggBufSize=FALSE;\r
+       u1Byte  aggBufSize=5;\r
+\r
+       u1Byte u1Tmpa, u1Tmpb;\r
+       u4Byte u4Tmp;\r
+\r
+       if(pBtCoexist->bManualControl ||\r
+               pBtCoexist->bStopCoexDm )\r
+               return;\r
+\r
+       if(BTC_SCAN_START == type)\r
+       {\r
+               pCoexSta->bWiFiIsHighPriTask = TRUE;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));\r
+\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);  //Force antenna setup for no scan result issue\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);\r
+       }\r
+       else\r
+       {\r
+               pCoexSta->bWiFiIsHighPriTask = FALSE;   \r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));\r
+\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum);              \r
+       }       \r
+\r
+       if(pBtCoexist->btInfo.bBtDisabled)\r
+               return;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+\r
+       halbtc8812a1ant_QueryBtInfo(pBtCoexist);\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);\r
+       numOfWifiLink = wifiLinkStatus>>16;\r
+       if(numOfWifiLink >= 2)\r
+       {\r
+               halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);\r
+               halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);\r
+               halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist);\r
+               return;\r
+       }\r
+       \r
+       if(pCoexSta->bC2hBtInquiryPage)\r
+       {\r
+               halbtc8812a1ant_ActionBtInquiry(pBtCoexist);\r
+               return;\r
+       }\r
+       else if(bBtHsOn)\r
+       {\r
+               halbtc8812a1ant_ActionHs(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       if(BTC_SCAN_START == type)\r
+       {       \r
+               //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n"));\r
+               if(!bWifiConnected)     // non-connected scan\r
+               {\r
+                       halbtc8812a1ant_ActionWifiNotConnectedScan(pBtCoexist);\r
+               }\r
+               else    // wifi is connected\r
+               {\r
+                       halbtc8812a1ant_ActionWifiConnectedScan(pBtCoexist);\r
+               }\r
+       }\r
+       else if(BTC_SCAN_FINISH == type)\r
+       {\r
+               //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n"));\r
+               if(!bWifiConnected)     // non-connected scan\r
+               {\r
+                       halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_ActionWifiConnected(pBtCoexist);\r
+               }\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_ConnectNotify(\r
+       IN      PBTC_COEXIST            pBtCoexist,\r
+       IN      u1Byte                  type\r
+       )\r
+{\r
+       BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;    \r
+       u4Byte  wifiLinkStatus=0;\r
+       u4Byte  numOfWifiLink=0;\r
+       BOOLEAN bBtCtrlAggBufSize=FALSE;\r
+       u1Byte  aggBufSize=5;\r
+\r
+       if(pBtCoexist->bManualControl ||\r
+               pBtCoexist->bStopCoexDm ||\r
+               pBtCoexist->btInfo.bBtDisabled )\r
+               return;\r
+\r
+       if(BTC_ASSOCIATE_START == type)\r
+       {\r
+                pCoexSta->bWiFiIsHighPriTask = TRUE;\r
+                halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);  //Force antenna setup for no scan result issue\r
+                halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);\r
+                RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));   \r
+                pCoexDm->nArpCnt = 0;\r
+       }\r
+       else\r
+       {\r
+               pCoexSta->bWiFiIsHighPriTask = FALSE;   \r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));   \r
+               //pCoexDm->nArpCnt = 0;\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);\r
+       numOfWifiLink = wifiLinkStatus>>16;\r
+       if(numOfWifiLink >= 2)\r
+       {\r
+               halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);\r
+               halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);\r
+               halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+       if(pCoexSta->bC2hBtInquiryPage)\r
+       {\r
+               halbtc8812a1ant_ActionBtInquiry(pBtCoexist);\r
+               return;\r
+       }\r
+       else if(bBtHsOn)\r
+       {\r
+               halbtc8812a1ant_ActionHs(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       if(BTC_ASSOCIATE_START == type)\r
+       {\r
+               //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n"));          \r
+               halbtc8812a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist);\r
+       }\r
+       else if(BTC_ASSOCIATE_FINISH == type)\r
+       {\r
+               //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n"));\r
+               \r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+               if(!bWifiConnected) // non-connected scan\r
+               {\r
+                       halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist);\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_ActionWifiConnected(pBtCoexist);\r
+               }\r
+       }\r
+}\r
+\r
+//to check registers...\r
+VOID\r
+EXhalbtc8812a1ant_MediaStatusNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       u1Byte                  dataLen=5;\r
+       u1Byte                  buf[6] = {0};\r
+       u1Byte                  H2C_Parameter[3] ={0};\r
+       u4Byte                  wifiBw;\r
+       u1Byte                  wifiCentralChnl;\r
+       BOOLEAN                 bWifiUnderBMode = FALSE;\r
+\r
+       if(pBtCoexist->bManualControl ||\r
+               pBtCoexist->bStopCoexDm ||\r
+               pBtCoexist->btInfo.bBtDisabled )\r
+               return;\r
+\r
+       if(BTC_MEDIA_CONNECT == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n"));\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);  //Force antenna setup for no scan result issue\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE);\r
+               pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);\r
+#if 0\r
+               //Set CCK Tx/Rx high Pri except 11b mode\r
+               if (bWifiUnderBMode)\r
+               {\r
+                       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx\r
+                       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx\r
+               }\r
+               else\r
+               {\r
+                       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx\r
+                       pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx\r
+               }\r
+#endif \r
+               pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430);\r
+               pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434);\r
+               pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a);\r
+               pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456);\r
+       }\r
+       else\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n"));\r
+               pCoexDm->nArpCnt = 0;\r
+\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx\r
+               pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx\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[0] = 0x0;\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
+                       H2C_Parameter[2] = 0x20;\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
+       buf[0] = dataLen;\r
+       buf[1] = 0x5;                           // OP_Code\r
+       buf[2] = 0x3;                           // OP_Code_Length\r
+       buf[3] = H2C_Parameter[0];      // OP_Code_Content\r
+       buf[4] = H2C_Parameter[1];\r
+       buf[5] = H2C_Parameter[2];\r
+\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_SpecialPacketNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          type\r
+       )\r
+{\r
+       BOOLEAN bBtHsOn=FALSE;\r
+       u4Byte  wifiLinkStatus=0;\r
+       u4Byte  numOfWifiLink=0;\r
+       BOOLEAN bBtCtrlAggBufSize=FALSE;\r
+       u1Byte  aggBufSize=5;\r
+\r
+       if(pBtCoexist->bManualControl ||\r
+               pBtCoexist->bStopCoexDm ||\r
+               pBtCoexist->btInfo.bBtDisabled )\r
+               return;\r
+\r
+       if( BTC_PACKET_DHCP == type || \r
+               BTC_PACKET_EAPOL == type ||\r
+               BTC_PACKET_ARP == type )\r
+       {\r
+               if(BTC_PACKET_ARP == type)\r
+               {\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n"));                \r
+\r
+                       pCoexDm->nArpCnt++;\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt));\r
+                       \r
+                       if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) \r
+                       {\r
+                               pCoexSta->bWiFiIsHighPriTask = FALSE;                                   \r
+                       }                       \r
+                       else\r
+                       {\r
+                               pCoexSta->bWiFiIsHighPriTask = TRUE;\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       pCoexSta->bWiFiIsHighPriTask = TRUE;\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n"));              \r
+               }\r
+       }\r
+       else\r
+       {\r
+               pCoexSta->bWiFiIsHighPriTask = FALSE;   \r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type));\r
+       }\r
+\r
+       pCoexSta->specialPktPeriodCnt = 0;\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus);\r
+       numOfWifiLink = wifiLinkStatus>>16;\r
+       if(numOfWifiLink >= 2)\r
+       {\r
+               halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0);\r
+               halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize);\r
+               halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);\r
+       if(pCoexSta->bC2hBtInquiryPage)\r
+       {\r
+               halbtc8812a1ant_ActionBtInquiry(pBtCoexist);\r
+               return;\r
+       }\r
+       else if(bBtHsOn)\r
+       {\r
+               halbtc8812a1ant_ActionHs(pBtCoexist);\r
+               return;\r
+       }\r
+\r
+       if( BTC_PACKET_DHCP == type ||\r
+               BTC_PACKET_EAPOL == type || \r
+               ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) )\r
+       {\r
+               halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_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                         bWifiConnected=FALSE;\r
+       BOOLEAN                         bBtBusy=FALSE;\r
+       \r
+       pCoexSta->bC2hBtInfoReqSent = FALSE;\r
+\r
+       rspSource = tmpBuf[0]&0xf;\r
+       if(rspSource >= BT_INFO_SRC_8812A_1ANT_MAX)\r
+               rspSource = BT_INFO_SRC_8812A_1ANT_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(BT_INFO_SRC_8812A_1ANT_WIFI_FW != rspSource)\r
+       {\r
+               pCoexSta->btRetryCnt =  // [3:0]\r
+                       pCoexSta->btInfoC2h[rspSource][2]&0xf;\r
+\r
+               if (pCoexSta->btRetryCnt >= 1)\r
+                       pCoexSta->popEventCnt++;\r
+\r
+               if (pCoexSta->btInfoC2h[rspSource][2]&0x20)\r
+                       pCoexSta->bC2hBtPage = TRUE;\r
+               else\r
+                       pCoexSta->bC2hBtPage = FALSE;                   \r
+\r
+               pCoexSta->btRssi =\r
+                       pCoexSta->btInfoC2h[rspSource][3]*2-90;\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 != 0x15 => Need to switch BT TRx Mask */                            \r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n"));\r
+                       pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15);\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
+                       pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);\r
+                       if(bWifiConnected)\r
+                       {\r
+                               EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);\r
+                       }\r
+                       else\r
+                       {\r
+                               EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);\r
+                       }\r
+               }\r
+                               \r
+               if(pCoexSta->btInfoExt & BIT3)\r
+               {\r
+                       if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm)\r
+                       {\r
+                               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));\r
+                               halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       // BT already NOT ignore Wlan active, do nothing here.\r
+               }\r
+#if(BT_AUTO_REPORT_ONLY_8812A_1ANT == 0)\r
+               if( (pCoexSta->btInfoExt & BIT4) )\r
+               {\r
+                       // BT auto report already enabled, do nothing\r
+               }\r
+               else\r
+               {\r
+                       halbtc8812a1ant_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_8812A_1ANT_B_INQ_PAGE)\r
+               pCoexSta->bC2hBtInquiryPage = TRUE;\r
+       else\r
+               pCoexSta->bC2hBtInquiryPage = FALSE;\r
+\r
+       // set link exist status\r
+       if(!(btInfo&BT_INFO_8812A_1ANT_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_8812A_1ANT_B_FTP)\r
+                       pCoexSta->bPanExist = TRUE;\r
+               else\r
+                       pCoexSta->bPanExist = FALSE;\r
+               if(btInfo & BT_INFO_8812A_1ANT_B_A2DP)\r
+                       pCoexSta->bA2dpExist = TRUE;\r
+               else\r
+                       pCoexSta->bA2dpExist = FALSE;\r
+               if(btInfo & BT_INFO_8812A_1ANT_B_HID)\r
+                       pCoexSta->bHidExist = TRUE;\r
+               else\r
+                       pCoexSta->bHidExist = FALSE;\r
+               if(btInfo & BT_INFO_8812A_1ANT_B_SCO_ESCO)\r
+                       pCoexSta->bScoExist = TRUE;\r
+               else\r
+                       pCoexSta->bScoExist = FALSE;\r
+       }\r
+\r
+       halbtc8812a1ant_UpdateBtLinkInfo(pBtCoexist);\r
+       \r
+       btInfo = btInfo & 0x1f;  //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41)\r
+       \r
+       if(!(btInfo&BT_INFO_8812A_1ANT_B_CONNECTION))\r
+       {\r
+               pCoexDm->btStatus = BT_8812A_1ANT_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_8812A_1ANT_B_CONNECTION)      // connection exists but no busy\r
+       {\r
+               pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"));\r
+       }\r
+       else if((btInfo&BT_INFO_8812A_1ANT_B_SCO_ESCO) ||\r
+               (btInfo&BT_INFO_8812A_1ANT_B_SCO_BUSY))\r
+       {\r
+               pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_SCO_BUSY;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"));\r
+       }\r
+       else if(btInfo&BT_INFO_8812A_1ANT_B_ACL_BUSY)\r
+       {\r
+               if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)\r
+                       pCoexDm->bAutoTdmaAdjust = FALSE;\r
+               pCoexDm->btStatus = BT_8812A_1ANT_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_8812A_1ANT_BT_STATUS_MAX;\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"));\r
+       }\r
+\r
+       if( (BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||\r
+               (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||\r
+               (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )\r
+               bBtBusy = TRUE;\r
+       else\r
+               bBtBusy = FALSE;\r
+       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);\r
+\r
+       halbtc8812a1ant_RunCoexistMechanism(pBtCoexist);\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_RfStatusNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                                  type\r
+       )\r
+{\r
+       u4Byte  u4Tmp;\r
+       u1Byte  u1Tmpa,u1Tmpb, u1Tmpc;\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF Status notify\n"));\r
+\r
+       if(BTC_RF_ON == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned ON!!\n"));\r
+               pBtCoexist->bStopCoexDm = FALSE;\r
+       }\r
+       else if(BTC_RF_OFF == type)\r
+       {\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned OFF!!\n"));\r
+               \r
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);\r
+               \r
+               halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);\r
+               pBtCoexist->bStopCoexDm = TRUE;\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_HaltNotify(\r
+       IN      PBTC_COEXIST                    pBtCoexist\r
+       )\r
+{\r
+       u4Byte  u4Tmp;\r
+       \r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n"));\r
+\r
+       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+       halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);\r
+       halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);\r
+\r
+       halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE);\r
+\r
+       EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);\r
+\r
+       pBtCoexist->bStopCoexDm = TRUE; \r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_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
+               halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+               halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);\r
+               halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE);\r
+               halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);\r
+\r
+               pBtCoexist->bStopCoexDm = TRUE;\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
+               pBtCoexist->bStopCoexDm = FALSE;\r
+               halbtc8812a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);\r
+               halbtc8812a1ant_InitCoexDm(pBtCoexist);\r
+               halbtc8812a1ant_QueryBtInfo(pBtCoexist);\r
+       }\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_CoexDmReset(\r
+       IN      PBTC_COEXIST                    pBtCoexist\r
+       )\r
+{\r
+       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], *****************Coex DM Reset*****************\n"));\r
+\r
+       halbtc8812a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE);\r
+       halbtc8812a1ant_InitCoexDm(pBtCoexist);\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_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(disVerInfoCnt <= 5)\r
+       {\r
+               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
+                       GLCoexVerDate8812a1Ant, GLCoexVer8812a1Ant, fwVer, btPatchVer, btPatchVer));\r
+               RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n"));\r
+       }\r
+\r
+#if(BT_AUTO_REPORT_ONLY_8812A_1ANT == 0)\r
+       halbtc8812a1ant_QueryBtInfo(pBtCoexist);\r
+       halbtc8812a1ant_MonitorBtEnableDisable(pBtCoexist);\r
+#else\r
+       halbtc8812a1ant_MonitorBtCtr(pBtCoexist);\r
+       halbtc8812a1ant_MonitorWiFiCtr(pBtCoexist);\r
+\r
+       if( halbtc8812a1ant_IsWifiStatusChanged(pBtCoexist) ||\r
+               pCoexDm->bAutoTdmaAdjust )\r
+       {\r
+               halbtc8812a1ant_RunCoexistMechanism(pBtCoexist);        \r
+       }\r
+\r
+       pCoexSta->specialPktPeriodCnt++;\r
+#endif\r
+}\r
+\r
+VOID\r
+EXhalbtc8812a1ant_DbgControl(\r
+       IN      PBTC_COEXIST                    pBtCoexist,\r
+       IN      u1Byte                          opCode,\r
+       IN      u1Byte                          opLen,\r
+       IN      pu1Byte                         pData\r
+       )\r
+{\r
+       switch(opCode)\r
+       {\r
+               case BTC_DBG_SET_COEX_NORMAL:\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set CoexMode to Normal\n"));\r
+                       pBtCoexist->bManualControl = FALSE;\r
+                       halbtc8812a1ant_InitCoexDm(pBtCoexist);\r
+                       break;\r
+               case BTC_DBG_SET_COEX_WIFI_ONLY:\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set CoexMode to Wifi Only\n"));\r
+                       pBtCoexist->bManualControl = TRUE;\r
+                       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);      \r
+                       break;\r
+               case BTC_DBG_SET_COEX_BT_ONLY:\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set CoexMode to BT only\n"));\r
+                       pBtCoexist->bManualControl = TRUE;\r
+                       halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);\r
+                       halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);      \r
+                       break;\r
+               case BTC_DBG_SET_COEX_DEC_BT_PWR:\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set Dec BT power\n"));\r
+                       {\r
+                               u1Byte  dataLen=4;\r
+                               u1Byte  buf[6] = {0};\r
+                               u1Byte  decBtPwr=0, pwrLevel=0;\r
+                               if(opLen == 2)\r
+                               {\r
+                                       decBtPwr = pData[0];\r
+                                       pwrLevel = pData[1];\r
+                               \r
+                                       buf[0] = dataLen;\r
+                                       buf[1] = 0x3;           // OP_Code\r
+                                       buf[2] = 0x2;           // OP_Code_Length\r
+                                       \r
+                                       buf[3] = decBtPwr;      // OP_Code_Content\r
+                                       buf[4] = pwrLevel;\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set Dec BT power=%d, pwrLevel=%d\n", decBtPwr, pwrLevel));\r
+                                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);      \r
+                               }\r
+                       }\r
+                       break;\r
+\r
+               case BTC_DBG_SET_COEX_BT_AFH_MAP:\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT AFH Map\n"));\r
+                       {\r
+                               u1Byte  dataLen=5;\r
+                               u1Byte  buf[6] = {0};\r
+                               if(opLen == 3)\r
+                               {\r
+                                       buf[0] = dataLen;\r
+                                       buf[1] = 0x5;                           // OP_Code\r
+                                       buf[2] = 0x3;                           // OP_Code_Length\r
+\r
+                                       buf[3] = pData[0];                      // OP_Code_Content\r
+                                       buf[4] = pData[1];\r
+                                       buf[5] = pData[2];\r
+\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT AFH Map = %02x %02x %02x\n", \r
+                                               pData[0], pData[1], pData[2]));\r
+                                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);\r
+                               }\r
+                       }\r
+                       break;\r
+               \r
+               case BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT:\r
+                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT Ignore Wlan Active\n"));\r
+                       {\r
+                               u1Byte  dataLen=3;\r
+                               u1Byte  buf[6] = {0};\r
+                               if(opLen == 1)\r
+                               {\r
+                                       buf[0] = dataLen;\r
+                                       buf[1] = 0x1;                   // OP_Code\r
+                                       buf[2] = 0x1;                   // OP_Code_Length\r
+\r
+                                       buf[3] = pData[0];              // OP_Code_Content\r
+                                       RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT Ignore Wlan Active = 0x%x\n", \r
+                                               pData[0]));\r
+                                               \r
+                                       pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);\r
+                               }\r
+                       }\r
+                       break;\r
+               default:\r
+                       break;\r
+       }\r
+}\r
+\r
+#endif\r
+\r