aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/rtl8821ae/btcoexist
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/rtl8821ae/btcoexist')
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.c3976
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.h205
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.c1614
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.h176
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbt_precomp.h99
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.c3891
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.h226
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c4118
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h160
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.c3780
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.h179
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c3892
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.h175
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c4200
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.h145
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c1130
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.h549
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/rtl_btc.c236
-rw-r--r--drivers/staging/rtl8821ae/btcoexist/rtl_btc.h66
19 files changed, 0 insertions, 28817 deletions
diff --git a/drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.c b/drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.c
deleted file mode 100644
index cf8c38292cd8..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.c
+++ /dev/null
@@ -1,3976 +0,0 @@
-//============================================================
-// Description:
-//
-// This file is for 8812a1ant Co-exist mechanism
-//
-// History
-// 2012/11/15 Cosa first check in.
-//
-//============================================================
-
-//============================================================
-// include files
-//============================================================
-#include "halbt_precomp.h"
-#if 1
-//============================================================
-// Global variables, these are static variables
-//============================================================
-static COEX_DM_8812A_1ANT GLCoexDm8812a1Ant;
-static PCOEX_DM_8812A_1ANT coex_dm=&GLCoexDm8812a1Ant;
-static COEX_STA_8812A_1ANT GLCoexSta8812a1Ant;
-static PCOEX_STA_8812A_1ANT coex_sta=&GLCoexSta8812a1Ant;
-
-const char *const GLBtInfoSrc8812a1Ant[]={
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-//============================================================
-// local function proto type if needed
-//============================================================
-//============================================================
-// local function start with halbtc8812a1ant_
-//============================================================
-#if 0
-void
-halbtc8812a1ant_Reg0x550Bit3(
- PBTC_COEXIST btcoexist,
- BOOLEAN bSet
- )
-{
- u1Byte u1tmp=0;
-
- u1tmp = btcoexist->btc_read_1byte(btcoexist, 0x550);
- if(bSet)
- {
- u1tmp |= BIT3;
- }
- else
- {
- u1tmp &= ~BIT3;
- }
- btcoexist->btc_write_1byte(btcoexist, 0x550, u1tmp);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], set 0x550[3]=%d\n", (bSet? 1:0)));
-}
-#endif
-u1Byte
-halbtc8812a1ant_BtRssiState(
- u1Byte level_num,
- u1Byte rssi_thresh,
- u1Byte rssi_thresh1
- )
-{
- s4Byte bt_rssi=0;
- u1Byte bt_rssi_state;
-
- bt_rssi = coex_sta->bt_rssi;
-
- if(level_num == 2)
- {
- if( (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW))
- {
- if(bt_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
- {
- bt_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
- }
- else
- {
- bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
- }
- }
- else
- {
- if(bt_rssi < rssi_thresh)
- {
- bt_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
- }
- else
- {
- bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
- }
- }
- }
- else if(level_num == 3)
- {
- if(rssi_thresh > rssi_thresh1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
- return coex_sta->pre_bt_rssi_state;
- }
-
- if( (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW))
- {
- if(bt_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
- {
- bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
- }
- else
- {
- bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
- }
- }
- else if( (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_MEDIUM))
- {
- if(bt_rssi >= (rssi_thresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
- {
- bt_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
- }
- else if(bt_rssi < rssi_thresh)
- {
- bt_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
- }
- else
- {
- bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
- }
- }
- else
- {
- if(bt_rssi < rssi_thresh1)
- {
- bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
- }
- else
- {
- bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
- }
- }
- }
-
- coex_sta->pre_bt_rssi_state = bt_rssi_state;
-
- return bt_rssi_state;
-}
-
-u1Byte
-halbtc8812a1ant_WifiRssiState(
- PBTC_COEXIST btcoexist,
- u1Byte index,
- u1Byte level_num,
- u1Byte rssi_thresh,
- u1Byte rssi_thresh1
- )
-{
- s4Byte wifi_rssi=0;
- u1Byte wifi_rssi_state;
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
-
- if(level_num == 2)
- {
- if( (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_STAY_LOW))
- {
- if(wifi_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
- {
- wifi_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
- }
- else
- {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
- }
- }
- else
- {
- if(wifi_rssi < rssi_thresh)
- {
- wifi_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
- }
- else
- {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
- }
- }
- }
- else if(level_num == 3)
- {
- if(rssi_thresh > rssi_thresh1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
- return coex_sta->pre_wifi_rssi_state[index];
- }
-
- if( (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_STAY_LOW))
- {
- if(wifi_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
- {
- wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
- }
- else
- {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
- }
- }
- else if( (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_STAY_MEDIUM))
- {
- if(wifi_rssi >= (rssi_thresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT))
- {
- wifi_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
- }
- else if(wifi_rssi < rssi_thresh)
- {
- wifi_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
- }
- else
- {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
- }
- }
- else
- {
- if(wifi_rssi < rssi_thresh1)
- {
- wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
- }
- else
- {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
- }
- }
- }
-
- coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
-
- return wifi_rssi_state;
-}
-
-void
-halbtc8812a1ant_MonitorBtEnableDisable(
- PBTC_COEXIST btcoexist
- )
-{
- static BOOLEAN pre_bt_disabled=false;
- static u4Byte bt_disable_cnt=0;
- BOOLEAN bt_active=true, bt_disable_by68=false, bt_disabled=false;
- u4Byte u4_tmp=0;
-
- // This function check if bt is disabled
-
- if( coex_sta->high_priority_tx == 0 &&
- coex_sta->high_priority_rx == 0 &&
- coex_sta->low_priority_tx == 0 &&
- coex_sta->low_priority_rx == 0)
- {
- bt_active = false;
- }
- if( coex_sta->high_priority_tx == 0xffff &&
- coex_sta->high_priority_rx == 0xffff &&
- coex_sta->low_priority_tx == 0xffff &&
- coex_sta->low_priority_rx == 0xffff)
- {
- bt_active = false;
- }
- if(bt_active)
- {
- bt_disable_cnt = 0;
- bt_disabled = false;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
- }
- else
- {
- bt_disable_cnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
- bt_disable_cnt));
- if(bt_disable_cnt >= 2 ||bt_disable_by68)
- {
- bt_disabled = true;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
- }
- }
- if(pre_bt_disabled != bt_disabled)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
- (pre_bt_disabled ? "disabled":"enabled"),
- (bt_disabled ? "disabled":"enabled")));
- pre_bt_disabled = bt_disabled;
- if(!bt_disabled)
- {
- }
- else
- {
- }
- }
-}
-
-void
-halbtc8812a1ant_MonitorBtCtr(
- PBTC_COEXIST btcoexist
- )
-{
- u4Byte reg_hp_tx_rx, reg_lp_tx_rx, u4_tmp;
- u4Byte reg_hp_tx=0, reg_hp_rx=0, reg_lp_tx=0, reg_lp_rx=0;
- u1Byte u1_tmp;
-
- reg_hp_tx_rx = 0x770;
- reg_lp_tx_rx = 0x774;
-
- u4_tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_tx_rx);
- reg_hp_tx = u4_tmp & bMaskLWord;
- reg_hp_rx = (u4_tmp & bMaskHWord)>>16;
-
- u4_tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_tx_rx);
- reg_lp_tx = u4_tmp & bMaskLWord;
- reg_lp_rx = (u4_tmp & bMaskHWord)>>16;
-
- coex_sta->high_priority_tx = reg_hp_tx;
- coex_sta->high_priority_rx = reg_hp_rx;
- coex_sta->low_priority_tx = reg_lp_tx;
- coex_sta->low_priority_rx = reg_lp_rx;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=%x(%d)/%x(%d)\n",
- reg_hp_tx_rx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=%x(%d)/%x(%d)\n",
- reg_lp_tx_rx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx));
-
- // reset counter
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
-}
-
-void
-halbtc8812a1ant_QueryBtInfo(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte dataLen=3;
- u1Byte buf[5] = {0};
- static u4Byte btInfoCnt=0;
-
- if(!btInfoCnt ||
- (coex_sta->bt_info_c2h_cnt[BT_INFO_SRC_8812A_1ANT_BT_RSP]-btInfoCnt)>2)
- {
- buf[0] = dataLen;
- buf[1] = 0x1; // polling enable, 1=enable, 0=disable
- buf[2] = 0x2; // polling time in seconds
- buf[3] = 0x1; // auto report enable, 1=enable, 0=disable
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_INFO, (PVOID)&buf[0]);
- }
- btInfoCnt = coex_sta->bt_info_c2h_cnt[BT_INFO_SRC_8812A_1ANT_BT_RSP];
-}
-u1Byte
-halbtc8812a1ant_ActionAlgorithm(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN bt_hs_on=false;
- u1Byte algorithm=BT_8812A_1ANT_COEX_ALGO_UNDEFINED;
- u1Byte num_of_diff_profile=0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
- if(!stack_info->bt_link_exist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No profile exists!!!\n"));
- return algorithm;
- }
-
- if(stack_info->sco_exist)
- num_of_diff_profile++;
- if(stack_info->hid_exist)
- num_of_diff_profile++;
- if(stack_info->pan_exist)
- num_of_diff_profile++;
- if(stack_info->a2dp_exist)
- num_of_diff_profile++;
-
- if(num_of_diff_profile == 1)
- {
- if(stack_info->sco_exist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
- }
- else
- {
- if(stack_info->hid_exist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID;
- }
- else if(stack_info->a2dp_exist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP;
- }
- else if(stack_info->pan_exist)
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANHS;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR;
- }
- }
- }
- }
- else if(num_of_diff_profile == 2)
- {
- if(stack_info->sco_exist)
- {
- if(stack_info->hid_exist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID;
- }
- else if(stack_info->a2dp_exist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
- }
- else if(stack_info->pan_exist)
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- else
- {
- if( stack_info->hid_exist &&
- stack_info->a2dp_exist )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
- }
- else if( stack_info->hid_exist &&
- stack_info->pan_exist )
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- else if( stack_info->pan_exist &&
- stack_info->a2dp_exist )
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP;
- }
- }
- }
- }
- else if(num_of_diff_profile == 3)
- {
- if(stack_info->sco_exist)
- {
- if( stack_info->hid_exist &&
- stack_info->a2dp_exist )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID;
- }
- else if( stack_info->hid_exist &&
- stack_info->pan_exist )
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- else if( stack_info->pan_exist &&
- stack_info->a2dp_exist )
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_SCO;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- else
- {
- if( stack_info->hid_exist &&
- stack_info->pan_exist &&
- stack_info->a2dp_exist )
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
- }
- }
- }
- }
- else if(num_of_diff_profile >= 3)
- {
- if(stack_info->sco_exist)
- {
- if( stack_info->hid_exist &&
- stack_info->pan_exist &&
- stack_info->a2dp_exist )
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
-
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
- algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- }
-
- return algorithm;
-}
-
-BOOLEAN
-halbtc8812a1ant_NeedToDecBtPwr(
- PBTC_COEXIST btcoexist
- )
-{
- BOOLEAN ret=false;
- BOOLEAN bt_hs_on=false, wifi_connected=false;
- s4Byte bt_hs_rssi=0;
-
- if(!btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on))
- return false;
- if(!btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected))
- return false;
- if(!btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi))
- return false;
-
- if(wifi_connected)
- {
- if(bt_hs_on)
- {
- if(bt_hs_rssi > 37)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], Need to decrease bt power for HS mode!!\n"));
- ret = true;
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], Need to decrease bt power for Wifi is connected!!\n"));
- ret = true;
- }
- }
-
- return ret;
-}
-
-void
-halbtc8812a1ant_SetFwDacSwingLevel(
- PBTC_COEXIST btcoexist,
- u1Byte dac_swing_lvl
- )
-{
- u1Byte h2c_parameter[1] ={0};
-
- // There are several type of dacswing
- // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
- h2c_parameter[0] = dac_swing_lvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level=0x%x\n", dac_swing_lvl));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x64=0x%x\n", h2c_parameter[0]));
-
- btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
-}
-
-void
-halbtc8812a1ant_SetFwDecBtPwr(
- PBTC_COEXIST btcoexist,
- BOOLEAN dec_bt_pwr
- )
-{
- u1Byte dataLen=3;
- u1Byte buf[5] = {0};
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power : %s\n",
- (dec_bt_pwr? "Yes!!":"No!!")));
-
- buf[0] = dataLen;
- buf[1] = 0x3; // OP_Code
- buf[2] = 0x1; // OP_Code_Length
- if(dec_bt_pwr)
- buf[3] = 0x1; // OP_Code_Content
- else
- buf[3] = 0x0;
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
-}
-
-void
-halbtc8812a1ant_DecBtPwr(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN dec_bt_pwr
- )
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power = %s\n",
- (force_exec? "force to":""), ((dec_bt_pwr)? "ON":"OFF")));
- coex_dm->cur_dec_bt_pwr = dec_bt_pwr;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_dec_bt_pwr=%d, cur_dec_bt_pwr=%d\n",
- coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr));
-
- if(coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr)
- return;
- }
- halbtc8812a1ant_SetFwDecBtPwr(btcoexist, coex_dm->cur_dec_bt_pwr);
-
- coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr;
-}
-
-void
-halbtc8812a1ant_SetFwBtLnaConstrain(
- PBTC_COEXIST btcoexist,
- BOOLEAN bt_lna_cons_on
- )
-{
- u1Byte dataLen=3;
- u1Byte buf[5] = {0};
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT LNA Constrain: %s\n",
- (bt_lna_cons_on? "ON!!":"OFF!!")));
-
- buf[0] = dataLen;
- buf[1] = 0x2; // OP_Code
- buf[2] = 0x1; // OP_Code_Length
- if(bt_lna_cons_on)
- buf[3] = 0x1; // OP_Code_Content
- else
- buf[3] = 0x0;
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
-}
-
-void
-halbtc8812a1ant_SetBtLnaConstrain(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN bt_lna_cons_on
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Constrain = %s\n",
- (force_exec? "force":""), ((bt_lna_cons_on)? "ON":"OFF")));
- coex_dm->bCurBtLnaConstrain = bt_lna_cons_on;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtLnaConstrain=%d, bCurBtLnaConstrain=%d\n",
- coex_dm->bPreBtLnaConstrain, coex_dm->bCurBtLnaConstrain));
-
- if(coex_dm->bPreBtLnaConstrain == coex_dm->bCurBtLnaConstrain)
- return;
- }
- halbtc8812a1ant_SetFwBtLnaConstrain(btcoexist, coex_dm->bCurBtLnaConstrain);
-
- coex_dm->bPreBtLnaConstrain = coex_dm->bCurBtLnaConstrain;
-}
-
-void
-halbtc8812a1ant_SetFwBtPsdMode(
- PBTC_COEXIST btcoexist,
- u1Byte bt_psd_mode
- )
-{
- u1Byte dataLen=3;
- u1Byte buf[5] = {0};
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT PSD mode=0x%x\n",
- bt_psd_mode));
-
- buf[0] = dataLen;
- buf[1] = 0x4; // OP_Code
- buf[2] = 0x1; // OP_Code_Length
- buf[3] = bt_psd_mode; // OP_Code_Content
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
-}
-
-
-void
-halbtc8812a1ant_SetBtPsdMode(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- u1Byte bt_psd_mode
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT PSD mode = 0x%x\n",
- (force_exec? "force":""), bt_psd_mode));
- coex_dm->bCurBtPsdMode = bt_psd_mode;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtPsdMode=0x%x, bCurBtPsdMode=0x%x\n",
- coex_dm->bPreBtPsdMode, coex_dm->bCurBtPsdMode));
-
- if(coex_dm->bPreBtPsdMode == coex_dm->bCurBtPsdMode)
- return;
- }
- halbtc8812a1ant_SetFwBtPsdMode(btcoexist, coex_dm->bCurBtPsdMode);
-
- coex_dm->bPreBtPsdMode = coex_dm->bCurBtPsdMode;
-}
-
-
-void
-halbtc8812a1ant_SetBtAutoReport(
- PBTC_COEXIST btcoexist,
- BOOLEAN enable_auto_report
- )
-{
-#if 0
- u1Byte h2c_parameter[1] ={0};
-
- h2c_parameter[0] = 0;
-
- if(enable_auto_report)
- {
- h2c_parameter[0] |= BIT0;
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
- (enable_auto_report? "Enabled!!":"Disabled!!"), h2c_parameter[0]));
-
- btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
-#else
-
-#endif
-}
-
-void
-halbtc8812a1ant_BtAutoReport(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN enable_auto_report
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
- (force_exec? "force to":""), ((enable_auto_report)? "Enabled":"Disabled")));
- coex_dm->cur_bt_auto_report = enable_auto_report;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_bt_auto_report=%d, cur_bt_auto_report=%d\n",
- coex_dm->pre_bt_auto_report, coex_dm->cur_bt_auto_report));
-
- if(coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report)
- return;
- }
- halbtc8812a1ant_SetBtAutoReport(btcoexist, coex_dm->cur_bt_auto_report);
-
- coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
-}
-
-void
-halbtc8812a1ant_FwDacSwingLvl(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- u1Byte fw_dac_swing_lvl
- )
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n",
- (force_exec? "force to":""), fw_dac_swing_lvl));
- coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_fw_dac_swing_lvl=%d, cur_fw_dac_swing_lvl=%d\n",
- coex_dm->pre_fw_dac_swing_lvl, coex_dm->cur_fw_dac_swing_lvl));
-
- if(coex_dm->pre_fw_dac_swing_lvl == coex_dm->cur_fw_dac_swing_lvl)
- return;
- }
-
- halbtc8812a1ant_SetFwDacSwingLevel(btcoexist, coex_dm->cur_fw_dac_swing_lvl);
-
- coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
-}
-
-void
-halbtc8812a1ant_SetSwRfRxLpfCorner(
- PBTC_COEXIST btcoexist,
- BOOLEAN rx_rf_shrink_on
- )
-{
- if(rx_rf_shrink_on)
- {
- //Shrink RF Rx LPF corner
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
- }
- else
- {
- //Resume RF Rx LPF corner
- // After initialized, we can use coex_dm->bt_rf0x1e_backup
- if(btcoexist->bInitilized)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff, coex_dm->bt_rf0x1e_backup);
- }
- }
-}
-
-void
-halbtc8812a1ant_RfShrink(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN rx_rf_shrink_on
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
- (force_exec? "force to":""), ((rx_rf_shrink_on)? "ON":"OFF")));
- coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], pre_rf_rx_lpf_shrink=%d, cur_rf_rx_lpf_shrink=%d\n",
- coex_dm->pre_rf_rx_lpf_shrink, coex_dm->cur_rf_rx_lpf_shrink));
-
- if(coex_dm->pre_rf_rx_lpf_shrink == coex_dm->cur_rf_rx_lpf_shrink)
- return;
- }
- halbtc8812a1ant_SetSwRfRxLpfCorner(btcoexist, coex_dm->cur_rf_rx_lpf_shrink);
-
- coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink;
-}
-
-void
-halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(
- PBTC_COEXIST btcoexist,
- BOOLEAN low_penalty_ra
- )
-{
- u1Byte u1_tmp;
-
- u1_tmp = btcoexist->btc_read_1byte(btcoexist, 0x4fd);
- u1_tmp |= BIT0;
- if(low_penalty_ra)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
- u1_tmp &= ~BIT2;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
- u1_tmp |= BIT2;
- }
-
- btcoexist->btc_write_1byte(btcoexist, 0x4fd, u1_tmp);
-}
-
-void
-halbtc8812a1ant_LowPenaltyRa(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN low_penalty_ra
- )
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
- (force_exec? "force to":""), ((low_penalty_ra)? "ON":"OFF")));
- coex_dm->cur_low_penalty_ra = low_penalty_ra;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], pre_low_penalty_ra=%d, cur_low_penalty_ra=%d\n",
- coex_dm->pre_low_penalty_ra, coex_dm->cur_low_penalty_ra));
-
- if(coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
- return;
- }
- halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(btcoexist, coex_dm->cur_low_penalty_ra);
-
- coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
-}
-
-void
-halbtc8812a1ant_SetDacSwingReg(
- PBTC_COEXIST btcoexist,
- u4Byte level
- )
-{
- u1Byte val=(u1Byte)level;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc5b, 0x3e, val);
-}
-
-void
-halbtc8812a1ant_SetSwFullTimeDacSwing(
- PBTC_COEXIST btcoexist,
- BOOLEAN sw_dac_swing_on,
- u4Byte sw_dac_swing_lvl
- )
-{
- if(sw_dac_swing_on)
- {
- halbtc8812a1ant_SetDacSwingReg(btcoexist, sw_dac_swing_lvl);
- }
- else
- {
- halbtc8812a1ant_SetDacSwingReg(btcoexist, 0x18);
- }
-}
-
-
-void
-halbtc8812a1ant_DacSwing(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN dac_swing_on,
- u4Byte dac_swing_lvl
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dac_swing_lvl=0x%x\n",
- (force_exec? "force to":""), ((dac_swing_on)? "ON":"OFF"), dac_swing_lvl));
- coex_dm->cur_dac_swing_on = dac_swing_on;
- coex_dm->cur_dac_swing_lvl = dac_swing_lvl;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], pre_dac_swing_on=%d, pre_dac_swing_lvl=0x%x, cur_dac_swing_on=%d, cur_dac_swing_lvl=0x%x\n",
- coex_dm->pre_dac_swing_on, coex_dm->pre_dac_swing_lvl,
- coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl));
-
- if( (coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) &&
- (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl) )
- return;
- }
- delay_ms(30);
- halbtc8812a1ant_SetSwFullTimeDacSwing(btcoexist, dac_swing_on, dac_swing_lvl);
-
- coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on;
- coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
-}
-
-void
-halbtc8812a1ant_SetAdcBackOff(
- PBTC_COEXIST btcoexist,
- BOOLEAN adc_back_off
- )
-{
- if(adc_back_off)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level On!\n"));
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x3);
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level Off!\n"));
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x1);
- }
-}
-
-void
-halbtc8812a1ant_AdcBackOff(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN adc_back_off
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn AdcBackOff = %s\n",
- (force_exec? "force to":""), ((adc_back_off)? "ON":"OFF")));
- coex_dm->cur_adc_back_off = adc_back_off;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], pre_adc_back_off=%d, cur_adc_back_off=%d\n",
- coex_dm->pre_adc_back_off, coex_dm->cur_adc_back_off));
-
- if(coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off)
- return;
- }
- halbtc8812a1ant_SetAdcBackOff(btcoexist, coex_dm->cur_adc_back_off);
-
- coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off;
-}
-
-void
-halbtc8812a1ant_SetAgcTable(
- PBTC_COEXIST btcoexist,
- BOOLEAN agc_table_en
- )
-{
- u1Byte rssi_adjust_val=0;
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
- if(agc_table_en)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff, 0x3fa58);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff, 0x37a58);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff, 0x2fa58);
- rssi_adjust_val = 8;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff, 0x39258);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff, 0x31258);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, 0xfffff, 0x29258);
- }
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
-
- // set rssi_adjust_val for wifi module.
- btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssi_adjust_val);
-}
-
-
-void
-halbtc8812a1ant_AgcTable(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN agc_table_en
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n",
- (force_exec? "force to":""), ((agc_table_en)? "Enable":"Disable")));
- coex_dm->cur_agc_table_en = agc_table_en;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], pre_agc_table_en=%d, cur_agc_table_en=%d\n",
- coex_dm->pre_agc_table_en, coex_dm->cur_agc_table_en));
-
- if(coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en)
- return;
- }
- halbtc8812a1ant_SetAgcTable(btcoexist, agc_table_en);
-
- coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en;
-}
-
-void
-halbtc8812a1ant_SetCoexTable(
- PBTC_COEXIST btcoexist,
- u4Byte val0x6c0,
- u4Byte val0x6c4,
- u4Byte val0x6c8,
- u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
- btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
- btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
- btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
- btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
-}
-
-void
-halbtc8812a1ant_CoexTable(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- u4Byte val0x6c0,
- u4Byte val0x6c4,
- u4Byte val0x6c8,
- u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
- (force_exec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
- coex_dm->cur_val0x6c0 = val0x6c0;
- coex_dm->cur_val0x6c4 = val0x6c4;
- coex_dm->cur_val0x6c8 = val0x6c8;
- coex_dm->cur_val0x6cc = val0x6cc;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], pre_val0x6c0=0x%x, pre_val0x6c4=0x%x, pre_val0x6c8=0x%x, pre_val0x6cc=0x%x !!\n",
- coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4, coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], cur_val0x6c0=0x%x, cur_val0x6c4=0x%x, cur_val0x6c8=0x%x, cur_val0x6cc=0x%x !!\n",
- coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4, coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc));
-
- if( (coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
- (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
- (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
- (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc) )
- return;
- }
- halbtc8812a1ant_SetCoexTable(btcoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
-
- coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
- coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
- coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
- coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
-}
-
-void
-halbtc8812a1ant_SetFwIgnoreWlanAct(
- PBTC_COEXIST btcoexist,
- BOOLEAN enable
- )
-{
- u1Byte dataLen=3;
- u1Byte buf[5] = {0};
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], %s BT Ignore Wlan_Act\n",
- (enable? "Enable":"Disable")));
-
- buf[0] = dataLen;
- buf[1] = 0x1; // OP_Code
- buf[2] = 0x1; // OP_Code_Length
- if(enable)
- buf[3] = 0x1; // OP_Code_Content
- else
- buf[3] = 0x0;
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
-}
-
-void
-halbtc8812a1ant_IgnoreWlanAct(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN enable
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
- (force_exec? "force to":""), (enable? "ON":"OFF")));
- coex_dm->cur_ignore_wlan_act = enable;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n",
- coex_dm->pre_ignore_wlan_act, coex_dm->cur_ignore_wlan_act));
-
- if(coex_dm->pre_ignore_wlan_act == coex_dm->cur_ignore_wlan_act)
- return;
- }
- halbtc8812a1ant_SetFwIgnoreWlanAct(btcoexist, enable);
-
- coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
-}
-
-void
-halbtc8812a1ant_SetFwPstdma(
- PBTC_COEXIST btcoexist,
- u1Byte byte1,
- u1Byte byte2,
- u1Byte byte3,
- u1Byte byte4,
- u1Byte byte5
- )
-{
- u1Byte h2c_parameter[5] ={0};
-
- h2c_parameter[0] = byte1;
- h2c_parameter[1] = byte2;
- h2c_parameter[2] = byte3;
- h2c_parameter[3] = byte4;
- h2c_parameter[4] = byte5;
-
- coex_dm->ps_tdma_para[0] = byte1;
- coex_dm->ps_tdma_para[1] = byte2;
- coex_dm->ps_tdma_para[2] = byte3;
- coex_dm->ps_tdma_para[3] = byte4;
- coex_dm->ps_tdma_para[4] = byte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
- h2c_parameter[0],
- h2c_parameter[1]<<24|h2c_parameter[2]<<16|h2c_parameter[3]<<8|h2c_parameter[4]));
-
- btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
-}
-
-void
-halbtc8812a1ant_SetLpsRpwm(
- PBTC_COEXIST btcoexist,
- u1Byte lps_val,
- u1Byte rpwm_val
- )
-{
- u1Byte lps=lps_val;
- u1Byte rpwm=rpwm_val;
-
- btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_LPS, &lps);
- btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_RPWM, &rpwm);
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT, NULL);
-}
-
-void
-halbtc8812a1ant_LpsRpwm(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- u1Byte lps_val,
- u1Byte rpwm_val
- )
-{
- BOOLEAN bForceExecPwrCmd=false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
- (force_exec? "force to":""), lps_val, rpwm_val));
- coex_dm->cur_lps = lps_val;
- coex_dm->cur_rpwm = rpwm_val;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_lps/cur_lps=0x%x/0x%x, pre_rpwm/cur_rpwm=0x%x/0x%x!!\n",
- coex_dm->pre_lps, coex_dm->cur_lps, coex_dm->pre_rpwm, coex_dm->cur_rpwm));
-
- if( (coex_dm->pre_lps == coex_dm->cur_lps) &&
- (coex_dm->pre_rpwm == coex_dm->cur_rpwm) )
- {
- return;
- }
- }
- halbtc8812a1ant_SetLpsRpwm(btcoexist, lps_val, rpwm_val);
-
- coex_dm->pre_lps = coex_dm->cur_lps;
- coex_dm->pre_rpwm = coex_dm->cur_rpwm;
-}
-
-void
-halbtc8812a1ant_SwMechanism1(
- PBTC_COEXIST btcoexist,
- BOOLEAN shrink_rx_lpf,
- BOOLEAN low_penalty_ra,
- BOOLEAN limited_dig,
- BOOLEAN bt_lna_constrain
- )
-{
- //halbtc8812a1ant_RfShrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf);
- //halbtc8812a1ant_LowPenaltyRa(btcoexist, NORMAL_EXEC, low_penalty_ra);
-
- //no limited DIG
- //halbtc8812a1ant_SetBtLnaConstrain(btcoexist, NORMAL_EXEC, bt_lna_constrain);
-}
-
-void
-halbtc8812a1ant_SwMechanism2(
- PBTC_COEXIST btcoexist,
- BOOLEAN agc_table_shift,
- BOOLEAN adc_back_off,
- BOOLEAN sw_dac_swing,
- u4Byte dac_swing_lvl
- )
-{
- //halbtc8812a1ant_AgcTable(btcoexist, NORMAL_EXEC, agc_table_shift);
- //halbtc8812a1ant_AdcBackOff(btcoexist, NORMAL_EXEC, adc_back_off);
- //halbtc8812a1ant_DacSwing(btcoexist, NORMAL_EXEC, sw_dac_swing, dac_swing_lvl);
-}
-
-void
-halbtc8812a1ant_PsTdma(
- PBTC_COEXIST btcoexist,
- BOOLEAN force_exec,
- BOOLEAN turn_on,
- u1Byte type
- )
-{
- BOOLEAN bTurnOnByCnt=false;
- u1Byte psTdmaTypeByCnt=0, rssi_adjust_val=0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
- (force_exec? "force to":""), (turn_on? "ON":"OFF"), type));
- coex_dm->cur_ps_tdma_on = turn_on;
- coex_dm->cur_ps_tdma = type;
-
- if(!force_exec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_ps_tdma_on = %d, cur_ps_tdma_on = %d!!\n",
- coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], pre_ps_tdma = %d, cur_ps_tdma = %d!!\n",
- coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma));
-
- if( (coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
- (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma) )
- return;
- }
- if(turn_on)
- {
- switch(type)
- {
- default:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x58);
- break;
- case 1:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x48);
- rssi_adjust_val = 11;
- break;
- case 2:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x12, 0x12, 0x0, 0x48);
- rssi_adjust_val = 14;
- break;
- case 3:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x25, 0x3, 0x10, 0x40);
- break;
- case 4:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
- rssi_adjust_val = 17;
- break;
- case 5:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x61, 0x15, 0x3, 0x31, 0x0);
- break;
- case 6:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x13, 0xa, 0x3, 0x0, 0x0);
- break;
- case 7:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
- break;
- case 8:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
- break;
- case 9:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0xa, 0xa, 0x0, 0x48);
- rssi_adjust_val = 18;
- break;
- case 10:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
- break;
- case 11:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x5, 0x5, 0x0, 0x48);
- rssi_adjust_val = 20;
- break;
- case 12:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xeb, 0xa, 0x3, 0x31, 0x18);
- break;
-
- case 15:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
- break;
- case 16:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
- rssi_adjust_val = 18;
- break;
-
- case 18:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
- rssi_adjust_val = 14;
- break;
-
- case 20:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x13, 0x25, 0x25, 0x0, 0x0);
- break;
- case 21:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x20, 0x3, 0x10, 0x40);
- break;
- case 22:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x13, 0x8, 0x8, 0x0, 0x40);
- break;
- case 23:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 24:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 25:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 26:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 27:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
- rssi_adjust_val = 22;
- break;
- case 28:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
- break;
- case 29:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xab, 0x1a, 0x1a, 0x1, 0x8);
- break;
- case 30:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
- break;
- case 31:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
- break;
- case 32:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xab, 0xa, 0x3, 0x31, 0x88);
- break;
- case 33:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xa3, 0x25, 0x3, 0x30, 0x88);
- break;
- case 34:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x8);
- break;
- case 35:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xe3, 0x1a, 0x1a, 0x0, 0x8);
- break;
- case 36:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0xd3, 0x12, 0x3, 0x14, 0x58);
- break;
- }
- }
- else
- {
- // disable PS tdma
- switch(type)
- {
- case 8:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x4);
- break;
- case 0:
- default:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
- delay_ms(5);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x20);
- break;
- case 9:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x4);
- break;
- case 10:
- halbtc8812a1ant_SetFwPstdma(btcoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
- delay_ms(5);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x20);
- break;
- }
- }
- rssi_adjust_val =0;
- btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssi_adjust_val);
-
- // update pre state
- coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
- coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
-}
-
-void
-halbtc8812a1ant_CoexAllOff(
- PBTC_COEXIST btcoexist
- )
-{
- // fw all off
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- // sw all off
- halbtc8812a1ant_SwMechanism1(btcoexist,false,false,false,false);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
-
- // hw all off
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
-}
-
-void
-halbtc8812a1ant_WifiParaAdjust(
- PBTC_COEXIST btcoexist,
- BOOLEAN enable
- )
-{
- if(enable)
- {
- halbtc8812a1ant_LowPenaltyRa(btcoexist, NORMAL_EXEC, true);
- }
- else
- {
- halbtc8812a1ant_LowPenaltyRa(btcoexist, NORMAL_EXEC, false);
- }
-}
-
-BOOLEAN
-halbtc8812a1ant_IsCommonAction(
- PBTC_COEXIST btcoexist
- )
-{
- BOOLEAN common=false, wifi_connected=false, wifi_busy=false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
- //halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
-
- if(!wifi_connected &&
- BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8812a1ant_SwMechanism1(btcoexist,false,false,false,false);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
- common = true;
- }
- else if(wifi_connected &&
- (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
-
- halbtc8812a1ant_SwMechanism1(btcoexist,false,false,false,false);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
- common = true;
- }
- else if(!wifi_connected &&
- (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8812a1ant_SwMechanism1(btcoexist,false,false,false,false);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
- common = true;
- }
- else if(wifi_connected &&
- (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8812a1ant_SwMechanism1(btcoexist,true,true,true,true);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
- common = true;
- }
- else if(!wifi_connected &&
- (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE != coex_dm->bt_status) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8812a1ant_SwMechanism1(btcoexist,false,false,false,false);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
- common = true;
- }
- else
- {
- halbtc8812a1ant_SwMechanism1(btcoexist,true,true,true,true);
-
- common = false;
- }
-
- return common;
-}
-
-
-void
-halbtc8812a1ant_TdmaDurationAdjustForAcl(
- PBTC_COEXIST btcoexist
- )
-{
- static s4Byte up,dn,m,n,wait_count;
- s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
- u1Byte retry_count=0, bt_info_ext;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], halbtc8812a1ant_TdmaDurationAdjustForAcl()\n"));
- if(coex_dm->reset_tdma_adjust)
- {
- coex_dm->reset_tdma_adjust = false;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
-
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- //============
- up = 0;
- dn = 0;
- m = 1;
- n= 3;
- result = 0;
- wait_count = 0;
- }
- else
- {
- //acquire the BT TRx retry count from BT_Info byte2
- retry_count = coex_sta->bt_retry_cnt;
- bt_info_ext = coex_sta->bt_info_ext;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retry_count = %d\n", retry_count));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, wait_count=%d\n",
- up, dn, m, n, wait_count));
- result = 0;
- wait_count++;
-
- if(retry_count == 0) // no retry in the last 2-second duration
- {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if(up >= n) // Google translated: if consecutive n-2 seconds retry count is 0, width-modulated WiFi duration
- {
- wait_count = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
- }
- }
- else if (retry_count <= 3) // <=3 retry in the last 2-second duration
- {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) // Google translated: if 2 consecutive two seconds retry count <3, then tune narrow WiFi duration
- {
- if (wait_count <= 2)
- m++; // Google translated: Avoid been back and forth in the two level
- else
- m = 1;
-
- if ( m >= 20) // Google translated: m max = 20 'Max 120 seconds recheck whether to adjust WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- wait_count = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
- }
- }
- else // Google translated: retry count> 3, as long as a second retry count> 3, then tune narrow WiFi duration
- {
- if (wait_count == 1)
- m++; // Google translated: Avoid been back and forth in the two level
- else
- m = 1;
-
- if ( m >= 20) // Google translated: m max = 20 'Max 120 seconds recheck whether to adjust WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- wait_count = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
- }
-
- if(result == -1)
- {
- if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(bt_info_ext)) &&
- ((coex_dm->cur_ps_tdma == 1) ||(coex_dm->cur_ps_tdma == 2)) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- }
- else if(coex_dm->cur_ps_tdma == 1)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- }
- else if(coex_dm->cur_ps_tdma == 2)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- }
- else if(coex_dm->cur_ps_tdma == 9)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- }
- }
- else if(result == 1)
- {
- if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(bt_info_ext)) &&
- ((coex_dm->cur_ps_tdma == 1) ||(coex_dm->cur_ps_tdma == 2)) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- }
- else if(coex_dm->cur_ps_tdma == 11)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- }
- else if(coex_dm->cur_ps_tdma == 9)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- }
- else if(coex_dm->cur_ps_tdma == 2)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 1);
- coex_dm->ps_tdma_du_adj_type = 1;
- }
- }
-
- if( coex_dm->cur_ps_tdma != 1 &&
- coex_dm->cur_ps_tdma != 2 &&
- coex_dm->cur_ps_tdma != 9 &&
- coex_dm->cur_ps_tdma != 11 )
- {
- // recover to previous adjust type
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, coex_dm->ps_tdma_du_adj_type);
- }
- }
-}
-
-u1Byte
-halbtc8812a1ant_PsTdmaTypeByWifiRssi(
- s4Byte wifi_rssi,
- s4Byte pre_wifi_rssi,
- u1Byte wifi_rssi_thresh
- )
-{
- u1Byte ps_tdma_type=0;
-
- if(wifi_rssi > pre_wifi_rssi)
- {
- if(wifi_rssi > (wifi_rssi_thresh+5))
- {
- ps_tdma_type = 26;
- }
- else
- {
- ps_tdma_type = 25;
- }
- }
- else
- {
- if(wifi_rssi > wifi_rssi_thresh)
- {
- ps_tdma_type = 26;
- }
- else
- {
- ps_tdma_type = 25;
- }
- }
-
- return ps_tdma_type;
-}
-
-void
-halbtc8812a1ant_PsTdmaCheckForPowerSaveState(
- PBTC_COEXIST btcoexist,
- BOOLEAN new_ps_state
- )
-{
- u1Byte lps_mode=0x0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode);
-
- if(lps_mode) // already under LPS state
- {
- if(new_ps_state)
- {
- // keep state under LPS, do nothing.
- }
- else
- {
- // will leave LPS state, turn off psTdma first
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 0);
- }
- }
- else // NO PS state
- {
- if(new_ps_state)
- {
- // will enter LPS state, turn off psTdma first
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 0);
- }
- else
- {
- // keep state under NO PS state, do nothing.
- }
- }
-}
-
-// SCO only or SCO+PAN(HS)
-void
-halbtc8812a1ant_ActionSco(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state;
- u4Byte wifi_bw;
-
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 4);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-
-void
-halbtc8812a1ant_ActionHid(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state;
- u4Byte wifi_bw;
-
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,false,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-//A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
-void
-halbtc8812a1ant_ActionA2dp(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state;
- u4Byte wifi_bw;
-
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-void
-halbtc8812a1ant_ActionA2dpPanHs(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u4Byte wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-void
-halbtc8812a1ant_ActionPanEdr(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state;
- u4Byte wifi_bw;
-
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-
-//PAN(HS) only
-void
-halbtc8812a1ant_ActionPanHs(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state;
- u4Byte wifi_bw;
-
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // fw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- }
- else
- {
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
- }
-
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // fw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- }
- else
- {
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
- }
-
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-//PAN(EDR)+A2DP
-void
-halbtc8812a1ant_ActionPanEdrA2dp(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u4Byte wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-void
-halbtc8812a1ant_ActionPanEdrHid(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state;
- u4Byte wifi_bw;
-
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-// HID+A2DP+PAN(EDR)
-void
-halbtc8812a1ant_ActionHidA2dpPanEdr(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u4Byte wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, NORMAL_EXEC, 6);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-void
-halbtc8812a1ant_ActionHidA2dp(
- PBTC_COEXIST btcoexist
- )
-{
- u1Byte wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u4Byte wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8812a1ant_WifiRssiState(btcoexist, 0, 2, 25, 0);
- bt_rssi_state = halbtc8812a1ant_BtRssiState(2, 50, 0);
-
- if(halbtc8812a1ant_NeedToDecBtPwr(btcoexist))
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8812a1ant_DecBtPwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,true,false,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,true,true,false,0x18);
- }
- else
- {
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
- }
- }
-}
-
-void
-halbtc8812a1ant_ActionHs(
- PBTC_COEXIST btcoexist,
- BOOLEAN hs_connecting
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action for HS, hs_connecting=%d!!!\n", hs_connecting));
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
-
- if(hs_connecting)
- {
- halbtc8812a1ant_CoexTable(btcoexist, FORCE_EXEC, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
- }
- else
- {
- if((coex_sta->high_priority_tx+coex_sta->high_priority_rx+
- coex_sta->low_priority_tx+coex_sta->low_priority_rx)<=1200)
- halbtc8812a1ant_CoexTable(btcoexist, FORCE_EXEC, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3);
- else
- halbtc8812a1ant_CoexTable(btcoexist, FORCE_EXEC, 0xffffffff, 0xffffffff, 0xffff, 0x3);
- }
-}
-
-
-void
-halbtc8812a1ant_ActionWifiNotConnected(
- PBTC_COEXIST btcoexist
- )
-{
- BOOLEAN hs_connecting=false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting);
-
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- if(hs_connecting)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HS is connecting!!!\n"));
- halbtc8812a1ant_ActionHs(btcoexist, hs_connecting);
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
-}
-
-void
-halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN hs_connecting=false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting);
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- if(hs_connecting)
- {
- halbtc8812a1ant_ActionHs(btcoexist, hs_connecting);
- }
- else if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_INQ_PAGE == coex_dm->bt_status)
-{
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 30);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if( (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 28);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status)
- {
- if(stack_info->hid_exist)
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 35);
- else
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 29);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
- }
- else
- {
- //error condition, should not reach here, record error number for debugging.
- coex_dm->error_condition = 1;
- }
-}
-
-void
-halbtc8812a1ant_ActionWifiConnectedScan(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ActionConnectedScan()===>\n"));
-
- if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
-
- // psTdma
- if(BT_8812A_1ANT_BT_STATUS_INQ_PAGE == coex_dm->bt_status)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ActionConnectedScan(), bt is under inquiry/page scan\n"));
- if(stack_info->sco_exist)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 32);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 30);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- }
- else if( (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 5);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status)
- {
- if(stack_info->hid_exist)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 34);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 4);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- }
- else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 33);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- //error condition, should not reach here
- coex_dm->error_condition = 2;
- }
- }
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ActionConnectedScan()<===\n"));
-}
-
-void
-halbtc8812a1ant_ActionWifiConnectedSpecialPacket(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
-
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else
- {
- if(BT_8812A_1ANT_BT_STATUS_INQ_PAGE == coex_dm->bt_status)
- {
- if(stack_info->sco_exist)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 32);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 30);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- }
- else if( (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 28);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status)
- {
- if(stack_info->hid_exist)
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 35);
- else
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 29);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
- }
- else
- {
- //error condition, should not reach here
- coex_dm->error_condition = 3;
- }
- }
-}
-
-void
-halbtc8812a1ant_ActionWifiConnected(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN wifi_connected=false, wifi_busy=false, bt_hs_on=false;
- BOOLEAN scan=false, link=false, roam=false;
- BOOLEAN hs_connecting=false, under4way=false;
- u4Byte wifi_bw;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- if(!wifi_connected)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi not connected<===\n"));
- return;
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &under4way);
- if(under4way)
- {
- halbtc8812a1ant_ActionWifiConnectedSpecialPacket(btcoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
- return;
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
- if(scan || link || roam)
- {
- halbtc8812a1ant_ActionWifiConnectedScan(btcoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
- return;
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- if(!wifi_busy)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi associated-idle!!!\n"));
- if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else
- {
- if(BT_8812A_1ANT_BT_STATUS_INQ_PAGE == coex_dm->bt_status)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], bt is under inquiry/page scan!!!\n"));
- if(stack_info->sco_exist)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 32);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 30);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- }
- else if(BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x26, 0x0);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x26, 0x0);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 0);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status)
- {
- if(stack_info->hid_exist && stack_info->numOfLink==1)
- {
- // hid only
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
- coex_dm->reset_tdma_adjust = true;
- }
- else
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
-
- if(stack_info->hid_exist)
- {
- if(stack_info->a2dp_exist)
- {
- // hid+a2dp
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else if(stack_info->pan_exist)
- {
- if(bt_hs_on)
- {
- // hid+hs
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- }
- else
- {
- // hid+pan
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- }
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- coex_dm->error_condition = 4;
- }
- coex_dm->reset_tdma_adjust = true;
- }
- else if(stack_info->a2dp_exist)
- {
- if(stack_info->pan_exist)
- {
- if(bt_hs_on)
- {
- // a2dp+hs
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- }
- else
- {
- // a2dp+pan
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 36);
- }
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- coex_dm->reset_tdma_adjust = true;
- }
- else
- {
- // a2dp only
- halbtc8812a1ant_TdmaDurationAdjustForAcl(btcoexist);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- }
- else if(stack_info->pan_exist)
- {
- // pan only
- if(bt_hs_on)
- {
- coex_dm->error_condition = 5;
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- coex_dm->reset_tdma_adjust = true;
- }
- else
- {
- // temp state, do nothing!!!
- //DbgPrint("error 6, coex_dm->bt_status=%d\n", coex_dm->bt_status);
- //DbgPrint("error 6, stack_info->numOfLink=%d, stack_info->hid_exist=%d, stack_info->a2dp_exist=%d, stack_info->pan_exist=%d, stack_info->sco_exist=%d\n",
- //stack_info->numOfLink, stack_info->hid_exist, stack_info->a2dp_exist, stack_info->pan_exist, stack_info->sco_exist);
- //coex_dm->error_condition = 6;
- }
- }
- }
- else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
- }
- else
- {
- //error condition, should not reach here
- coex_dm->error_condition = 7;
- }
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi busy!!!\n"));
- if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else
- {
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HS is under progress!!!\n"));
- //DbgPrint("coex_dm->bt_status = 0x%x\n", coex_dm->bt_status);
- halbtc8812a1ant_ActionHs(btcoexist, hs_connecting);
- }
- else if(BT_8812A_1ANT_BT_STATUS_INQ_PAGE == coex_dm->bt_status)
- {
- if(stack_info->sco_exist)
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 32);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 30);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- }
- else if(BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 5);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
- }
- else if(BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- if(bt_hs_on)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HS is under progress!!!\n"));
- halbtc8812a1ant_ActionHs(btcoexist, hs_connecting);
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 5);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3);
- }
- }
- else if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status)
- {
- if(stack_info->hid_exist && stack_info->numOfLink==1)
- {
- // hid only
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3);
- coex_dm->reset_tdma_adjust = true;
- }
- else
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
-
- if(stack_info->hid_exist)
- {
- if(stack_info->a2dp_exist)
- {
- // hid+a2dp
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else if(stack_info->pan_exist)
- {
- if(bt_hs_on)
- {
- // hid+hs
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- }
- else
- {
- // hid+pan
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- }
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- else
- {
- coex_dm->error_condition = 8;
- }
- coex_dm->reset_tdma_adjust = true;
- }
- else if(stack_info->a2dp_exist)
- {
- if(stack_info->pan_exist)
- {
- if(bt_hs_on)
- {
- // a2dp+hs
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- }
- else
- {
- // a2dp+pan
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 36);
- }
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- coex_dm->reset_tdma_adjust = true;
- }
- else
- {
- // a2dp only
- halbtc8812a1ant_TdmaDurationAdjustForAcl(btcoexist);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- }
- else if(stack_info->pan_exist)
- {
- // pan only
- if(bt_hs_on)
- {
- coex_dm->error_condition = 9;
- }
- else
- {
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, true, 2);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x5afa5afa, 0xffff, 0x3);
- }
- coex_dm->reset_tdma_adjust = true;
- }
- else
- {
- //DbgPrint("error 10, stack_info->numOfLink=%d, stack_info->hid_exist=%d, stack_info->a2dp_exist=%d, stack_info->pan_exist=%d, stack_info->sco_exist=%d\n",
- //stack_info->numOfLink, stack_info->hid_exist, stack_info->a2dp_exist, stack_info->pan_exist, stack_info->sco_exist);
- coex_dm->error_condition = 10;
- }
- }
- }
- else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status) )
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
-
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3);
- }
- else
- {
- //DbgPrint("error 11, coex_dm->bt_status=%d\n", coex_dm->bt_status);
- //DbgPrint("error 11, stack_info->numOfLink=%d, stack_info->hid_exist=%d, stack_info->a2dp_exist=%d, stack_info->pan_exist=%d, stack_info->sco_exist=%d\n",
- //stack_info->numOfLink, stack_info->hid_exist, stack_info->a2dp_exist, stack_info->pan_exist, stack_info->sco_exist);
- //error condition, should not reach here
- coex_dm->error_condition = 11;
- }
- }
- }
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()<===\n"));
-}
-
-void
-halbtc8812a1ant_RunSwCoexistMechanism(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN wifi_under5g=false, wifi_busy=false, wifi_connected=false;
- u1Byte bt_info_original=0, bt_retry_cnt=0;
- u1Byte algorithm=0;
-
- return;
- if(stack_info->bProfileNotified)
- {
- algorithm = halbtc8812a1ant_ActionAlgorithm(btcoexist);
- coex_dm->cur_algorithm = algorithm;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d \n", coex_dm->cur_algorithm));
-
- if(halbtc8812a1ant_IsCommonAction(btcoexist))
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action common.\n"));
- }
- else
- {
- switch(coex_dm->cur_algorithm)
- {
- case BT_8812A_1ANT_COEX_ALGO_SCO:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
- halbtc8812a1ant_ActionSco(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
- halbtc8812a1ant_ActionHid(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
- halbtc8812a1ant_ActionA2dp(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
- halbtc8812a1ant_ActionA2dpPanHs(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
- halbtc8812a1ant_ActionPanEdr(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
- halbtc8812a1ant_ActionPanHs(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
- halbtc8812a1ant_ActionPanEdrA2dp(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_PANEDR_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
- halbtc8812a1ant_ActionPanEdrHid(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
- halbtc8812a1ant_ActionHidA2dpPanEdr(btcoexist);
- break;
- case BT_8812A_1ANT_COEX_ALGO_HID_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
- halbtc8812a1ant_ActionHidA2dp(btcoexist);
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
- halbtc8812a1ant_CoexAllOff(btcoexist);
- break;
- }
- coex_dm->pre_algorithm = coex_dm->cur_algorithm;
- }
- }
-}
-
-void
-halbtc8812a1ant_RunCoexistMechanism(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN wifi_under5g=false, wifi_busy=false, wifi_connected=false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under5g);
-
- if(wifi_under5g)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for 5G <===\n"));
- return;
- }
-
- if(btcoexist->manual_control)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
- return;
- }
-
- if(btcoexist->stop_coex_dm)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
- return;
- }
-
- halbtc8812a1ant_RunSwCoexistMechanism(btcoexist);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- if(btcoexist->bt_info.bt_disabled)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], bt is disabled!!!\n"));
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- if(wifi_busy)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- }
- else
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8812a1ant_LpsRpwm(btcoexist, NORMAL_EXEC, 0x0, 0x4);
- // power save must executed before psTdma.
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- }
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- }
- else if(coex_sta->under_ips)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 0);
- halbtc8812a1ant_CoexTable(btcoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
- halbtc8812a1ant_WifiParaAdjust(btcoexist, false);
- }
- else if(!wifi_connected)
- {
- BOOLEAN scan=false, link=false, roam=false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
-
- if(scan || link || roam)
- halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(btcoexist);
- else
- halbtc8812a1ant_ActionWifiNotConnected(btcoexist);
- }
- else // wifi LPS/Busy
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is NOT under IPS!!!\n"));
- halbtc8812a1ant_WifiParaAdjust(btcoexist, true);
- halbtc8812a1ant_ActionWifiConnected(btcoexist);
- }
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()<===\n"));
-}
-
-void
-halbtc8812a1ant_InitCoexDm(
- PBTC_COEXIST btcoexist
- )
-{
- BOOLEAN wifi_connected=false;
- // force to reset coex mechanism
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- if(!wifi_connected) // non-connected scan
- {
- halbtc8812a1ant_ActionWifiNotConnected(btcoexist);
- }
- else // wifi is connected
- {
- halbtc8812a1ant_ActionWifiConnected(btcoexist);
- }
-
- halbtc8812a1ant_FwDacSwingLvl(btcoexist, FORCE_EXEC, 6);
- halbtc8812a1ant_DecBtPwr(btcoexist, FORCE_EXEC, false);
-
- // sw all off
- halbtc8812a1ant_SwMechanism1(btcoexist,false,false,false,false);
- halbtc8812a1ant_SwMechanism2(btcoexist,false,false,false,0x18);
-
- halbtc8812a1ant_CoexTable(btcoexist, FORCE_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3);
-}
-
-//============================================================
-// work around function start with wa_halbtc8812a1ant_
-//============================================================
-//============================================================
-// extern function start with EXhalbtc8812a1ant_
-//============================================================
-void
-EXhalbtc8812a1ant_InitHwConfig(
- PBTC_COEXIST btcoexist
- )
-{
- u4Byte u4_tmp=0;
- u2Byte u2Tmp=0;
- u1Byte u1_tmp=0;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
-
- // backup rf 0x1e value
- coex_dm->bt_rf0x1e_backup =
- btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff);
-
- //ant sw control to BT
- btcoexist->btc_write_4byte(btcoexist, 0x900, 0x00000400);
- btcoexist->btc_write_1byte(btcoexist, 0x76d, 0x1);
- btcoexist->btc_write_1byte(btcoexist, 0xcb3, 0x77);
- btcoexist->btc_write_1byte(btcoexist, 0xcb7, 0x40);
-
- // 0x790[5:0]=0x5
- u1_tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
- u1_tmp &= 0xc0;
- u1_tmp |= 0x5;
- btcoexist->btc_write_1byte(btcoexist, 0x790, u1_tmp);
-
- // PTA parameter
- btcoexist->btc_write_1byte(btcoexist, 0x6cc, 0x0);
- btcoexist->btc_write_4byte(btcoexist, 0x6c8, 0xffff);
- btcoexist->btc_write_4byte(btcoexist, 0x6c4, 0x55555555);
- btcoexist->btc_write_4byte(btcoexist, 0x6c0, 0x55555555);
-
- // coex parameters
- btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1);
-
- // enable counter statistics
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4);
-
- // enable PTA
- btcoexist->btc_write_1byte(btcoexist, 0x40, 0x20);
-
- // bt clock related
- u1_tmp = btcoexist->btc_read_1byte(btcoexist, 0x4);
- u1_tmp |= BIT7;
- btcoexist->btc_write_1byte(btcoexist, 0x4, u1_tmp);
-
- // bt clock related
- u1_tmp = btcoexist->btc_read_1byte(btcoexist, 0x7);
- u1_tmp |= BIT1;
- btcoexist->btc_write_1byte(btcoexist, 0x7, u1_tmp);
-}
-
-void
-EXhalbtc8812a1ant_InitCoexDm(
- PBTC_COEXIST btcoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
-
- btcoexist->stop_coex_dm = false;
-
- halbtc8812a1ant_InitCoexDm(btcoexist);
-}
-
-void
-EXhalbtc8812a1ant_DisplayCoexInfo(
- PBTC_COEXIST btcoexist
- )
-{
- PBTC_BOARD_INFO board_info=&btcoexist->boardInfo;
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- pu1Byte cli_buf=btcoexist->cli_buf;
- u1Byte u1_tmp[4], i, bt_info_ext, psTdmaCase=0;
- u4Byte u4_tmp[4];
- BOOLEAN roam=false, scan=false, link=false, wifi_under5g=false;
- BOOLEAN bt_hs_on=false, wifi_busy=false;
- s4Byte wifi_rssi=0, bt_hs_rssi=0;
- u4Byte wifi_bw, wifiTrafficDir;
- u1Byte wifiDot11Chnl, wifiHsChnl;
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cli_buf);
-
- if(btcoexist->manual_control)
- {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
- CL_PRINTF(cli_buf);
- }
- if(btcoexist->stop_coex_dm)
- {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
- CL_PRINTF(cli_buf);
- }
-
- if(!board_info->bBtExist)
- {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cli_buf);
- return;
- }
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
- board_info->pgAntNum, board_info->btdmAntNum);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
- ((stack_info->bProfileNotified)? "Yes":"No"), stack_info->hciVersion);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_FW_VER);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
- wifiDot11Chnl, wifiHsChnl, bt_hs_on);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
- coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1],
- coex_dm->wifi_chnl_info[2]);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
- btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
- wifi_rssi, bt_hs_rssi);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi link/ roam/ scan", \
- link, roam, scan);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under5g);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
- (wifi_under5g? "5G":"2.4G"),
- ((BTC_WIFI_BW_LEGACY==wifi_bw)? "Legacy": (((BTC_WIFI_BW_HT40==wifi_bw)? "HT40":"HT20"))),
- ((!wifi_busy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
- ((coex_sta->c2h_bt_inquiry_page)?("inquiry/page scan"):((BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)? "non-connected idle":
- ( (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)? "connected-idle":"busy"))),
- coex_sta->bt_rssi, coex_sta->bt_retry_cnt);
- CL_PRINTF(cli_buf);
-
- if(stack_info->bProfileNotified)
- {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
- stack_info->sco_exist, stack_info->hid_exist, stack_info->pan_exist, stack_info->a2dp_exist);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO);
- }
-
- bt_info_ext = coex_sta->bt_info_ext;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
- (bt_info_ext&BIT0)? "Basic rate":"EDR rate");
- CL_PRINTF(cli_buf);
-
- for(i=0; i<BT_INFO_SRC_8812A_1ANT_MAX; i++)
- {
- if(coex_sta->bt_info_c2h_cnt[i])
- {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8812a1Ant[i], \
- coex_sta->bt_info_c2h[i][0], coex_sta->bt_info_c2h[i][1],
- coex_sta->bt_info_c2h[i][2], coex_sta->bt_info_c2h[i][3],
- coex_sta->bt_info_c2h[i][4], coex_sta->bt_info_c2h[i][5],
- coex_sta->bt_info_c2h[i][6], coex_sta->bt_info_c2h_cnt[i]);
- CL_PRINTF(cli_buf);
- }
- }
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
- ((coex_sta->under_ips? "IPS ON":"IPS OFF")),
- ((coex_sta->under_lps? "LPS ON":"LPS OFF")),
- btcoexist->bt_info.lps1Ant,
- btcoexist->bt_info.rpwm1Ant);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
-
- if(!btcoexist->manual_control)
- {
- // Sw mechanism
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig/ btLna]", \
- coex_dm->cur_rf_rx_lpf_shrink, coex_dm->cur_low_penalty_ra, coex_dm->limited_dig, coex_dm->bCurBtLnaConstrain);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
- coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off, coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl);
- CL_PRINTF(cli_buf);
-
- // Fw mechanism
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
- CL_PRINTF(cli_buf);
-
- psTdmaCase = coex_dm->cur_ps_tdma;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
- coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1],
- coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3],
- coex_dm->ps_tdma_para[4], psTdmaCase);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
- coex_dm->error_condition);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
- coex_dm->cur_dec_bt_pwr, coex_dm->cur_ignore_wlan_act);
- CL_PRINTF(cli_buf);
- }
-
- // Hw setting
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
- coex_dm->bt_rf0x1e_backup);
- CL_PRINTF(cli_buf);
-
- u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
- u1_tmp[0]);
- CL_PRINTF(cli_buf);
-
- u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x92c);
- u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x930);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \
- (u1_tmp[0]), u4_tmp[0]);
- CL_PRINTF(cli_buf);
-
- u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40);
- u1_tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x4f);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \
- u1_tmp[0], u1_tmp[1]);
- CL_PRINTF(cli_buf);
-
- u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
- u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
- u4_tmp[0], u1_tmp[0]);
- CL_PRINTF(cli_buf);
-
- u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
- u4_tmp[0]);
- CL_PRINTF(cli_buf);
-
-#if 0
- u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48);
- u4_tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xf4c);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xf48/ 0xf4c (FA cnt)", \
- u4_tmp[0], u4_tmp[1]);
- CL_PRINTF(cli_buf);
-#endif
-
- u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
- u4_tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
- u4_tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
- u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
- u4_tmp[0], u4_tmp[1], u4_tmp[2], u1_tmp[0]);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
- coex_sta->high_priority_rx, coex_sta->high_priority_tx);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
- coex_sta->low_priority_rx, coex_sta->low_priority_tx);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-void
-EXhalbtc8812a1ant_IpsNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- u4Byte u4_tmp=0;
-
- if(btcoexist->manual_control || btcoexist->stop_coex_dm)
- return;
-
- if(BTC_IPS_ENTER == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
- coex_sta->under_ips = true;
-
- // 0x4c[23]=1
- u4_tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u4_tmp |= BIT23;
- btcoexist->btc_write_4byte(btcoexist, 0x4c, u4_tmp);
-
- halbtc8812a1ant_CoexAllOff(btcoexist);
- }
- else if(BTC_IPS_LEAVE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
- coex_sta->under_ips = false;
- //halbtc8812a1ant_InitCoexDm(btcoexist);
- }
-}
-
-void
-EXhalbtc8812a1ant_LpsNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- if(btcoexist->manual_control || btcoexist->stop_coex_dm)
- return;
-
- if(BTC_LPS_ENABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
- coex_sta->under_lps = true;
- }
- else if(BTC_IPS_LEAVE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
- coex_sta->under_lps = false;
- }
-}
-
-void
-EXhalbtc8812a1ant_ScanNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN wifi_connected=false;
-
- if(btcoexist->manual_control ||btcoexist->stop_coex_dm)
- return;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- if(BTC_SCAN_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
- if(!wifi_connected) // non-connected scan
- {
- //set 0x550[3]=1 before PsTdma
- //halbtc8812a1ant_Reg0x550Bit3(btcoexist, true);
- halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(btcoexist);
- }
- else // wifi is connected
- {
- halbtc8812a1ant_ActionWifiConnectedScan(btcoexist);
- }
- }
- else if(BTC_SCAN_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
- if(!wifi_connected) // non-connected scan
- {
- //halbtc8812a1ant_Reg0x550Bit3(btcoexist, false);
- halbtc8812a1ant_ActionWifiNotConnected(btcoexist);
- }
- else
- {
- halbtc8812a1ant_ActionWifiConnected(btcoexist);
- }
- }
-}
-
-void
-EXhalbtc8812a1ant_ConnectNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- PBTC_STACK_INFO stack_info=&btcoexist->stack_info;
- BOOLEAN wifi_connected=false;
-
- if(btcoexist->manual_control ||btcoexist->stop_coex_dm)
- return;
-
- if(BTC_ASSOCIATE_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
- if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- }
- else
- {
- halbtc8812a1ant_ActionWifiNotConnectedAssoAuthScan(btcoexist);
- }
- }
- else if(BTC_ASSOCIATE_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- if(!wifi_connected) // non-connected scan
- {
- //halbtc8812a1ant_Reg0x550Bit3(btcoexist, false);
- halbtc8812a1ant_ActionWifiNotConnected(btcoexist);
- }
- else
- {
- halbtc8812a1ant_ActionWifiConnected(btcoexist);
- }
- }
-}
-
-void
-EXhalbtc8812a1ant_MediaStatusNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- u1Byte dataLen=5;
- u1Byte buf[6] = {0};
- u1Byte h2c_parameter[3] ={0};
- BOOLEAN wifi_under5g=false;
- u4Byte wifi_bw;
- u1Byte wifi_central_chnl;
-
- if(btcoexist->manual_control ||btcoexist->stop_coex_dm)
- return;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under5g);
-
- // only 2.4G we need to inform bt the chnl mask
- if(!wifi_under5g)
- {
- if(BTC_MEDIA_CONNECT == type)
- {
- h2c_parameter[0] = 0x1;
- }
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifi_central_chnl);
- h2c_parameter[1] = wifi_central_chnl;
- if(BTC_WIFI_BW_HT40 == wifi_bw)
- h2c_parameter[2] = 0x30;
- else
- h2c_parameter[2] = 0x20;
- }
-
- coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
- coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
- coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
-
- buf[0] = dataLen;
- buf[1] = 0x5; // OP_Code
- buf[2] = 0x3; // OP_Code_Length
- buf[3] = h2c_parameter[0]; // OP_Code_Content
- buf[4] = h2c_parameter[1];
- buf[5] = h2c_parameter[2];
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]);
-}
-
-void
-EXhalbtc8812a1ant_SpecialPacketNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- BOOLEAN bSecurityLink=false;
-
- if(btcoexist->manual_control ||btcoexist->stop_coex_dm)
- return;
-
- //if(type == BTC_PACKET_DHCP)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
- if(btcoexist->bt_info.bt_disabled)
- {
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- }
- else
- {
- halbtc8812a1ant_ActionWifiConnectedSpecialPacket(btcoexist);
- }
- }
-}
-
-void
-EXhalbtc8812a1ant_BtInfoNotify(
- PBTC_COEXIST btcoexist,
- pu1Byte tmp_buf,
- u1Byte length
- )
-{
- u1Byte bt_info=0;
- u1Byte i, rsp_source=0;
- static u4Byte set_bt_lna_cnt=0, set_bt_psd_mode=0;
- BOOLEAN bt_busy=false, limited_dig=false;
- BOOLEAN wifi_connected=false;
- BOOLEAN bRejApAggPkt=false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify()===>\n"));
-
-
- rsp_source = tmp_buf[0]&0xf;
- if(rsp_source >= BT_INFO_SRC_8812A_1ANT_MAX)
- rsp_source = BT_INFO_SRC_8812A_1ANT_WIFI_FW;
- coex_sta->bt_info_c2h_cnt[rsp_source]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rsp_source, length));
- for(i=0; i<length; i++)
- {
- coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
- if(i == 1)
- bt_info = tmp_buf[i];
- if(i == length-1)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%2x]\n", tmp_buf[i]));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%2x, ", tmp_buf[i]));
- }
- }
-
- if(btcoexist->manual_control)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
- return;
- }
- if(btcoexist->stop_coex_dm)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Coex STOPPED!!<===\n"));
- return;
- }
-
- if(BT_INFO_SRC_8812A_1ANT_WIFI_FW != rsp_source)
- {
- coex_sta->bt_retry_cnt =
- coex_sta->bt_info_c2h[rsp_source][2];
-
- coex_sta->bt_rssi =
- coex_sta->bt_info_c2h[rsp_source][3]*2+10;
-
- coex_sta->bt_info_ext =
- coex_sta->bt_info_c2h[rsp_source][4];
-
- // Here we need to resend some wifi info to BT
- // because bt is reset and loss of the info.
- if( (coex_sta->bt_info_ext & BIT1) )
- {
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
- if(wifi_connected)
- {
- EXhalbtc8812a1ant_MediaStatusNotify(btcoexist, BTC_MEDIA_CONNECT);
- }
- else
- {
- EXhalbtc8812a1ant_MediaStatusNotify(btcoexist, BTC_MEDIA_DISCONNECT);
- }
-
- set_bt_psd_mode = 0;
- }
-
- // test-chip bt patch doesn't support, temporary remove.
- // need to add back when mp-chip. 12/20/2012
-#if 0
- if(set_bt_psd_mode <= 3)
- {
- halbtc8812a1ant_SetBtPsdMode(btcoexist, FORCE_EXEC, 0xd);
- set_bt_psd_mode++;
- }
-
- if(coex_dm->bCurBtLnaConstrain)
- {
- if( (coex_sta->bt_info_ext & BIT2) )
- {
- }
- else
- {
- if(set_bt_lna_cnt <= 3)
- {
- halbtc8812a1ant_SetBtLnaConstrain(btcoexist, FORCE_EXEC, true);
- set_bt_lna_cnt++;
- }
- }
- }
- else
- {
- set_bt_lna_cnt = 0;
- }
-#endif
- // test-chip bt patch only rsp the status for BT_RSP,
- // so temporary we consider the following only under BT_RSP
- if(BT_INFO_SRC_8812A_1ANT_BT_RSP == rsp_source)
- {
- if( (coex_sta->bt_info_ext & BIT3) )
- {
- #if 0// temp disable because bt patch report the wrong value.
- halbtc8812a1ant_IgnoreWlanAct(btcoexist, FORCE_EXEC, false);
- #endif
- }
- else
- {
- // BT already NOT ignore Wlan active, do nothing here.
- }
-
- if( (coex_sta->bt_info_ext & BIT4) )
- {
- // BT auto report already enabled, do nothing
- }
- else
- {
- halbtc8812a1ant_BtAutoReport(btcoexist, FORCE_EXEC, true);
- }
- }
- }
-
- // check BIT2 first ==> check if bt is under inquiry or page scan
- if(bt_info & BT_INFO_8812A_1ANT_B_INQ_PAGE)
- {
- coex_sta->c2h_bt_inquiry_page = true;
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_INQ_PAGE;
- }
- else
- {
- coex_sta->c2h_bt_inquiry_page = false;
- if(!(bt_info&BT_INFO_8812A_1ANT_B_CONNECTION))
- {
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-connected idle!!!\n"));
- }
- else if(bt_info == BT_INFO_8812A_1ANT_B_CONNECTION) // connection exists but no busy
- {
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt connected-idle!!!\n"));
- }
- else if((bt_info&BT_INFO_8812A_1ANT_B_SCO_ESCO) ||
- (bt_info&BT_INFO_8812A_1ANT_B_SCO_BUSY))
- {
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_SCO_BUSY;
- bRejApAggPkt = true;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt sco busy!!!\n"));
- }
- else if(bt_info&BT_INFO_8812A_1ANT_B_ACL_BUSY)
- {
- if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status)
- coex_dm->reset_tdma_adjust = true;
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_ACL_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt acl busy!!!\n"));
- }
-#if 0
- else if(bt_info&BT_INFO_8812A_1ANT_B_SCO_ESCO)
- {
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt acl/sco busy!!!\n"));
- }
-#endif
- else
- {
- //DbgPrint("error, undefined bt_info=0x%x\n", bt_info);
- coex_dm->bt_status = BT_8812A_1ANT_BT_STATUS_MAX;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-defined state!!!\n"));
- }
-
- // send delete BA to disable aggregation
- //btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
- }
-
- if( (BT_8812A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status) )
- {
- bt_busy = true;
- }
- else
- {
- bt_busy = false;
- }
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
-
- if(bt_busy)
- {
- limited_dig = true;
- }
- else
- {
- limited_dig = false;
- }
- coex_dm->limited_dig = limited_dig;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
-
- halbtc8812a1ant_RunCoexistMechanism(btcoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify()<===\n"));
-}
-
-void
-EXhalbtc8812a1ant_StackOperationNotify(
- PBTC_COEXIST btcoexist,
- u1Byte type
- )
-{
- if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
- }
- else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
- }
-}
-
-void
-EXhalbtc8812a1ant_HaltNotify(
- PBTC_COEXIST btcoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
-
- halbtc8812a1ant_IgnoreWlanAct(btcoexist, FORCE_EXEC, true);
- halbtc8812a1ant_PsTdma(btcoexist, FORCE_EXEC, false, 0);
- btcoexist->btc_write_1byte(btcoexist, 0x4f, 0xf);
- halbtc8812a1ant_WifiParaAdjust(btcoexist, false);
-}
-
-void
-EXhalbtc8812a1ant_PnpNotify(
- PBTC_COEXIST btcoexist,
- u1Byte pnpState
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
-
- if(BTC_WIFI_PNP_SLEEP == pnpState)
- {
- btcoexist->stop_coex_dm = true;
- halbtc8812a1ant_IgnoreWlanAct(btcoexist, FORCE_EXEC, true);
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- }
- else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
- {
-
- }
-}
-
-void
-EXhalbtc8812a1ant_Periodical(
- PBTC_COEXIST btcoexist
- )
-{
- BOOLEAN wifi_under5g=false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Periodical()===>\n"));
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 1Ant Periodical!!\n"));
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under5g);
-
- if(wifi_under5g)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Periodical(), return for 5G<===\n"));
- halbtc8812a1ant_CoexAllOff(btcoexist);
- return;
- }
-
- halbtc8812a1ant_QueryBtInfo(btcoexist);
- halbtc8812a1ant_MonitorBtCtr(btcoexist);
- halbtc8812a1ant_MonitorBtEnableDisable(btcoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Periodical()<===\n"));
-}
-
-void
-EXhalbtc8812a1ant_DbgControl(
- PBTC_COEXIST btcoexist,
- u1Byte opCode,
- u1Byte opLen,
- pu1Byte pData
- )
-{
- switch(opCode)
- {
- case BTC_DBG_SET_COEX_NORMAL:
- btcoexist->manual_control = false;
- halbtc8812a1ant_InitCoexDm(btcoexist);
- break;
- case BTC_DBG_SET_COEX_WIFI_ONLY:
- btcoexist->manual_control = true;
- halbtc8812a1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- halbtc8812a1ant_PsTdma(btcoexist, NORMAL_EXEC, false, 9);
- break;
- case BTC_DBG_SET_COEX_BT_ONLY:
- // todo
- break;
- default:
- break;
- }
-}
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.h b/drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.h
deleted file mode 100644
index 37bdab5ae9f1..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/HalBtc8812a1Ant.h
+++ /dev/null
@@ -1,205 +0,0 @@
-//===========================================
-// The following is for 8812A_1ANT BT Co-exist definition
-//===========================================
-#define BT_INFO_8812A_1ANT_B_FTP BIT7
-#define BT_INFO_8812A_1ANT_B_A2DP BIT6
-#define BT_INFO_8812A_1ANT_B_HID BIT5
-#define BT_INFO_8812A_1ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8812A_1ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8812A_1ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8812A_1ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8812A_1ANT_B_CONNECTION BIT0
-
-#define BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \
- (((_BT_INFO_EXT_&BIT0))? true:false)
-
-#define BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT 2
-
-#define
-#define OUT
-
-typedef enum _BT_INFO_SRC_8812A_1ANT{
- BT_INFO_SRC_8812A_1ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8812A_1ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8812A_1ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8812A_1ANT_MAX
-}BT_INFO_SRC_8812A_1ANT,*PBT_INFO_SRC_8812A_1ANT;
-
-typedef enum _BT_8812A_1ANT_BT_STATUS{
- BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8812A_1ANT_BT_STATUS_INQ_PAGE = 0x2,
- BT_8812A_1ANT_BT_STATUS_ACL_BUSY = 0x3,
- BT_8812A_1ANT_BT_STATUS_SCO_BUSY = 0x4,
- BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
- BT_8812A_1ANT_BT_STATUS_MAX
-}BT_8812A_1ANT_BT_STATUS,*PBT_8812A_1ANT_BT_STATUS;
-
-typedef enum _BT_8812A_1ANT_COEX_ALGO{
- BT_8812A_1ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8812A_1ANT_COEX_ALGO_SCO = 0x1,
- BT_8812A_1ANT_COEX_ALGO_HID = 0x2,
- BT_8812A_1ANT_COEX_ALGO_A2DP = 0x3,
- BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS = 0x4,
- BT_8812A_1ANT_COEX_ALGO_PANEDR = 0x5,
- BT_8812A_1ANT_COEX_ALGO_PANHS = 0x6,
- BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
- BT_8812A_1ANT_COEX_ALGO_PANEDR_HID = 0x8,
- BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
- BT_8812A_1ANT_COEX_ALGO_HID_A2DP = 0xa,
- BT_8812A_1ANT_COEX_ALGO_MAX = 0xb,
-}BT_8812A_1ANT_COEX_ALGO,*PBT_8812A_1ANT_COEX_ALGO;
-
-typedef struct _COEX_DM_8812A_1ANT{
- // fw mechanism
- bool pre_dec_bt_pwr;
- bool cur_dec_bt_pwr;
- bool bPreBtLnaConstrain;
- bool bCurBtLnaConstrain;
- u8 bPreBtPsdMode;
- u8 bCurBtPsdMode;
- u8 pre_fw_dac_swing_lvl;
- u8 cur_fw_dac_swing_lvl;
- bool cur_ignore_wlan_act;
- bool pre_ignore_wlan_act;
- u8 pre_ps_tdma;
- u8 cur_ps_tdma;
- u8 ps_tdma_para[5];
- u8 ps_tdma_du_adj_type;
- bool reset_tdma_adjust;
- bool pre_ps_tdma_on;
- bool cur_ps_tdma_on;
- bool pre_bt_auto_report;
- bool cur_bt_auto_report;
- u8 pre_lps;
- u8 cur_lps;
- u8 pre_rpwm;
- u8 cur_rpwm;
-
- // sw mechanism
- bool pre_rf_rx_lpf_shrink;
- bool cur_rf_rx_lpf_shrink;
- u32 bt_rf0x1e_backup;
- bool pre_low_penalty_ra;
- bool cur_low_penalty_ra;
- bool pre_dac_swing_on;
- u32 pre_dac_swing_lvl;
- bool cur_dac_swing_on;
- u32 cur_dac_swing_lvl;
- bool pre_adc_back_off;
- bool cur_adc_back_off;
- bool pre_agc_table_en;
- bool cur_agc_table_en;
- u32 pre_val0x6c0;
- u32 cur_val0x6c0;
- u32 pre_val0x6c4;
- u32 cur_val0x6c4;
- u32 pre_val0x6c8;
- u32 cur_val0x6c8;
- u8 pre_val0x6cc;
- u8 cur_val0x6cc;
- bool limited_dig;
-
- // algorithm related
- u8 pre_algorithm;
- u8 cur_algorithm;
- u8 bt_status;
- u8 wifi_chnl_info[3];
-
- u8 error_condition;
-} COEX_DM_8812A_1ANT, *PCOEX_DM_8812A_1ANT;
-
-typedef struct _COEX_STA_8812A_1ANT{
- bool under_lps;
- bool under_ips;
- u32 high_priority_tx;
- u32 high_priority_rx;
- u32 low_priority_tx;
- u32 low_priority_rx;
- u8 bt_rssi;
- u8 pre_bt_rssi_state;
- u8 pre_wifi_rssi_state[4];
- bool c2h_bt_info_req_sent;
- u8 bt_info_c2h[BT_INFO_SRC_8812A_1ANT_MAX][10];
- u32 bt_info_c2h_cnt[BT_INFO_SRC_8812A_1ANT_MAX];
- bool c2h_bt_inquiry_page;
- u8 bt_retry_cnt;
- u8 bt_info_ext;
-}COEX_STA_8812A_1ANT, *PCOEX_STA_8812A_1ANT;
-
-//===========================================
-// The following is interface which will notify coex module.
-//===========================================
-void
-EXhalbtc8812a1ant_InitHwConfig(
- PBTC_COEXIST btcoexist
- );
-void
-EXhalbtc8812a1ant_InitCoexDm(
- PBTC_COEXIST btcoexist
- );
-void
-EXhalbtc8812a1ant_IpsNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_LpsNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_ScanNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_ConnectNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_MediaStatusNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_SpecialPacketNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_BtInfoNotify(
- PBTC_COEXIST btcoexist,
- u8 *tmp_buf,
- u8 length
- );
-void
-EXhalbtc8812a1ant_StackOperationNotify(
- PBTC_COEXIST btcoexist,
- u8 type
- );
-void
-EXhalbtc8812a1ant_HaltNotify(
- PBTC_COEXIST btcoexist
- );
-void
-EXhalbtc8812a1ant_PnpNotify(
- PBTC_COEXIST btcoexist,
- u8 pnpState
- );
-void
-EXhalbtc8812a1ant_Periodical(
- PBTC_COEXIST btcoexist
- );
-void
-EXhalbtc8812a1ant_DisplayCoexInfo(
- PBTC_COEXIST btcoexist
- );
-void
-EXhalbtc8812a1ant_DbgControl(
- PBTC_COEXIST btcoexist,
- u8 opCode,
- u8 opLen,
- u8 *pData
- );
diff --git a/drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.c b/drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.c
deleted file mode 100644
index 8e4293a35872..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.c
+++ /dev/null
@@ -1,1614 +0,0 @@
-//============================================================
-// Description:
-//
-// This file is for RTL8723A Co-exist mechanism
-//
-// History
-// 2012/08/22 Cosa first check in.
-// 2012/11/14 Cosa Revise for 8723A 1Ant out sourcing.
-//
-//============================================================
-
-//============================================================
-// include files
-//============================================================
-#include "Mp_Precomp.h"
-#if(BT_30_SUPPORT == 1)
-//============================================================
-// Global variables, these are static variables
-//============================================================
-static COEX_DM_8723A_1ANT GLCoexDm8723a1Ant;
-static PCOEX_DM_8723A_1ANT pCoexDm=&GLCoexDm8723a1Ant;
-static COEX_STA_8723A_1ANT GLCoexSta8723a1Ant;
-static PCOEX_STA_8723A_1ANT pCoexSta=&GLCoexSta8723a1Ant;
-
-const char *const GLBtInfoSrc8723a1Ant[]={
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-//============================================================
-// local function proto type if needed
-//============================================================
-//============================================================
-// local function start with halbtc8723a1ant_
-//============================================================
-VOID
-halbtc8723a1ant_Reg0x550Bit3(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bSet
- )
-{
- u1Byte u1tmp=0;
-
- u1tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x550);
- if(bSet)
- {
- u1tmp |= BIT3;
- }
- else
- {
- u1tmp &= ~BIT3;
- }
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x550, u1tmp);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], set 0x550[3]=%d\n", (bSet? 1:0)));
-}
-
-VOID
-halbtc8723a1ant_NotifyFwScan(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte scanType
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- if(BTC_SCAN_START == scanType)
- H2C_Parameter[0] = 0x1;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Notify FW for wifi scan, write 0x3b=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x3b, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8723a1ant_QueryBtInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- pCoexSta->bC2hBtInfoReqSent = true;
-
- H2C_Parameter[0] |= BIT0; // trigger
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x38, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8723a1ant_SetSwRfRxLpfCorner(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bRxRfShrinkOn
- )
-{
- if(bRxRfShrinkOn)
- {
- //Shrink RF Rx LPF corner
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
- }
- else
- {
- //Resume RF Rx LPF corner
- // After initialized, we can use pCoexDm->btRf0x1eBackup
- if(pBtCoexist->initilized)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
- }
- }
-}
-
-VOID
-halbtc8723a1ant_RfShrink(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bRxRfShrinkOn
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
- (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
- pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
- pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
-
- if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
- return;
- }
- halbtc8723a1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
-
- pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
-}
-
-VOID
-halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bLowPenaltyRa
- )
-{
- u1Byte tmpU1;
-
- tmpU1 = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4fd);
- tmpU1 |= BIT0;
- if(bLowPenaltyRa)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
- tmpU1 &= ~BIT2;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
- tmpU1 |= BIT2;
- }
-
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x4fd, tmpU1);
-}
-
-VOID
-halbtc8723a1ant_LowPenaltyRa(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bLowPenaltyRa
- )
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
- (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
- pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
- pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
-
- if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
- return;
- }
- halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
-
- pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
-}
-
-VOID
-halbtc8723a1ant_SetCoexTable(
- IN PBTC_COEXIST pBtCoexist,
- IN u4Byte val0x6c0,
- IN u4Byte val0x6c8,
- IN u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x6cc, val0x6cc);
-}
-
-VOID
-halbtc8723a1ant_CoexTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u4Byte val0x6c0,
- IN u4Byte val0x6c8,
- IN u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
- (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc));
- pCoexDm->curVal0x6c0 = val0x6c0;
- pCoexDm->curVal0x6c8 = val0x6c8;
- pCoexDm->curVal0x6cc = val0x6cc;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
- pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
- pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
-
- if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
- (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
- (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
- return;
- }
- halbtc8723a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc);
-
- pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
- pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
- pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
-}
-
-VOID
-halbtc8723a1ant_SetFwIgnoreWlanAct(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bEnable
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- if(bEnable)
- {
- H2C_Parameter[0] |= BIT0; // function enable
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x25, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8723a1ant_IgnoreWlanAct(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bEnable
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
- (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
- pCoexDm->bCurIgnoreWlanAct = bEnable;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
- pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
-
- if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
- return;
- }
- halbtc8723a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
-
- pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
-}
-
-VOID
-halbtc8723a1ant_SetFwPstdma(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type,
- IN u1Byte byte1,
- IN u1Byte byte2,
- IN u1Byte byte3,
- IN u1Byte byte4,
- IN u1Byte byte5
- )
-{
- u1Byte H2C_Parameter[5] ={0};
- u1Byte realByte1=byte1, realByte5=byte5;
- BOOLEAN bApEnable=FALSE;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable);
-
- // byte1[1:0] != 0 means enable pstdma
- // for 2Ant bt coexist, if byte1 != 0 means enable pstdma
- if(byte1)
- {
- if(bApEnable)
- {
- if(type != 5 && type != 12)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n"));
- realByte1 &= ~BIT4;
- realByte1 |= BIT5;
-
- realByte5 |= BIT5;
- realByte5 &= ~BIT6;
- }
- }
- }
- H2C_Parameter[0] = realByte1;
- H2C_Parameter[1] = byte2;
- H2C_Parameter[2] = byte3;
- H2C_Parameter[3] = byte4;
- H2C_Parameter[4] = realByte5;
-
- pCoexDm->psTdmaPara[0] = realByte1;
- pCoexDm->psTdmaPara[1] = byte2;
- pCoexDm->psTdmaPara[2] = byte3;
- pCoexDm->psTdmaPara[3] = byte4;
- pCoexDm->psTdmaPara[4] = realByte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n",
- H2C_Parameter[0],
- H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x3a, 5, H2C_Parameter);
-}
-
-VOID
-halbtc8723a1ant_PsTdma(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bTurnOn,
- IN u1Byte type
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
- (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
- pCoexDm->bCurPsTdmaOn = bTurnOn;
- pCoexDm->curPsTdma = type;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
- pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
- pCoexDm->prePsTdma, pCoexDm->curPsTdma));
-
- if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
- (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
- return;
- }
- if(pCoexDm->bCurPsTdmaOn)
- {
- switch(pCoexDm->curPsTdma)
- {
- case 1:
- default:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x0, 0x40);
- break;
- case 2:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x0, 0x40);
- break;
- case 3:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x3f, 0x3, 0x10, 0x40);
- break;
- case 4:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x15, 0x3, 0x10, 0x0);
- break;
- case 5:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0x15, 0x3, 0x35, 0xc0);
- break;
-
- case 8:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
- break;
- case 9:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40);
- break;
- case 10:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40);
- break;
- case 11:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x0, 0x40);
- break;
- case 12:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0xa, 0x3, 0x15, 0xc0);
- break;
-
- case 18:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
- break;
-
- case 20:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x2a, 0x2a, 0x0, 0x0);
- break;
- case 21:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x20, 0x3, 0x10, 0x40);
- break;
- case 22:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x2, 0x40);
- break;
- case 23:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x2, 0x40);
- break;
- case 24:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x2, 0x40);
- break;
- case 25:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40);
- break;
- case 26:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0);
- break;
- case 27:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40);
- break;
- case 28:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x3, 0x2f, 0x2f, 0x0, 0x0);
- break;
-
- }
- }
- else
- {
- // disable PS tdma
- switch(pCoexDm->curPsTdma)
- {
- case 8:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x8, 0x0, 0x0, 0x0, 0x0);
- break;
- case 0:
- default:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0);
- pBtCoexist->btc_write_2byte(pBtCoexist, 0x860, 0x210);
- break;
- case 9:
- halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0);
- pBtCoexist->btc_write_2byte(pBtCoexist, 0x860, 0x110);
- break;
-
- }
- }
-
- // update pre state
- pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
- pCoexDm->prePsTdma = pCoexDm->curPsTdma;
-}
-
-
-VOID
-halbtc8723a1ant_CoexAllOff(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // fw all off
- halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- // sw all off
- halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
-
- // hw all off
- halbtc8723a1ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-}
-
-VOID
-halbtc8723a1ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // force to reset coex mechanism
- halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
-}
-
-VOID
-halbtc8723a1ant_BtEnableAction(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
-}
-
-VOID
-halbtc8723a1ant_MonitorBtCtr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u4Byte regHPTxRx, regLPTxRx, u4Tmp;
- u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
- u1Byte u1Tmp;
-
- regHPTxRx = 0x770;
- regLPTxRx = 0x774;
-
- u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regHPTxRx);
- regHPTx = u4Tmp & MASKLWORD;
- regHPRx = (u4Tmp & MASKHWORD)>>16;
-
- u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regLPTxRx);
- regLPTx = u4Tmp & MASKLWORD;
- regLPRx = (u4Tmp & MASKHWORD)>>16;
-
- pCoexSta->highPriorityTx = regHPTx;
- pCoexSta->highPriorityRx = regHPRx;
- pCoexSta->lowPriorityTx = regLPTx;
- pCoexSta->lowPriorityRx = regLPRx;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
-
- // reset counter
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0xc);
-}
-
-VOID
-halbtc8723a1ant_MonitorBtEnableDisable(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- static BOOLEAN bPreBtDisabled=FALSE;
- static u4Byte btDisableCnt=0;
- BOOLEAN bBtActive=true, bBtDisabled=FALSE;
-
- // This function check if bt is disabled
-
- if( pCoexSta->highPriorityTx == 0 &&
- pCoexSta->highPriorityRx == 0 &&
- pCoexSta->lowPriorityTx == 0 &&
- pCoexSta->lowPriorityRx == 0)
- {
- bBtActive = FALSE;
- }
- if( pCoexSta->highPriorityTx == 0xffff &&
- pCoexSta->highPriorityRx == 0xffff &&
- pCoexSta->lowPriorityTx == 0xffff &&
- pCoexSta->lowPriorityRx == 0xffff)
- {
- bBtActive = FALSE;
- }
- if(bBtActive)
- {
- btDisableCnt = 0;
- bBtDisabled = FALSE;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
- }
- else
- {
- btDisableCnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
- btDisableCnt));
- if(btDisableCnt >= 2)
- {
- bBtDisabled = true;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
- }
- }
- if(bPreBtDisabled != bBtDisabled)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
- (bPreBtDisabled ? "disabled":"enabled"),
- (bBtDisabled ? "disabled":"enabled")));
- bPreBtDisabled = bBtDisabled;
- if(!bBtDisabled)
- {
- halbtc8723a1ant_BtEnableAction(pBtCoexist);
- }
- else
- {
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
- }
- }
-}
-
-VOID
-halbtc8723a1ant_TdmaDurationAdjust(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- static s4Byte up,dn,m,n,WaitCount;
- s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
- u1Byte retryCount=0;
- u1Byte btState;
- BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
- u4Byte wifiBw;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- btState = pCoexDm->btStatus;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], TdmaDurationAdjust()\n"));
- if(pCoexDm->psTdmaGlobalCnt != pCoexDm->psTdmaMonitorCnt)
- {
- pCoexDm->psTdmaMonitorCnt = 0;
- pCoexDm->psTdmaGlobalCnt = 0;
- }
- if(pCoexDm->psTdmaMonitorCnt == 0)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], first run BT A2DP + WiFi busy state!!\n"));
- if(btState == BT_STATE_8723A_1ANT_ACL_ONLY_BUSY)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- pCoexDm->psTdmaDuAdjType = 1;
- }
- else
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 22);
- pCoexDm->psTdmaDuAdjType = 22;
- }
- //============
- up = 0;
- dn = 0;
- m = 1;
- n= 3;
- result = 0;
- WaitCount = 0;
- }
- else
- {
- //acquire the BT TRx retry count from BT_Info byte2
- retryCount = pCoexSta->btRetryCnt;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], retryCount = %d\n", retryCount));
- result = 0;
- WaitCount++;
-
- if(retryCount == 0) // no retry in the last 2-second duration
- {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
- {
- WaitCount = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Increase wifi duration!!\n"));
- }
- }
- else if (retryCount <= 3) // <=3 retry in the last 2-second duration
- {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
- {
- if (WaitCount <= 2)
- m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^
- else
- m = 1;
-
- if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- WaitCount = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
- }
- }
- else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
- {
- if (WaitCount == 1)
- m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^
- else
- m = 1;
-
- if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- WaitCount = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
- }
-
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT TxRx counter H+L <= 1200\n"));
- if(btState != BT_STATE_8723A_1ANT_ACL_ONLY_BUSY)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], NOT ACL only busy!\n"));
- if(BTC_WIFI_BW_HT40 != wifiBw)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], 20MHz\n"));
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 22)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 23);
- pCoexDm->psTdmaDuAdjType = 23;
- }
- else if(pCoexDm->curPsTdma == 23)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 24);
- pCoexDm->psTdmaDuAdjType = 24;
- }
- else if(pCoexDm->curPsTdma == 24)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 25);
- pCoexDm->psTdmaDuAdjType = 25;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 25)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 24);
- pCoexDm->psTdmaDuAdjType = 24;
- }
- else if(pCoexDm->curPsTdma == 24)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 23);
- pCoexDm->psTdmaDuAdjType = 23;
- }
- else if(pCoexDm->curPsTdma == 23)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 22);
- pCoexDm->psTdmaDuAdjType = 22;
- }
- }
- // error handle, if not in the following state,
- // set psTdma again.
- if( (pCoexDm->psTdmaDuAdjType != 22) &&
- (pCoexDm->psTdmaDuAdjType != 23) &&
- (pCoexDm->psTdmaDuAdjType != 24) &&
- (pCoexDm->psTdmaDuAdjType != 25) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], duration case out of handle!!\n"));
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 23);
- pCoexDm->psTdmaDuAdjType = 23;
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], 40MHz\n"));
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 23)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 24);
- pCoexDm->psTdmaDuAdjType = 24;
- }
- else if(pCoexDm->curPsTdma == 24)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 25);
- pCoexDm->psTdmaDuAdjType = 25;
- }
- else if(pCoexDm->curPsTdma == 25)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 27);
- pCoexDm->psTdmaDuAdjType = 27;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 27)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 25);
- pCoexDm->psTdmaDuAdjType = 25;
- }
- else if(pCoexDm->curPsTdma == 25)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 24);
- pCoexDm->psTdmaDuAdjType = 24;
- }
- else if(pCoexDm->curPsTdma == 24)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 23);
- pCoexDm->psTdmaDuAdjType = 23;
- }
- }
- // error handle, if not in the following state,
- // set psTdma again.
- if( (pCoexDm->psTdmaDuAdjType != 23) &&
- (pCoexDm->psTdmaDuAdjType != 24) &&
- (pCoexDm->psTdmaDuAdjType != 25) &&
- (pCoexDm->psTdmaDuAdjType != 27) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], duration case out of handle!!\n"));
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 24);
- pCoexDm->psTdmaDuAdjType = 24;
- }
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ACL only busy\n"));
- if (result == -1)
- {
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- pCoexDm->psTdmaDuAdjType = 1;
- }
- }
-
- // error handle, if not in the following state,
- // set psTdma again.
- if( (pCoexDm->psTdmaDuAdjType != 1) &&
- (pCoexDm->psTdmaDuAdjType != 2) &&
- (pCoexDm->psTdmaDuAdjType != 9) &&
- (pCoexDm->psTdmaDuAdjType != 11) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], duration case out of handle!!\n"));
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- }
- }
- }
-
- // if current PsTdma not match with the recorded one (when scan, dhcp...),
- // then we have to adjust it back to the previous record one.
- if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
- pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
-
- if( !bScan && !bLink && !bRoam)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
- }
- }
- pCoexDm->psTdmaMonitorCnt++;
-}
-
-
-VOID
-halbtc8723a1ant_CoexForWifiConnect(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
- u1Byte btState, btInfoOriginal=0;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
-
- btState = pCoexDm->btStatus;
- btInfoOriginal = pCoexSta->btInfoC2h[BT_INFO_SRC_8723A_1ANT_BT_RSP][0];
-
- if(bWifiConnected)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi connected!!\n"));
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
-
- if( !bWifiBusy &&
- ((BT_STATE_8723A_1ANT_NO_CONNECTION == btState) ||
- (BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], [Wifi is idle] or [Bt is non connected idle or Bt is connected idle]!!\n"));
-
- if(BT_STATE_8723A_1ANT_NO_CONNECTION == btState)
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
- else if(BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
- }
- else
- {
- if( (BT_STATE_8723A_1ANT_SCO_ONLY_BUSY == btState) ||
- (BT_STATE_8723A_1ANT_ACL_SCO_BUSY == btState) ||
- (BT_STATE_8723A_1ANT_HID_BUSY == btState) ||
- (BT_STATE_8723A_1ANT_HID_SCO_BUSY == btState) )
- {
- pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, 0x60);
- }
- else
- {
- pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
- }
- switch(btState)
- {
- case BT_STATE_8723A_1ANT_NO_CONNECTION:
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
- break;
- case BT_STATE_8723A_1ANT_CONNECT_IDLE:
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- break;
- case BT_STATE_8723A_1ANT_INQ_OR_PAG:
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- break;
- case BT_STATE_8723A_1ANT_SCO_ONLY_BUSY:
- case BT_STATE_8723A_1ANT_ACL_SCO_BUSY:
- case BT_STATE_8723A_1ANT_HID_BUSY:
- case BT_STATE_8723A_1ANT_HID_SCO_BUSY:
- halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist);
- break;
- case BT_STATE_8723A_1ANT_ACL_ONLY_BUSY:
- if (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP)
- {
- halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist);
- }
- else if(btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- }
- else if( (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP) &&
- (btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP) )
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- }
- else
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- }
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], error!!!, undefined case in halbtc8723a1ant_CoexForWifiConnect()!!\n"));
- break;
- }
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is disconnected!!\n"));
- }
-
- pCoexDm->psTdmaGlobalCnt++;
-}
-
-//============================================================
-// work around function start with wa_halbtc8723a1ant_
-//============================================================
-VOID
-wa_halbtc8723a1ant_MonitorC2h(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte tmp1b=0x0;
- u4Byte curC2hTotalCnt=0x0;
- static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0;
-
- curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_1ANT_BT_RSP];
-
- if(curC2hTotalCnt == preC2hTotalCnt)
- {
- sameCntPollingTime++;
- }
- else
- {
- preC2hTotalCnt = curC2hTotalCnt;
- sameCntPollingTime = 0;
- }
-
- if(sameCntPollingTime >= 2)
- {
- tmp1b = pBtCoexist->btc_read_1byte(pBtCoexist, 0x1af);
- if(tmp1b != 0x0)
- {
- pCoexSta->c2hHangDetectCnt++;
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x1af, 0x0);
- }
- }
-}
-
-//============================================================
-// extern function start with EXhalbtc8723a1ant_
-//============================================================
-VOID
-EXhalbtc8723a1ant_InitHwConfig(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
-
- // backup rf 0x1e value
- pCoexDm->btRf0x1eBackup =
- pBtCoexist->btc_get_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
-
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x40, 0x20);
-
- // enable counter statistics
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0x4);
-
- // coex table
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x6cc, 0x0); // 1-Ant coex
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c8, 0xffff); // wifi break table
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c4, 0x55555555); //coex table
-
- // antenna switch control parameter
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x858, 0xaaaaaaaa);
-
- pBtCoexist->btc_write_2byte(pBtCoexist, 0x860, 0x210); //set antenna at wifi side if ANTSW is software control
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x870, 0x300); //SPDT(connected with TRSW) control by hardware PTA
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x874, 0x22804000); //ANTSW keep by GNT_BT
-
- // coexistence parameters
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x778, 0x1); // enable RTK mode PTA
-}
-
-VOID
-EXhalbtc8723a1ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
-
- halbtc8723a1ant_InitCoexDm(pBtCoexist);
-}
-
-VOID
-EXhalbtc8723a1ant_DisplayCoexInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
- pu1Byte cliBuf=pBtCoexist->cli_buf;
- u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
- u4Byte u4Tmp[4];
- BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
- BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
- s4Byte wifiRssi=0, btHsRssi=0;
- u4Byte wifiBw, wifiTrafficDir;
- u1Byte wifiDot11Chnl, wifiHsChnl;
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cliBuf);
-
- if(!pBoardInfo->bt_exist)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cliBuf);
- return;
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
- pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num);
- CL_PRINTF(cliBuf);
-
- if(pBtCoexist->manual_control)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
- CL_PRINTF(cliBuf);
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
- ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
- wifiDot11Chnl, wifiHsChnl, bBtHsOn);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
- pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
- pCoexDm->wifiChnlInfo[2]);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
- wifiRssi, btHsRssi);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
- bLink, bRoam, bScan);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
- (bWifiUnder5G? "5G":"2.4G"),
- ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
- ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
- ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723A_1ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8723A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))),
- pCoexSta->btRssi, pCoexSta->btRetryCnt);
- CL_PRINTF(cliBuf);
-
- if(pStackInfo->bProfileNotified)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
- pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
- }
-
- btInfoExt = pCoexSta->btInfoExt;
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
- (btInfoExt&BIT0)? "Basic rate":"EDR rate");
- CL_PRINTF(cliBuf);
-
- for(i=0; i<BT_INFO_SRC_8723A_1ANT_MAX; i++)
- {
- if(pCoexSta->btInfoC2hCnt[i])
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a1Ant[i], \
- pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
- pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
- pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
- pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
- CL_PRINTF(cliBuf);
- }
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \
- pCoexSta->c2hHangDetectCnt);
- CL_PRINTF(cliBuf);
-
- // Sw mechanism
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \
- pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->limited_dig);
- CL_PRINTF(cliBuf);
-
- // Fw mechanism
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
- CL_PRINTF(cliBuf);
-
- if(!pBtCoexist->manual_control)
- {
- psTdmaCase = pCoexDm->curPsTdma;
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
- pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
- pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
- pCoexDm->psTdmaPara[4], psTdmaCase);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \
- pCoexDm->bCurIgnoreWlanAct);
- CL_PRINTF(cliBuf);
- }
-
- // Hw setting
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
- pCoexDm->btRf0x1eBackup);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x778);
- u1Tmp[1] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x783);
- u1Tmp[2] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x796);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
- u1Tmp[0], u1Tmp[1], u1Tmp[2]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x880);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x40);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
- u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x550);
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x522);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
- u4Tmp[0], u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x484);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc50);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda0);
- u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda4);
- u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda8);
- u4Tmp[3] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xdac);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \
- u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c0);
- u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c4);
- u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c8);
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x6cc);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
- u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \
- pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
- pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
- CL_PRINTF(cliBuf);
-
- // Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x41b);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x41b (mgntQ hang chk == 0xf)", \
- u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-VOID
-EXhalbtc8723a1ant_IpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_IPS_ENTER == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
- halbtc8723a1ant_CoexAllOff(pBtCoexist);
- }
- else if(BTC_IPS_LEAVE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
- //halbtc8723a1ant_InitCoexDm(pBtCoexist);
- }
-}
-
-VOID
-EXhalbtc8723a1ant_LpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_LPS_ENABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
- }
- else if(BTC_LPS_DISABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- }
-}
-
-VOID
-EXhalbtc8723a1ant_ScanNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- BOOLEAN bWifiConnected=FALSE;
-
- halbtc8723a1ant_NotifyFwScan(pBtCoexist, type);
-
- if(pBtCoexist->btInfo.bBtDisabled)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
- }
- else
- {
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(BTC_SCAN_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
- if(!bWifiConnected) // non-connected scan
- {
- //set 0x550[3]=1 before PsTdma
- halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, true);
- }
-
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- }
- else if(BTC_SCAN_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
- if(!bWifiConnected) // non-connected scan
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- }
- else
- {
- halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
- }
- }
- }
-}
-
-VOID
-EXhalbtc8723a1ant_ConnectNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- BOOLEAN bWifiConnected=FALSE;
-
- if(pBtCoexist->btInfo.bBtDisabled)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
- }
- else
- {
- if(BTC_ASSOCIATE_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
- //set 0x550[3]=1 before PsTdma
- halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, true);
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); // extend wifi slot
- }
- else if(BTC_ASSOCIATE_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(!bWifiConnected) // non-connected scan
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- }
- else
- {
- halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
- }
- }
- }
-}
-
-VOID
-EXhalbtc8723a1ant_MediaStatusNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_MEDIA_CONNECT == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
- }
-}
-
-VOID
-EXhalbtc8723a1ant_SpecialPacketNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(type == BTC_PACKET_DHCP)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
- if(pBtCoexist->btInfo.bBtDisabled)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
- }
- else
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 18);
- }
- }
-}
-
-VOID
-EXhalbtc8723a1ant_BtInfoNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN pu1Byte tmpBuf,
- IN u1Byte length
- )
-{
- u1Byte btInfo=0;
- u1Byte i, rspSource=0;
- BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, bForceLps=FALSE;
-
- pCoexSta->bC2hBtInfoReqSent = FALSE;
-
- rspSource = BT_INFO_SRC_8723A_1ANT_BT_RSP;
- pCoexSta->btInfoC2hCnt[rspSource]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
- for(i=0; i<length; i++)
- {
- pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
- if(i == 0)
- btInfo = tmpBuf[i];
- if(i == length-1)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
- }
- }
-
- if(BT_INFO_SRC_8723A_1ANT_WIFI_FW != rspSource)
- {
- pCoexSta->btRetryCnt =
- pCoexSta->btInfoC2h[rspSource][1];
-
- pCoexSta->btRssi =
- pCoexSta->btInfoC2h[rspSource][2]*2+10;
-
- pCoexSta->btInfoExt =
- pCoexSta->btInfoC2h[rspSource][3];
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- // check BIT2 first ==> check if bt is under inquiry or page scan
- if(btInfo & BT_INFO_8723A_1ANT_B_INQ_PAGE)
- {
- pCoexSta->bC2hBtInquiryPage = true;
- }
- else
- {
- pCoexSta->bC2hBtInquiryPage = FALSE;
- }
- btInfo &= ~BIT2;
- if(!(btInfo & BIT0))
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_NO_CONNECTION;
- bForceLps = FALSE;
- }
- else
- {
- bForceLps = true;
- if(btInfo == 0x1)
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_CONNECT_IDLE;
- }
- else if(btInfo == 0x9)
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_ONLY_BUSY;
- bBtBusy = true;
- }
- else if(btInfo == 0x13)
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_SCO_ONLY_BUSY;
- bBtBusy = true;
- }
- else if(btInfo == 0x1b)
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_SCO_BUSY;
- bBtBusy = true;
- }
- else if(btInfo == 0x29)
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_BUSY;
- bBtBusy = true;
- }
- else if(btInfo == 0x3b)
- {
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_SCO_BUSY;
- bBtBusy = true;
- }
- }
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bBtBusy);
- if(bForceLps)
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- else
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
-
- if( (BT_STATE_8723A_1ANT_NO_CONNECTION == pCoexDm->btStatus) ||
- (BT_STATE_8723A_1ANT_CONNECT_IDLE == pCoexDm->btStatus) )
- {
- if(pCoexSta->bC2hBtInquiryPage)
- pCoexDm->btStatus = BT_STATE_8723A_1ANT_INQ_OR_PAG;
- }
-}
-
-VOID
-EXhalbtc8723a1ant_StackOperationNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
- }
- else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
- }
-}
-
-VOID
-EXhalbtc8723a1ant_HaltNotify(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- halbtc8723a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
-
- halbtc8723a1ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE);
- halbtc8723a1ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE);
-
- halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
- EXhalbtc8723a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
-}
-
-VOID
-EXhalbtc8723a1ant_Periodical(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE, bWifiConnected=FALSE;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 1Ant Periodical!!\n"));
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
-
- // work around for c2h hang
- wa_halbtc8723a1ant_MonitorC2h(pBtCoexist);
-
- halbtc8723a1ant_QueryBtInfo(pBtCoexist);
- halbtc8723a1ant_MonitorBtCtr(pBtCoexist);
- halbtc8723a1ant_MonitorBtEnableDisable(pBtCoexist);
-
-
- if(bScan)
- return;
- if(bLink)
- return;
-
- if(bWifiConnected)
- {
- if(pBtCoexist->btInfo.bBtDisabled)
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
-
- halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
- }
- else
- {
- halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a1ant_CoexForWifiConnect(pBtCoexist);
- }
- }
- else
- {
- halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
- }
-}
-
-
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.h b/drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.h
deleted file mode 100644
index 60992f59eb37..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/habtc8723a1ant.h
+++ /dev/null
@@ -1,176 +0,0 @@
-//===========================================
-// The following is for 8723A 1Ant BT Co-exist definition
-//===========================================
-#define BT_INFO_8723A_1ANT_B_FTP BIT7
-#define BT_INFO_8723A_1ANT_B_A2DP BIT6
-#define BT_INFO_8723A_1ANT_B_HID BIT5
-#define BT_INFO_8723A_1ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8723A_1ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8723A_1ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8723A_1ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8723A_1ANT_B_CONNECTION BIT0
-
-typedef enum _BT_STATE_8723A_1ANT{
- BT_STATE_8723A_1ANT_DISABLED = 0,
- BT_STATE_8723A_1ANT_NO_CONNECTION = 1,
- BT_STATE_8723A_1ANT_CONNECT_IDLE = 2,
- BT_STATE_8723A_1ANT_INQ_OR_PAG = 3,
- BT_STATE_8723A_1ANT_ACL_ONLY_BUSY = 4,
- BT_STATE_8723A_1ANT_SCO_ONLY_BUSY = 5,
- BT_STATE_8723A_1ANT_ACL_SCO_BUSY = 6,
- BT_STATE_8723A_1ANT_HID_BUSY = 7,
- BT_STATE_8723A_1ANT_HID_SCO_BUSY = 8,
- BT_STATE_8723A_1ANT_MAX
-}BT_STATE_8723A_1ANT, *PBT_STATE_8723A_1ANT;
-
-#define BTC_RSSI_COEX_THRESH_TOL_8723A_1ANT 2
-
-typedef enum _BT_INFO_SRC_8723A_1ANT{
- BT_INFO_SRC_8723A_1ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8723A_1ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8723A_1ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8723A_1ANT_MAX
-}BT_INFO_SRC_8723A_1ANT,*PBT_INFO_SRC_8723A_1ANT;
-
-typedef enum _BT_8723A_1ANT_BT_STATUS{
- BT_8723A_1ANT_BT_STATUS_IDLE = 0x0,
- BT_8723A_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8723A_1ANT_BT_STATUS_NON_IDLE = 0x2,
- BT_8723A_1ANT_BT_STATUS_MAX
-}BT_8723A_1ANT_BT_STATUS,*PBT_8723A_1ANT_BT_STATUS;
-
-typedef enum _BT_8723A_1ANT_COEX_ALGO{
- BT_8723A_1ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8723A_1ANT_COEX_ALGO_SCO = 0x1,
- BT_8723A_1ANT_COEX_ALGO_HID = 0x2,
- BT_8723A_1ANT_COEX_ALGO_A2DP = 0x3,
- BT_8723A_1ANT_COEX_ALGO_PANEDR = 0x4,
- BT_8723A_1ANT_COEX_ALGO_PANHS = 0x5,
- BT_8723A_1ANT_COEX_ALGO_PANEDR_A2DP = 0x6,
- BT_8723A_1ANT_COEX_ALGO_PANEDR_HID = 0x7,
- BT_8723A_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x8,
- BT_8723A_1ANT_COEX_ALGO_HID_A2DP = 0x9,
- BT_8723A_1ANT_COEX_ALGO_MAX
-}BT_8723A_1ANT_COEX_ALGO,*PBT_8723A_1ANT_COEX_ALGO;
-
-typedef struct _COEX_DM_8723A_1ANT{
- // fw mechanism
- BOOLEAN bCurIgnoreWlanAct;
- BOOLEAN bPreIgnoreWlanAct;
- u1Byte prePsTdma;
- u1Byte curPsTdma;
- u1Byte psTdmaPara[5];
- u1Byte psTdmaDuAdjType;
- u4Byte psTdmaMonitorCnt;
- u4Byte psTdmaGlobalCnt;
- BOOLEAN bResetTdmaAdjust;
- BOOLEAN bPrePsTdmaOn;
- BOOLEAN bCurPsTdmaOn;
-
- // sw mechanism
- BOOLEAN bPreRfRxLpfShrink;
- BOOLEAN bCurRfRxLpfShrink;
- u4Byte btRf0x1eBackup;
- BOOLEAN bPreLowPenaltyRa;
- BOOLEAN bCurLowPenaltyRa;
- u4Byte preVal0x6c0;
- u4Byte curVal0x6c0;
- u4Byte preVal0x6c8;
- u4Byte curVal0x6c8;
- u1Byte preVal0x6cc;
- u1Byte curVal0x6cc;
- BOOLEAN limited_dig;
-
- // algorithm related
- u1Byte preAlgorithm;
- u1Byte curAlgorithm;
- u1Byte btStatus;
- u1Byte wifiChnlInfo[3];
-} COEX_DM_8723A_1ANT, *PCOEX_DM_8723A_1ANT;
-
-typedef struct _COEX_STA_8723A_1ANT{
- u4Byte highPriorityTx;
- u4Byte highPriorityRx;
- u4Byte lowPriorityTx;
- u4Byte lowPriorityRx;
- u1Byte btRssi;
- u1Byte preBtRssiState;
- u1Byte preBtRssiState1;
- u1Byte preWifiRssiState[4];
- BOOLEAN bC2hBtInfoReqSent;
- u1Byte btInfoC2h[BT_INFO_SRC_8723A_1ANT_MAX][10];
- u4Byte btInfoC2hCnt[BT_INFO_SRC_8723A_1ANT_MAX];
- BOOLEAN bC2hBtInquiryPage;
- u1Byte btRetryCnt;
- u1Byte btInfoExt;
- //BOOLEAN bHoldForStackOperation;
- //u1Byte bHoldPeriodCnt;
- // this is for c2h hang work-around
- u4Byte c2hHangDetectCnt;
-}COEX_STA_8723A_1ANT, *PCOEX_STA_8723A_1ANT;
-
-//===========================================
-// The following is interface which will notify coex module.
-//===========================================
-VOID
-EXhalbtc8723a1ant_InitHwConfig(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a1ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a1ant_IpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_LpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_ScanNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_ConnectNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_MediaStatusNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_SpecialPacketNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_BtInfoNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN pu1Byte tmpBuf,
- IN u1Byte length
- );
-VOID
-EXhalbtc8723a1ant_StackOperationNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a1ant_HaltNotify(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a1ant_Periodical(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a1ant_DisplayCoexInfo(
- IN PBTC_COEXIST pBtCoexist
- );
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbt_precomp.h b/drivers/staging/rtl8821ae/btcoexist/halbt_precomp.h
deleted file mode 100644
index d538ba3d0a2e..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbt_precomp.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
- ******************************************************************************/
-#ifndef __HALBT_PRECOMP_H__
-#define __HALBT_PRECOMP_H__
-/*************************************************************
- * include files
- *************************************************************/
-#include "../wifi.h"
-#include "../efuse.h"
-#include "../base.h"
-#include "../regd.h"
-#include "../cam.h"
-#include "../ps.h"
-#include "../pci.h"
-#include "../rtl8821ae/reg.h"
-#include "../rtl8821ae/def.h"
-#include "../rtl8821ae/phy.h"
-#include "../rtl8821ae/dm.h"
-#include "../rtl8821ae/fw.h"
-#include "../rtl8821ae/led.h"
-#include "../rtl8821ae/hw.h"
-#include "../rtl8821ae/pwrseqcmd.h"
-#include "../rtl8821ae/pwrseq.h"
-
-#include "halbtcoutsrc.h"
-
-
-#include "halbtc8192e2ant.h"
-#include "halbtc8723b1ant.h"
-#include "halbtc8723b2ant.h"
-
-
-
-#define GetDefaultAdapter(padapter) padapter
-
-
-#define BIT0 0x00000001
-#define BIT1 0x00000002
-#define BIT2 0x00000004
-#define BIT3 0x00000008
-#define BIT4 0x00000010
-#define BIT5 0x00000020
-#define BIT6 0x00000040
-#define BIT7 0x00000080
-#define BIT8 0x00000100
-#define BIT9 0x00000200
-#define BIT10 0x00000400
-#define BIT11 0x00000800
-#define BIT12 0x00001000
-#define BIT13 0x00002000
-#define BIT14 0x00004000
-#define BIT15 0x00008000
-#define BIT16 0x00010000
-#define BIT17 0x00020000
-#define BIT18 0x00040000
-#define BIT19 0x00080000
-#define BIT20 0x00100000
-#define BIT21 0x00200000
-#define BIT22 0x00400000
-#define BIT23 0x00800000
-#define BIT24 0x01000000
-#define BIT25 0x02000000
-#define BIT26 0x04000000
-#define BIT27 0x08000000
-#define BIT28 0x10000000
-#define BIT29 0x20000000
-#define BIT30 0x40000000
-#define BIT31 0x80000000
-
-#define MASKBYTE0 0xff
-#define MASKBYTE1 0xff00
-#define MASKBYTE2 0xff0000
-#define MASKBYTE3 0xff000000
-#define MASKHWORD 0xffff0000
-#define MASKLWORD 0x0000ffff
-#define MASKDWORD 0xffffffff
-#define MASK12BITS 0xfff
-#define MASKH4BITS 0xf0000000
-#define MASKOFDM_D 0xffc00000
-#define MASKCCK 0x3f3f3f3f
-
-#endif /* __HALBT_PRECOMP_H__ */
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.c
deleted file mode 100644
index 1b04530d46bc..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.c
+++ /dev/null
@@ -1,3891 +0,0 @@
-//============================================================
-// Description:
-//
-// This file is for 8192e1ant Co-exist mechanism
-//
-// History
-// 2012/11/15 Cosa first check in.
-//
-//============================================================
-
-//============================================================
-// include files
-//============================================================
-#include "Mp_Precomp.h"
-#if(BT_30_SUPPORT == 1)
-//============================================================
-// Global variables, these are static variables
-//============================================================
-static COEX_DM_8192E_1ANT GLCoexDm8192e1Ant;
-static PCOEX_DM_8192E_1ANT pCoexDm=&GLCoexDm8192e1Ant;
-static COEX_STA_8192E_1ANT GLCoexSta8192e1Ant;
-static PCOEX_STA_8192E_1ANT pCoexSta=&GLCoexSta8192e1Ant;
-
-const char *const GLBtInfoSrc8192e1Ant[]={
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-u4Byte GLCoexVerDate8192e1Ant=20130729;
-u4Byte GLCoexVer8192e1Ant=0x10;
-
-//============================================================
-// local function proto type if needed
-//============================================================
-//============================================================
-// local function start with halbtc8192e1ant_
-//============================================================
-u1Byte
-halbtc8192e1ant_BtRssiState(
- u1Byte levelNum,
- u1Byte rssiThresh,
- u1Byte rssiThresh1
- )
-{
- s4Byte btRssi=0;
- u1Byte btRssiState=pCoexSta->preBtRssiState;
-
- btRssi = pCoexSta->btRssi;
-
- if(levelNum == 2)
- {
- if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
- {
- if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
- {
- btRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
- }
- }
- else
- {
- if(btRssi < rssiThresh)
- {
- btRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
- }
- }
- }
- else if(levelNum == 3)
- {
- if(rssiThresh > rssiThresh1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
- return pCoexSta->preBtRssiState;
- }
-
- if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
- {
- if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
- {
- btRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
- }
- }
- else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
- (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
- {
- if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
- {
- btRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
- }
- else if(btRssi < rssiThresh)
- {
- btRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
- }
- }
- else
- {
- if(btRssi < rssiThresh1)
- {
- btRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
- }
- }
- }
-
- pCoexSta->preBtRssiState = btRssiState;
-
- return btRssiState;
-}
-
-u1Byte
-halbtc8192e1ant_WifiRssiState(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte index,
- IN u1Byte levelNum,
- IN u1Byte rssiThresh,
- IN u1Byte rssiThresh1
- )
-{
- s4Byte wifiRssi=0;
- u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
-
- if(levelNum == 2)
- {
- if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
- {
- if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
- {
- wifiRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
- }
- }
- else
- {
- if(wifiRssi < rssiThresh)
- {
- wifiRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
- }
- }
- }
- else if(levelNum == 3)
- {
- if(rssiThresh > rssiThresh1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
- return pCoexSta->preWifiRssiState[index];
- }
-
- if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
- {
- if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
- {
- wifiRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
- }
- }
- else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
- (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
- {
- if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT))
- {
- wifiRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
- }
- else if(wifiRssi < rssiThresh)
- {
- wifiRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
- }
- }
- else
- {
- if(wifiRssi < rssiThresh1)
- {
- wifiRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
- }
- }
- }
-
- pCoexSta->preWifiRssiState[index] = wifiRssiState;
-
- return wifiRssiState;
-}
-
-VOID
-halbtc8192e1ant_Updatera_mask(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte type,
- IN u4Byte rateMask
- )
-{
- if(BTC_RATE_DISABLE == type)
- {
- pCoexDm->curra_mask |= rateMask; // disable rate
- }
- else if(BTC_RATE_ENABLE == type)
- {
- pCoexDm->curra_mask &= ~rateMask; // enable rate
- }
-
- if( bForceExec || (pCoexDm->prera_mask != pCoexDm->curra_mask))
- {
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_UPDATE_ra_mask, &pCoexDm->curra_mask);
- }
- pCoexDm->prera_mask = pCoexDm->curra_mask;
-}
-
-VOID
-halbtc8192e1ant_MonitorBtCtr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u4Byte regHPTxRx, regLPTxRx, u4Tmp;
- u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
- u1Byte u1Tmp;
-
- regHPTxRx = 0x770;
- regLPTxRx = 0x774;
-
- u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regHPTxRx);
- regHPTx = u4Tmp & MASKLWORD;
- regHPRx = (u4Tmp & MASKHWORD)>>16;
-
- u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regLPTxRx);
- regLPTx = u4Tmp & MASKLWORD;
- regLPRx = (u4Tmp & MASKHWORD)>>16;
-
- pCoexSta->highPriorityTx = regHPTx;
- pCoexSta->highPriorityRx = regHPRx;
- pCoexSta->lowPriorityTx = regLPTx;
- pCoexSta->lowPriorityRx = regLPRx;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
-
- // reset counter
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0xc);
-}
-
-VOID
-halbtc8192e1ant_QueryBtInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- pCoexSta->bC2hBtInfoReqSent = true;
-
- H2C_Parameter[0] |= BIT0; // trigger
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x61, 1, H2C_Parameter);
-}
-
-BOOLEAN
-halbtc8192e1ant_IsWifiStatusChanged(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE;
- BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE;
- BOOLEAN bWifiConnected=FALSE;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
-
- if(bWifiConnected)
- {
- if(bWifiBusy != bPreWifiBusy)
- {
- bPreWifiBusy = bWifiBusy;
- return true;
- }
- if(bUnder4way != bPreUnder4way)
- {
- bPreUnder4way = bUnder4way;
- return true;
- }
- if(bBtHsOn != bPreBtHsOn)
- {
- bPreBtHsOn = bBtHsOn;
- return true;
- }
- }
-
- return FALSE;
-}
-
-VOID
-halbtc8192e1ant_UpdateBtLinkInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
-
- pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist;
- pBtLinkInfo->bScoExist = pCoexSta->bScoExist;
- pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist;
- pBtLinkInfo->bPanExist = pCoexSta->bPanExist;
- pBtLinkInfo->bHidExist = pCoexSta->bHidExist;
-
- // check if Sco only
- if( pBtLinkInfo->bScoExist &&
- !pBtLinkInfo->bA2dpExist &&
- !pBtLinkInfo->bPanExist &&
- !pBtLinkInfo->bHidExist )
- pBtLinkInfo->bScoOnly = true;
- else
- pBtLinkInfo->bScoOnly = FALSE;
-
- // check if A2dp only
- if( !pBtLinkInfo->bScoExist &&
- pBtLinkInfo->bA2dpExist &&
- !pBtLinkInfo->bPanExist &&
- !pBtLinkInfo->bHidExist )
- pBtLinkInfo->bA2dpOnly = true;
- else
- pBtLinkInfo->bA2dpOnly = FALSE;
-
- // check if Pan only
- if( !pBtLinkInfo->bScoExist &&
- !pBtLinkInfo->bA2dpExist &&
- pBtLinkInfo->bPanExist &&
- !pBtLinkInfo->bHidExist )
- pBtLinkInfo->bPanOnly = true;
- else
- pBtLinkInfo->bPanOnly = FALSE;
-
- // check if Hid only
- if( !pBtLinkInfo->bScoExist &&
- !pBtLinkInfo->bA2dpExist &&
- !pBtLinkInfo->bPanExist &&
- pBtLinkInfo->bHidExist )
- pBtLinkInfo->bHidOnly = true;
- else
- pBtLinkInfo->bHidOnly = FALSE;
-}
-
-u1Byte
-halbtc8192e1ant_ActionAlgorithm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
- BOOLEAN bBtHsOn=FALSE;
- u1Byte algorithm=BT_8192E_1ANT_COEX_ALGO_UNDEFINED;
- u1Byte numOfDiffProfile=0;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
-
- if(!pBtLinkInfo->bBtLinkExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n"));
- return algorithm;
- }
-
- if(pBtLinkInfo->bScoExist)
- numOfDiffProfile++;
- if(pBtLinkInfo->bHidExist)
- numOfDiffProfile++;
- if(pBtLinkInfo->bPanExist)
- numOfDiffProfile++;
- if(pBtLinkInfo->bA2dpExist)
- numOfDiffProfile++;
-
- if(numOfDiffProfile == 1)
- {
- if(pBtLinkInfo->bScoExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
- }
- else
- {
- if(pBtLinkInfo->bHidExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
- }
- else if(pBtLinkInfo->bA2dpExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP;
- }
- else if(pBtLinkInfo->bPanExist)
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANHS;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR;
- }
- }
- }
- }
- else if(numOfDiffProfile == 2)
- {
- if(pBtLinkInfo->bScoExist)
- {
- if(pBtLinkInfo->bHidExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
- }
- else if(pBtLinkInfo->bA2dpExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
- }
- else if(pBtLinkInfo->bPanExist)
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- else
- {
- if( pBtLinkInfo->bHidExist &&
- pBtLinkInfo->bA2dpExist )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
- }
- else if( pBtLinkInfo->bHidExist &&
- pBtLinkInfo->bPanExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- else if( pBtLinkInfo->bPanExist &&
- pBtLinkInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP;
- }
- }
- }
- }
- else if(numOfDiffProfile == 3)
- {
- if(pBtLinkInfo->bScoExist)
- {
- if( pBtLinkInfo->bHidExist &&
- pBtLinkInfo->bA2dpExist )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID;
- }
- else if( pBtLinkInfo->bHidExist &&
- pBtLinkInfo->bPanExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- else if( pBtLinkInfo->bPanExist &&
- pBtLinkInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_SCO;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- else
- {
- if( pBtLinkInfo->bHidExist &&
- pBtLinkInfo->bPanExist &&
- pBtLinkInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
- }
- }
- }
- }
- else if(numOfDiffProfile >= 3)
- {
- if(pBtLinkInfo->bScoExist)
- {
- if( pBtLinkInfo->bHidExist &&
- pBtLinkInfo->bPanExist &&
- pBtLinkInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
-
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
- algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- }
-
- return algorithm;
-}
-
-VOID
-halbtc8192e1ant_SetFwDacSwingLevel(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte dacSwingLvl
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- // There are several type of dacswing
- // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
- H2C_Parameter[0] = dacSwingLvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x64, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8192e1ant_SetFwDecBtPwr(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte decBtPwrLvl
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- H2C_Parameter[0] = decBtPwrLvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n",
- decBtPwrLvl, H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x62, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8192e1ant_DecBtPwr(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte decBtPwrLvl
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power level = %d\n",
- (bForceExec? "force to":""), decBtPwrLvl));
- pCoexDm->curBtDecPwrLvl = decBtPwrLvl;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], BtDecPwrLvl=%d, curBtDecPwrLvl=%d\n",
- pCoexDm->preBtDecPwrLvl, pCoexDm->curBtDecPwrLvl));
-
- if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl)
- return;
- }
- halbtc8192e1ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl);
-
- pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl;
-}
-
-VOID
-halbtc8192e1ant_SetFwBtLnaConstrain(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bBtLnaConsOn
- )
-{
- u1Byte H2C_Parameter[2] ={0};
-
- H2C_Parameter[0] = 0x3; // opCode, 0x3=BT_SET_LNA_CONSTRAIN
-
- if(bBtLnaConsOn)
- {
- H2C_Parameter[1] |= BIT0;
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT LNA Constrain: %s, FW write 0x69=0x%x\n",
- (bBtLnaConsOn? "ON!!":"OFF!!"),
- H2C_Parameter[0]<<8|H2C_Parameter[1]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x69, 2, H2C_Parameter);
-}
-
-VOID
-halbtc8192e1ant_SetBtLnaConstrain(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bBtLnaConsOn
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Constrain = %s\n",
- (bForceExec? "force":""), ((bBtLnaConsOn)? "ON":"OFF")));
- pCoexDm->bCurBtLnaConstrain = bBtLnaConsOn;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtLnaConstrain=%d, bCurBtLnaConstrain=%d\n",
- pCoexDm->bPreBtLnaConstrain, pCoexDm->bCurBtLnaConstrain));
-
- if(pCoexDm->bPreBtLnaConstrain == pCoexDm->bCurBtLnaConstrain)
- return;
- }
- halbtc8192e1ant_SetFwBtLnaConstrain(pBtCoexist, pCoexDm->bCurBtLnaConstrain);
-
- pCoexDm->bPreBtLnaConstrain = pCoexDm->bCurBtLnaConstrain;
-}
-
-VOID
-halbtc8192e1ant_SetFwBtPsdMode(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte btPsdMode
- )
-{
- u1Byte H2C_Parameter[2] ={0};
-
- H2C_Parameter[0] = 0x2; // opCode, 0x2=BT_SET_PSD_MODE
-
- H2C_Parameter[1] = btPsdMode;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set BT PSD mode=0x%x, FW write 0x69=0x%x\n",
- H2C_Parameter[1],
- H2C_Parameter[0]<<8|H2C_Parameter[1]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x69, 2, H2C_Parameter);
-}
-
-
-VOID
-halbtc8192e1ant_SetBtPsdMode(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte btPsdMode
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT PSD mode = 0x%x\n",
- (bForceExec? "force":""), btPsdMode));
- pCoexDm->bCurBtPsdMode = btPsdMode;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtPsdMode=0x%x, bCurBtPsdMode=0x%x\n",
- pCoexDm->bPreBtPsdMode, pCoexDm->bCurBtPsdMode));
-
- if(pCoexDm->bPreBtPsdMode == pCoexDm->bCurBtPsdMode)
- return;
- }
- halbtc8192e1ant_SetFwBtPsdMode(pBtCoexist, pCoexDm->bCurBtPsdMode);
-
- pCoexDm->bPreBtPsdMode = pCoexDm->bCurBtPsdMode;
-}
-
-
-VOID
-halbtc8192e1ant_SetBtAutoReport(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bEnableAutoReport
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- H2C_Parameter[0] = 0;
-
- if(bEnableAutoReport)
- {
- H2C_Parameter[0] |= BIT0;
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
- (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x68, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8192e1ant_BtAutoReport(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bEnableAutoReport
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s BT Auto report = %s\n",
- (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled")));
- pCoexDm->bCurBtAutoReport = bEnableAutoReport;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
- pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport));
-
- if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport)
- return;
- }
- halbtc8192e1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport);
-
- pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport;
-}
-
-VOID
-halbtc8192e1ant_FwDacSwingLvl(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte fwDacSwingLvl
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n",
- (bForceExec? "force to":""), fwDacSwingLvl));
- pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
- pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
-
- if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
- return;
- }
-
- halbtc8192e1ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
-
- pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
-}
-
-VOID
-halbtc8192e1ant_SetSwRfRxLpfCorner(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bRxRfShrinkOn
- )
-{
- if(bRxRfShrinkOn)
- {
- //Shrink RF Rx LPF corner
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
- }
- else
- {
- //Resume RF Rx LPF corner
- // After initialized, we can use pCoexDm->btRf0x1eBackup
- if(pBtCoexist->initilized)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_RfShrink(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bRxRfShrinkOn
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
- (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
- pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
- pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
-
- if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
- return;
- }
- halbtc8192e1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
-
- pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
-}
-
-VOID
-halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bLowPenaltyRa
- )
-{
- u1Byte tmpU1;
-
- tmpU1 = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4fd);
- tmpU1 |= BIT0;
- if(bLowPenaltyRa)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
- tmpU1 &= ~BIT2;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
- tmpU1 |= BIT2;
- }
-
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x4fd, tmpU1);
-}
-
-VOID
-halbtc8192e1ant_LowPenaltyRa(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bLowPenaltyRa
- )
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
- (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
- pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
- pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
-
- if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
- return;
- }
- halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
-
- pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
-}
-
-VOID
-halbtc8192e1ant_SetDacSwingReg(
- IN PBTC_COEXIST pBtCoexist,
- IN u4Byte level
- )
-{
- u1Byte val=(u1Byte)level;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Write SwDacSwing = 0x%x\n", level));
- pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0x883, 0x3e, val);
-}
-
-VOID
-halbtc8192e1ant_SetSwFullTimeDacSwing(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bSwDacSwingOn,
- IN u4Byte swDacSwingLvl
- )
-{
- if(bSwDacSwingOn)
- {
- halbtc8192e1ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl);
- }
- else
- {
- halbtc8192e1ant_SetDacSwingReg(pBtCoexist, 0x18);
- }
-}
-
-
-VOID
-halbtc8192e1ant_DacSwing(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bDacSwingOn,
- IN u4Byte dacSwingLvl
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
- (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
- pCoexDm->bCurDacSwingOn = bDacSwingOn;
- pCoexDm->curDacSwingLvl = dacSwingLvl;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
- pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
- pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
-
- if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
- (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
- return;
- }
- mdelay(30);
- halbtc8192e1ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
-
- pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
- pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
-}
-
-VOID
-halbtc8192e1ant_SetAdcBackOff(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bAdcBackOff
- )
-{
- if(bAdcBackOff)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level On!\n"));
- pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0x8db, 0x60, 0x3);
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level Off!\n"));
- pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0x8db, 0x60, 0x1);
- }
-}
-
-VOID
-halbtc8192e1ant_AdcBackOff(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bAdcBackOff
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn AdcBackOff = %s\n",
- (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
- pCoexDm->bCurAdcBackOff = bAdcBackOff;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
- pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));
-
- if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
- return;
- }
- halbtc8192e1ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
-
- pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
-}
-
-VOID
-halbtc8192e1ant_SetAgcTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bAgcTableEn
- )
-{
- u1Byte rssiAdjustVal=0;
-
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
- if(bAgcTableEn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x3fa58);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x37a58);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x2fa58);
- rssiAdjustVal = 8;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x39258);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x31258);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x29258);
- }
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
-
- // set rssiAdjustVal for wifi module.
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
-}
-
-
-VOID
-halbtc8192e1ant_AgcTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bAgcTableEn
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n",
- (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
- pCoexDm->bCurAgcTableEn = bAgcTableEn;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
- pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));
-
- if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
- return;
- }
- halbtc8192e1ant_SetAgcTable(pBtCoexist, bAgcTableEn);
-
- pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
-}
-
-VOID
-halbtc8192e1ant_SetCoexTable(
- IN PBTC_COEXIST pBtCoexist,
- IN u4Byte val0x6c0,
- IN u4Byte val0x6c4,
- IN u4Byte val0x6c8,
- IN u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c4, val0x6c4);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x6cc, val0x6cc);
-}
-
-VOID
-halbtc8192e1ant_CoexTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u4Byte val0x6c0,
- IN u4Byte val0x6c4,
- IN u4Byte val0x6c8,
- IN u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
- (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc));
- pCoexDm->curVal0x6c0 = val0x6c0;
- pCoexDm->curVal0x6c4 = val0x6c4;
- pCoexDm->curVal0x6c8 = val0x6c8;
- pCoexDm->curVal0x6cc = val0x6cc;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
- pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
- pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
-
- if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
- (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) &&
- (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
- (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
- return;
- }
- halbtc8192e1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc);
-
- pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
- pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4;
- pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
- pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
-}
-
-VOID
-halbtc8192e1ant_CoexTableWithType(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte type
- )
-{
- switch(type)
- {
- case 0:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3);
- break;
- case 1:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 2:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 3:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3);
- break;
- case 4:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3);
- break;
- case 5:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3);
- break;
- case 6:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 7:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xddffddff, 0xddffddff, 0xffffff, 0x3);
- break;
- case 8:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5afa5afa, 0xffffff, 0x3);
- break;
- case 9:
- halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5f5f5f5f, 0x5f5f5f5f, 0xffffff, 0x3);
- break;
- default:
- break;
- }
-}
-
-VOID
-halbtc8192e1ant_SetFwIgnoreWlanAct(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bEnable
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- if(bEnable)
- {
- H2C_Parameter[0] |= BIT0; // function enable
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x63, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8192e1ant_IgnoreWlanAct(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bEnable
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
- (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
- pCoexDm->bCurIgnoreWlanAct = bEnable;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
- pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
-
- if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
- return;
- }
- halbtc8192e1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
-
- pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
-}
-
-VOID
-halbtc8192e1ant_SetFwPstdma(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte byte1,
- IN u1Byte byte2,
- IN u1Byte byte3,
- IN u1Byte byte4,
- IN u1Byte byte5
- )
-{
- u1Byte H2C_Parameter[5] ={0};
-
- H2C_Parameter[0] = byte1;
- H2C_Parameter[1] = byte2;
- H2C_Parameter[2] = byte3;
- H2C_Parameter[3] = byte4;
- H2C_Parameter[4] = byte5;
-
- pCoexDm->psTdmaPara[0] = byte1;
- pCoexDm->psTdmaPara[1] = byte2;
- pCoexDm->psTdmaPara[2] = byte3;
- pCoexDm->psTdmaPara[3] = byte4;
- pCoexDm->psTdmaPara[4] = byte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
- H2C_Parameter[0],
- H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x60, 5, H2C_Parameter);
-}
-
-VOID
-halbtc8192e1ant_SetLpsRpwm(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte lpsVal,
- IN u1Byte rpwmVal
- )
-{
- u1Byte lps=lpsVal;
- u1Byte rpwm=rpwmVal;
-
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_1ANT_LPS, &lps);
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_1ANT_RPWM, &rpwm);
-}
-
-VOID
-halbtc8192e1ant_LpsRpwm(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte lpsVal,
- IN u1Byte rpwmVal
- )
-{
- BOOLEAN bForceExecPwrCmd=FALSE;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
- (bForceExec? "force to":""), lpsVal, rpwmVal));
- pCoexDm->curLps = lpsVal;
- pCoexDm->curRpwm = rpwmVal;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preLps/curLps=0x%x/0x%x, preRpwm/curRpwm=0x%x/0x%x!!\n",
- pCoexDm->preLps, pCoexDm->curLps, pCoexDm->preRpwm, pCoexDm->curRpwm));
-
- if( (pCoexDm->preLps == pCoexDm->curLps) &&
- (pCoexDm->preRpwm == pCoexDm->curRpwm) )
- {
- return;
- }
- }
- halbtc8192e1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal);
-
- pCoexDm->preLps = pCoexDm->curLps;
- pCoexDm->preRpwm = pCoexDm->curRpwm;
-}
-
-VOID
-halbtc8192e1ant_SwMechanism1(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bShrinkRxLPF,
- IN BOOLEAN bLowPenaltyRA,
- IN BOOLEAN limited_dig,
- IN BOOLEAN bBTLNAConstrain
- )
-{
- //halbtc8192e1ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF);
- //halbtc8192e1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA);
-
- //no limited DIG
- //halbtc8192e1ant_SetBtLnaConstrain(pBtCoexist, NORMAL_EXEC, bBTLNAConstrain);
-}
-
-VOID
-halbtc8192e1ant_SwMechanism2(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bAGCTableShift,
- IN BOOLEAN bADCBackOff,
- IN BOOLEAN bSWDACSwing,
- IN u4Byte dacSwingLvl
- )
-{
- //halbtc8192e1ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift);
- //halbtc8192e1ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff);
- //halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl);
-}
-
-VOID
-halbtc8192e1ant_PsTdma(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bTurnOn,
- IN u1Byte type
- )
-{
- BOOLEAN bTurnOnByCnt=FALSE;
- u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
- (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
- pCoexDm->bCurPsTdmaOn = bTurnOn;
- pCoexDm->curPsTdma = type;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
- pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
- pCoexDm->prePsTdma, pCoexDm->curPsTdma));
-
- if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
- (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
- return;
- }
- if(bTurnOn)
- {
- switch(type)
- {
- default:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x2c, 0x03, 0x10, 0x50);
- break;
- case 1:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x2c, 0x03, 0x10, 0x50);
- rssiAdjustVal = 11;
- break;
- case 2:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x03, 0x10, 0x50);
- rssiAdjustVal = 14;
- break;
- case 3:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x40);
- break;
- case 4:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
- rssiAdjustVal = 17;
- break;
- case 5:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x31, 0x0);
- break;
- case 6:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x0, 0x0);
- break;
- case 7:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0);
- break;
- case 8:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
- break;
- case 9:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1e, 0x03, 0x10, 0x50);
- rssiAdjustVal = 18;
- break;
- case 10:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40);
- break;
- case 11:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x12, 0x03, 0x10, 0x50);
- rssiAdjustVal = 20;
- break;
- case 12:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xeb, 0xa, 0x3, 0x31, 0x18);
- break;
-
- case 15:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0);
- break;
- case 16:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0);
- rssiAdjustVal = 18;
- break;
-
- case 18:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0);
- rssiAdjustVal = 14;
- break;
-
- case 20:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0x25, 0x25, 0x0, 0x0);
- break;
- case 21:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x20, 0x3, 0x10, 0x40);
- break;
- case 22:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0x8, 0x8, 0x0, 0x40);
- break;
- case 23:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18);
- rssiAdjustVal = 22;
- break;
- case 24:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18);
- rssiAdjustVal = 22;
- break;
- case 25:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
- rssiAdjustVal = 22;
- break;
- case 26:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18);
- rssiAdjustVal = 22;
- break;
- case 27:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98);
- rssiAdjustVal = 22;
- break;
- case 28:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0);
- break;
- case 29:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10);
- break;
- case 30:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0);
- break;
- case 31:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58);
- break;
- case 32:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0xa, 0x3, 0x31, 0x90);
- break;
- case 33:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90);
- break;
- case 34:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x10);
- break;
- case 35:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x0, 0x10);
- break;
- case 36:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50);
- break;
- case 37:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x25, 0x3, 0x10, 0x50);
- break;
- case 38:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90);
- break;
- }
- }
- else
- {
- // disable PS tdma
- switch(type)
- {
- case 8: //0x778 = 1, ant2PTA
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x4);
- break;
- case 0: //0x778 = 1, ant2BT
- default:
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
- mdelay(5);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x20);
- break;
- case 9: //0x778 = 1, ant2WIFI
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x4);
- break;
- case 10: //0x778 = 3, ant2BT
- halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
- mdelay(5);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x20);
- break;
- }
- }
- rssiAdjustVal =0;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal);
-
- // update pre state
- pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
- pCoexDm->prePsTdma = pCoexDm->curPsTdma;
-}
-
-VOID
-halbtc8192e1ant_SetSwitchSsType(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte ssType
- )
-{
- u1Byte mimoPs=BTC_MIMO_PS_DYNAMIC;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], REAL set SS Type = %d\n", ssType));
-
- if(ssType == 1)
- {
- halbtc8192e1ant_Updatera_mask(pBtCoexist, FORCE_EXEC, BTC_RATE_DISABLE, 0xfff00000); // disable 2ss
- halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
- // switch ofdm path
- pBtCoexist->btc_write_1byte(pBtCoexist, 0xc04, 0x11);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0xd04, 0x1);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x90c, 0x81111111);
- // switch cck patch
- pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0xe77, 0x4, 0x1);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0xa07, 0x81);
- mimoPs=BTC_MIMO_PS_STATIC;
- }
- else if(ssType == 2)
- {
- halbtc8192e1ant_Updatera_mask(pBtCoexist, FORCE_EXEC, BTC_RATE_ENABLE, 0xfff00000); // enable 2ss
- halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0xc04, 0x33);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0xd04, 0x3);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x90c, 0x81121313);
- pBtCoexist->btc_write_1byte_bitmask(pBtCoexist, 0xe77, 0x4, 0x0);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0xa07, 0x41);
- mimoPs=BTC_MIMO_PS_DYNAMIC;
- }
-
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimoPs); // set rx 1ss or 2ss
-}
-
-VOID
-halbtc8192e1ant_SwitchSsType(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte newSsType
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], %s Switch SS Type = %d\n",
- (bForceExec? "force to":""), newSsType));
- pCoexDm->curSsType = newSsType;
-
- if(!bForceExec)
- {
- if(pCoexDm->preSsType == pCoexDm->curSsType)
- return;
- }
- halbtc8192e1ant_SetSwitchSsType(pBtCoexist, pCoexDm->curSsType);
-
- pCoexDm->preSsType = pCoexDm->curSsType;
-}
-
-VOID
-halbtc8192e1ant_CoexAllOff(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
-
- // sw all off
- halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
-
- // hw all off
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
-}
-
-BOOLEAN
-halbtc8192e1ant_IsCommonAction(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
-
- if(!bWifiConnected &&
- BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"));
- halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
- bCommon = true;
- }
- else if(bWifiConnected &&
- (BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n"));
- halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
- bCommon = true;
- }
- else if(!bWifiConnected &&
- (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"));
- halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
- bCommon = true;
- }
- else if(bWifiConnected &&
- (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n"));
- halbtc8192e1ant_SwMechanism1(pBtCoexist,true,true,true,true);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
- bCommon = true;
- }
- else if(!bWifiConnected &&
- (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
- halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
- bCommon = true;
- }
- else
- {
- halbtc8192e1ant_SwMechanism1(pBtCoexist,true,true,true,true);
-
- bCommon = FALSE;
- }
-
- return bCommon;
-}
-
-
-VOID
-halbtc8192e1ant_TdmaDurationAdjustForAcl(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte wifiStatus
- )
-{
- static s4Byte up,dn,m,n,WaitCount;
- s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
- u1Byte retryCount=0, btInfoExt;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n"));
-
- if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
- (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
- (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
- {
- if( pCoexDm->curPsTdma != 1 &&
- pCoexDm->curPsTdma != 2 &&
- pCoexDm->curPsTdma != 3 &&
- pCoexDm->curPsTdma != 9 )
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
-
- up = 0;
- dn = 0;
- m = 1;
- n= 3;
- result = 0;
- WaitCount = 0;
- }
- return;
- }
-
- if(!pCoexDm->bAutoTdmaAdjust)
- {
- pCoexDm->bAutoTdmaAdjust = true;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- //============
- up = 0;
- dn = 0;
- m = 1;
- n= 3;
- result = 0;
- WaitCount = 0;
- }
- else
- {
- //acquire the BT TRx retry count from BT_Info byte2
- retryCount = pCoexSta->btRetryCnt;
- btInfoExt = pCoexSta->btInfoExt;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
- up, dn, m, n, WaitCount));
- result = 0;
- WaitCount++;
-
- if(retryCount == 0) // no retry in the last 2-second duration
- {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
- {
- WaitCount = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
- }
- }
- else if (retryCount <= 3) // <=3 retry in the last 2-second duration
- {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
- {
- if (WaitCount <= 2)
- m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^
- else
- m = 1;
-
- if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- WaitCount = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
- }
- }
- else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
- {
- if (WaitCount == 1)
- m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^
- else
- m = 1;
-
- if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- WaitCount = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
- }
-
- if(result == -1)
- {
- if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
- ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 1)
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- }
- else if(result == 1)
- {
- if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) &&
- ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) )
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- pCoexDm->psTdmaDuAdjType = 1;
- }
- }
-
- if( pCoexDm->curPsTdma != 1 &&
- pCoexDm->curPsTdma != 2 &&
- pCoexDm->curPsTdma != 9 &&
- pCoexDm->curPsTdma != 11 )
- {
- // recover to previous adjust type
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
- }
- }
-}
-
-u1Byte
-halbtc8192e1ant_PsTdmaTypeByWifiRssi(
- IN s4Byte wifiRssi,
- IN s4Byte preWifiRssi,
- IN u1Byte wifiRssiThresh
- )
-{
- u1Byte psTdmaType=0;
-
- if(wifiRssi > preWifiRssi)
- {
- if(wifiRssi > (wifiRssiThresh+5))
- {
- psTdmaType = 26;
- }
- else
- {
- psTdmaType = 25;
- }
- }
- else
- {
- if(wifiRssi > wifiRssiThresh)
- {
- psTdmaType = 26;
- }
- else
- {
- psTdmaType = 25;
- }
- }
-
- return psTdmaType;
-}
-
-VOID
-halbtc8192e1ant_PsTdmaCheckForPowerSaveState(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bNewPsState
- )
-{
- u1Byte lpsMode=0x0;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode);
-
- if(lpsMode) // already under LPS state
- {
- if(bNewPsState)
- {
- // keep state under LPS, do nothing.
- }
- else
- {
- // will leave LPS state, turn off psTdma first
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- }
- }
- else // NO PS state
- {
- if(bNewPsState)
- {
- // will enter LPS state, turn off psTdma first
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- }
- else
- {
- // keep state under NO PS state, do nothing.
- }
- }
-}
-
-VOID
-halbtc8192e1ant_PowerSaveState(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte psType,
- IN u1Byte lpsVal,
- IN u1Byte rpwmVal
- )
-{
- BOOLEAN bLowPwrDisable=FALSE;
-
- switch(psType)
- {
- case BTC_PS_WIFI_NATIVE:
- // recover to original 32k low power setting
- bLowPwrDisable = FALSE;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
- break;
- case BTC_PS_LPS_ON:
- halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, true);
- halbtc8192e1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal);
- // when coex force to enter LPS, do not enter 32k low power.
- bLowPwrDisable = true;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
- // power save must executed before psTdma.
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- break;
- case BTC_PS_LPS_OFF:
- halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE);
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- break;
- default:
- break;
- }
-}
-
-
-VOID
-halbtc8192e1ant_ActionWifiOnly(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
-}
-
-VOID
-halbtc8192e1ant_MonitorBtEnableDisable(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- static BOOLEAN bPreBtDisabled=FALSE;
- static u4Byte btDisableCnt=0;
- BOOLEAN bBtActive=true, bBtDisabled=FALSE;
-
- // This function check if bt is disabled
-
- if( pCoexSta->highPriorityTx == 0 &&
- pCoexSta->highPriorityRx == 0 &&
- pCoexSta->lowPriorityTx == 0 &&
- pCoexSta->lowPriorityRx == 0)
- {
- bBtActive = FALSE;
- }
- if( pCoexSta->highPriorityTx == 0xffff &&
- pCoexSta->highPriorityRx == 0xffff &&
- pCoexSta->lowPriorityTx == 0xffff &&
- pCoexSta->lowPriorityRx == 0xffff)
- {
- bBtActive = FALSE;
- }
- if(bBtActive)
- {
- btDisableCnt = 0;
- bBtDisabled = FALSE;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
- }
- else
- {
- btDisableCnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
- btDisableCnt));
- if(btDisableCnt >= 2)
- {
- bBtDisabled = true;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
- halbtc8192e1ant_ActionWifiOnly(pBtCoexist);
- }
- }
- if(bPreBtDisabled != bBtDisabled)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
- (bPreBtDisabled ? "disabled":"enabled"),
- (bBtDisabled ? "disabled":"enabled")));
- bPreBtDisabled = bBtDisabled;
- if(!bBtDisabled)
- {
- }
- else
- {
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
- }
- }
-}
-
-//=============================================
-//
-// Software Coex Mechanism start
-//
-//=============================================
-
-// SCO only or SCO+PAN(HS)
-VOID
-halbtc8192e1ant_ActionSco(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-
-VOID
-halbtc8192e1ant_ActionHid(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,FALSE,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-//A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
-VOID
-halbtc8192e1ant_ActionA2dp(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_ActionA2dpPanHs(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_ActionPanEdr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-
-//PAN(HS) only
-VOID
-halbtc8192e1ant_ActionPanHs(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-//PAN(EDR)+A2DP
-VOID
-halbtc8192e1ant_ActionPanEdrA2dp(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_ActionPanEdrHid(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-// HID+A2DP+PAN(EDR)
-VOID
-halbtc8192e1ant_ActionHidA2dpPanEdr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_ActionHidA2dp(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
- wifiRssiState = halbtc8192e1ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
-
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,true,FALSE,0x18);
- }
- }
- else
- {
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,true,true,FALSE,0x18);
- }
- else
- {
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
- }
- }
-}
-
-//=============================================
-//
-// Non-Software Coex Mechanism start
-//
-//=============================================
-VOID
-halbtc8192e1ant_ActionBtInquiry(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
- BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
-
- // Note:
- // Do not do DacSwing here, use original setting.
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- if(bBtHsOn)
- return;
-
- if(!bWifiConnected)
- {
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
- }
- else if( (pBtLinkInfo->bScoExist) ||
- (pBtLinkInfo->bHidOnly) )
- {
- // SCO/HID-only busy
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
- }
- else
- {
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
-
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 30);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
- }
-}
-
-VOID
-halbtc8192e1ant_ActionBtScoHidOnlyBusy(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte wifiStatus
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
- u1Byte btRssiState=BTC_RSSI_STATE_HIGH;
-
- if(BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus)
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
- }
- else
- {
- if(pBtLinkInfo->bHidOnly)
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
- else
- {
- // dec bt power for diff level
- btRssiState = halbtc8192e1ant_BtRssiState(3, 34, 42);
- if( (btRssiState == BTC_RSSI_STATE_LOW) ||
- (btRssiState == BTC_RSSI_STATE_STAY_LOW) )
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- }
- else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) ||
- (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) )
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2);
- }
- else if( (btRssiState == BTC_RSSI_STATE_HIGH) ||
- (btRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 6);
- }
-
- // sw dacSwing
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, true, 0xc);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_ActionHs(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action for HS!!!\n"));
-
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- if(BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
- {
- // error, should not be here
- pCoexDm->errorCondition = 1;
- }
- else if(BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, true, 6);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
- }
- else if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus &&
- !pBtCoexist->bt_link_info.bHidOnly)
- {
- if(pCoexDm->curSsType == 1)
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, true, 6);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10);
- //halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 38);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
- }
- }
- else
- {
- halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
- }
-}
-
-VOID
-halbtc8192e1ant_ActionWifiConnectedBtAclBusy(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte wifiStatus
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
-
- if(pBtLinkInfo->bHidOnly)
- {
- halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus);
- pCoexDm->bAutoTdmaAdjust = FALSE;
- return;
- }
-
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- if( (pBtLinkInfo->bA2dpOnly) ||
- (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) )
- {
- halbtc8192e1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus);
- }
- else if( (pBtLinkInfo->bPanOnly) ||
- (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) )
- {
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->bAutoTdmaAdjust = FALSE;
- }
- else
- {
- if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) ||
- (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) ||
- (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) )
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- else
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->bAutoTdmaAdjust = FALSE;
- }
-
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1);
-}
-
-
-VOID
-halbtc8192e1ant_ActionWifiNotConnected(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // power save state
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
-}
-
-VOID
-halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0);
-}
-
-VOID
-halbtc8192e1ant_ActionWifiConnectedScan(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // power save state
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->bt_link_info.bHidOnly)
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
- else
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
- {
- halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
- }
- else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
- (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
- {
- halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN);
- }
- else
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
-}
-
-
-VOID
-halbtc8192e1ant_ActionWifiConnectedSpecialPacket(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // power save state
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->bt_link_info.bHidOnly)
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
- else
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
- {
- halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT);
- }
- else
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
-}
-
-VOID
-halbtc8192e1ant_ActionWifiConnected(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE;
- BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
- BOOLEAN bUnder4way=FALSE;
- u4Byte wifiBw;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect()===>\n"));
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(!bWifiConnected)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi not connected<===\n"));
- return;
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way);
- if(bUnder4way)
- {
- halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"));
- return;
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
- if(bScan || bLink || bRoam)
- {
- halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"));
- return;
- }
-
- // power save state
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->bt_link_info.bHidOnly)
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x0);
- else
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
- if(!bWifiBusy)
- {
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
- {
- halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
- }
- else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
- (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
- {
- halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE);
- }
- else
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
- }
- else
- {
- if(BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
- else if(BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
- else if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus)
- {
- halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
- }
- else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
- (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
- {
- halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY);
- }
- else
- {
- halbtc8192e1ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0);
- halbtc8192e1ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2);
- }
- }
-}
-
-VOID
-halbtc8192e1ant_RunSwCoexistMechanism(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bWifiUnder5G=FALSE, bWifiBusy=FALSE, bWifiConnected=FALSE;
- u1Byte btInfoOriginal=0, btRetryCnt=0;
- u1Byte algorithm=0;
-
- return;
-
- algorithm = halbtc8192e1ant_ActionAlgorithm(pBtCoexist);
- pCoexDm->curAlgorithm = algorithm;
-
- if(halbtc8192e1ant_IsCommonAction(pBtCoexist))
- {
- }
- else
- {
- switch(pCoexDm->curAlgorithm)
- {
- case BT_8192E_1ANT_COEX_ALGO_SCO:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n"));
- halbtc8192e1ant_ActionSco(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n"));
- halbtc8192e1ant_ActionHid(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n"));
- halbtc8192e1ant_ActionA2dp(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n"));
- halbtc8192e1ant_ActionA2dpPanHs(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n"));
- halbtc8192e1ant_ActionPanEdr(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n"));
- halbtc8192e1ant_ActionPanHs(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n"));
- halbtc8192e1ant_ActionPanEdrA2dp(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_PANEDR_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n"));
- halbtc8192e1ant_ActionPanEdrHid(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n"));
- halbtc8192e1ant_ActionHidA2dpPanEdr(pBtCoexist);
- break;
- case BT_8192E_1ANT_COEX_ALGO_HID_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n"));
- halbtc8192e1ant_ActionHidA2dp(pBtCoexist);
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n"));
- halbtc8192e1ant_CoexAllOff(pBtCoexist);
- break;
- }
- pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
- }
-}
-
-VOID
-halbtc8192e1ant_RunCoexistMechanism(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
- BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n"));
-
- if(pBtCoexist->manual_control)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"));
- return;
- }
-
- if(pBtCoexist->bStopCoexDm)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"));
- return;
- }
-
- if(pCoexSta->bUnderIps)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n"));
- return;
- }
-
- halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- if(pCoexSta->bC2hBtInquiryPage)
- {
- halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
- return;
- }
-
- // 1ss or 2ss
- if(pBtLinkInfo->bScoExist)
- {
- halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
- }
- else if(bBtHsOn)
- {
- if(pBtLinkInfo->bHidOnly)
- halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
- else
- halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1);
- }
- else
- halbtc8192e1ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2);
-
- if(bBtHsOn)
- {
- halbtc8192e1ant_ActionHs(pBtCoexist);
- return;
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(!bWifiConnected)
- {
- BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n"));
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
-
- if(bScan || bLink || bRoam)
- halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
- else
- halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
- }
- else
- {
- halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
- }
-}
-
-VOID
-halbtc8192e1ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // force to reset coex mechanism
- halbtc8192e1ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6);
- halbtc8192e1ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0);
-
- // sw all off
- halbtc8192e1ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE);
- halbtc8192e1ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18);
-
- halbtc8192e1ant_SwitchSsType(pBtCoexist, FORCE_EXEC, 2);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8);
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
-}
-
-//============================================================
-// work around function start with wa_halbtc8192e1ant_
-//============================================================
-//============================================================
-// extern function start with EXhalbtc8192e1ant_
-//============================================================
-VOID
-EXhalbtc8192e1ant_InitHwConfig(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u4Byte u4Tmp=0;
- u16 u2Tmp=0;
- u1Byte u1Tmp=0;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n"));
-
- // backup rf 0x1e value
- pCoexDm->btRf0x1eBackup =
- pBtCoexist->btc_get_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
-
- // antenna sw ctrl to bt
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x4f, 0x6);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x944, 0x24);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x930, 0x700700);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x92c, 0x20);
- if(pBtCoexist->chipInterface == BTC_INTF_USB)
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x64, 0x30430004);
- else
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x64, 0x30030004);
-
- halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0);
-
- // antenna switch control parameter
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x858, 0x55555555);
-
- // coex parameters
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x778, 0x1);
- // 0x790[5:0]=0x5
- u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x790);
- u1Tmp &= 0xc0;
- u1Tmp |= 0x5;
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x790, u1Tmp);
-
- // enable counter statistics
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0x4);
-
- // enable PTA
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x40, 0x20);
- // enable mailbox interface
- u2Tmp = pBtCoexist->btc_read_2byte(pBtCoexist, 0x40);
- u2Tmp |= BIT9;
- pBtCoexist->btc_write_2byte(pBtCoexist, 0x40, u2Tmp);
-
- // enable PTA I2C mailbox
- u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x101);
- u1Tmp |= BIT4;
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x101, u1Tmp);
-
- // enable bt clock when wifi is disabled.
- u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x93);
- u1Tmp |= BIT0;
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x93, u1Tmp);
- // enable bt clock when suspend.
- u1Tmp = pBtCoexist->btc_read_1byte(pBtCoexist, 0x7);
- u1Tmp |= BIT0;
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x7, u1Tmp);
-}
-
-VOID
-EXhalbtc8192e1ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
-
- pBtCoexist->bStopCoexDm = FALSE;
-
- halbtc8192e1ant_InitCoexDm(pBtCoexist);
-}
-
-VOID
-EXhalbtc8192e1ant_DisplayCoexInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
- pu1Byte cliBuf=pBtCoexist->cli_buf;
- u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
- u4Byte u4Tmp[4];
- BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
- BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
- s4Byte wifiRssi=0, btHsRssi=0;
- u4Byte wifiBw, wifiTrafficDir;
- u1Byte wifiDot11Chnl, wifiHsChnl;
- u4Byte fwVer=0, btPatchVer=0;
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cliBuf);
-
- if(pBtCoexist->manual_control)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============");
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
- CL_PRINTF(cliBuf);
- }
- if(pBtCoexist->bStopCoexDm)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============");
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ==========================================");
- CL_PRINTF(cliBuf);
- }
-
- if(!pBoardInfo->bt_exist)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cliBuf);
- return;
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
- pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
- ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \
- GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
- wifiDot11Chnl, wifiHsChnl, bBtHsOn);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
- pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
- pCoexDm->wifiChnlInfo[2]);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
- wifiRssi, btHsRssi);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
- bLink, bRoam, bScan);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
- (bWifiUnder5G? "5G":"2.4G"),
- ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
- ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
- ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle":
- ( (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))),
- pCoexSta->btRssi, pCoexSta->btRetryCnt);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
- pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist);
- CL_PRINTF(cliBuf);
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
-
- btInfoExt = pCoexSta->btInfoExt;
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
- (btInfoExt&BIT0)? "Basic rate":"EDR rate");
- CL_PRINTF(cliBuf);
-
- for(i=0; i<BT_INFO_SRC_8192E_1ANT_MAX; i++)
- {
- if(pCoexSta->btInfoC2hCnt[i])
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e1Ant[i], \
- pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
- pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
- pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
- pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
- CL_PRINTF(cliBuf);
- }
- }
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \
- ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")),
- ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF")),
- pBtCoexist->btInfo.lps1Ant,
- pBtCoexist->btInfo.rpwm_1ant);
- CL_PRINTF(cliBuf);
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type", \
- pCoexDm->curSsType);
- CL_PRINTF(cliBuf);
-
- if(!pBtCoexist->manual_control)
- {
- // Sw mechanism
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig/ btLna]", \
- pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->limited_dig, pCoexDm->bCurBtLnaConstrain);
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
- pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \
- (pBtCoexist->btInfo.reject_agg_pkt? "Yes":"No"), (pBtCoexist->btInfo.b_bt_ctrl_agg_buf_size? "Yes":"No"),
- pBtCoexist->btInfo.aggBufSize);
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \
- pBtCoexist->btInfo.ra_mask);
- CL_PRINTF(cliBuf);
-
- // Fw mechanism
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
- CL_PRINTF(cliBuf);
-
- psTdmaCase = pCoexDm->curPsTdma;
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \
- pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
- pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
- pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \
- pCoexDm->errorCondition);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwrLvl/ IgnWlanAct", \
- pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct);
- CL_PRINTF(cliBuf);
- }
-
- // Hw setting
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
- pCoexDm->btRf0x1eBackup);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc04);
- u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xd04);
- u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x90c);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \
- u4Tmp[0], u4Tmp[1], u4Tmp[2]);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x778);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \
- u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x92c);
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x930);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \
- (u1Tmp[0]), u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x40);
- u1Tmp[1] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4f);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \
- u1Tmp[0], u1Tmp[1]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x550);
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x522);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
- u4Tmp[0], u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc50);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c0);
- u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c4);
- u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c8);
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x6cc);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
- u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \
- pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
- pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
- CL_PRINTF(cliBuf);
-#if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 1)
- halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
-#endif
-
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-VOID
-EXhalbtc8192e1ant_IpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- u4Byte u4Tmp=0;
-
- if(pBtCoexist->manual_control || pBtCoexist->bStopCoexDm)
- return;
-
- if(BTC_IPS_ENTER == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
- pCoexSta->bUnderIps = true;
- halbtc8192e1ant_CoexAllOff(pBtCoexist);
- }
- else if(BTC_IPS_LEAVE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
- pCoexSta->bUnderIps = FALSE;
- }
-}
-
-VOID
-EXhalbtc8192e1ant_LpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(pBtCoexist->manual_control || pBtCoexist->bStopCoexDm)
- return;
-
- if(BTC_LPS_ENABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
- pCoexSta->bUnderLps = true;
- }
- else if(BTC_LPS_DISABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
- pCoexSta->bUnderLps = FALSE;
- }
-}
-
-VOID
-EXhalbtc8192e1ant_ScanNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
-
- if(pBtCoexist->manual_control ||
- pBtCoexist->bStopCoexDm ||
- pBtCoexist->btInfo.bBtDisabled )
- return;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- if(pCoexSta->bC2hBtInquiryPage)
- {
- halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
- return;
- }
- else if(bBtHsOn)
- {
- halbtc8192e1ant_ActionHs(pBtCoexist);
- return;
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(BTC_SCAN_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
- if(!bWifiConnected) // non-connected scan
- {
- halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
- }
- else // wifi is connected
- {
- halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist);
- }
- }
- else if(BTC_SCAN_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
- if(!bWifiConnected) // non-connected scan
- {
- halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
- }
- else
- {
- halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
- }
- }
-}
-
-VOID
-EXhalbtc8192e1ant_ConnectNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
-
- if(pBtCoexist->manual_control ||
- pBtCoexist->bStopCoexDm ||
- pBtCoexist->btInfo.bBtDisabled )
- return;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- if(pCoexSta->bC2hBtInquiryPage)
- {
- halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
- return;
- }
- else if(bBtHsOn)
- {
- halbtc8192e1ant_ActionHs(pBtCoexist);
- return;
- }
-
- if(BTC_ASSOCIATE_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
- halbtc8192e1ant_ActionWifiNotConnectedAssoAuthScan(pBtCoexist);
- }
- else if(BTC_ASSOCIATE_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(!bWifiConnected) // non-connected scan
- {
- halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist);
- }
- else
- {
- halbtc8192e1ant_ActionWifiConnected(pBtCoexist);
- }
- }
-}
-
-VOID
-EXhalbtc8192e1ant_MediaStatusNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- u1Byte H2C_Parameter[3] ={0};
- u4Byte wifiBw;
- u1Byte wifiCentralChnl;
-
- if(pBtCoexist->manual_control ||
- pBtCoexist->bStopCoexDm ||
- pBtCoexist->btInfo.bBtDisabled )
- return;
-
- if(BTC_MEDIA_CONNECT == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
- }
-
- // only 2.4G we need to inform bt the chnl mask
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
- if( (BTC_MEDIA_CONNECT == type) &&
- (wifiCentralChnl <= 14) )
- {
- H2C_Parameter[0] = 0x1;
- H2C_Parameter[1] = wifiCentralChnl;
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- H2C_Parameter[2] = 0x30;
- else
- H2C_Parameter[2] = 0x20;
- }
-
- pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
- pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
- pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66=0x%x\n",
- H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x66, 3, H2C_Parameter);
-}
-
-VOID
-EXhalbtc8192e1ant_SpecialPacketNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- BOOLEAN bBtHsOn=FALSE;
-
- if(pBtCoexist->manual_control ||
- pBtCoexist->bStopCoexDm ||
- pBtCoexist->btInfo.bBtDisabled )
- return;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- if(pCoexSta->bC2hBtInquiryPage)
- {
- halbtc8192e1ant_ActionBtInquiry(pBtCoexist);
- return;
- }
- else if(bBtHsOn)
- {
- halbtc8192e1ant_ActionHs(pBtCoexist);
- return;
- }
-
- if( BTC_PACKET_DHCP == type ||
- BTC_PACKET_EAPOL == type )
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet(%d) notify\n", type));
- halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist);
- }
-}
-
-VOID
-EXhalbtc8192e1ant_BtInfoNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN pu1Byte tmpBuf,
- IN u1Byte length
- )
-{
- PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->bt_link_info;
- u1Byte btInfo=0;
- u1Byte i, rspSource=0;
- static u4Byte setBtPsdMode=0;
- BOOLEAN bBtBusy=FALSE, limited_dig=FALSE;
- BOOLEAN bWifiConnected=FALSE;
- BOOLEAN b_bt_ctrl_agg_buf_size=FALSE;
-
- pCoexSta->bC2hBtInfoReqSent = FALSE;
-
- rspSource = tmpBuf[0]&0xf;
- if(rspSource >= BT_INFO_SRC_8192E_1ANT_MAX)
- rspSource = BT_INFO_SRC_8192E_1ANT_WIFI_FW;
- pCoexSta->btInfoC2hCnt[rspSource]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
- for(i=0; i<length; i++)
- {
- pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
- if(i == 1)
- btInfo = tmpBuf[i];
- if(i == length-1)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
- }
- }
-
- if(pBtCoexist->btInfo.bBtDisabled)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for BT is disabled <===\n"));
- return;
- }
-
- if(pBtCoexist->manual_control)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"));
- return;
- }
- if(pBtCoexist->bStopCoexDm)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Coex STOPPED!!<===\n"));
- return;
- }
-
- if(BT_INFO_SRC_8192E_1ANT_WIFI_FW != rspSource)
- {
- pCoexSta->btRetryCnt = // [3:0]
- pCoexSta->btInfoC2h[rspSource][2]&0xf;
-
- pCoexSta->btRssi =
- pCoexSta->btInfoC2h[rspSource][3]*2+10;
-
- pCoexSta->btInfoExt =
- pCoexSta->btInfoC2h[rspSource][4];
-
- // Here we need to resend some wifi info to BT
- // because bt is reset and loss of the info.
- if( (pCoexSta->btInfoExt & BIT1) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"));
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(bWifiConnected)
- {
- EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT);
- }
- else
- {
- EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
- }
-
- setBtPsdMode = 0;
- }
-
- // test-chip bt patch only rsp the status for BT_RSP,
- // so temporary we consider the following only under BT_RSP
- if(BT_INFO_SRC_8192E_1ANT_BT_RSP == rspSource)
- {
- if( (pCoexSta->btInfoExt & BIT3) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"));
- halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
- }
- else
- {
- // BT already NOT ignore Wlan active, do nothing here.
- }
-#if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
- if( (pCoexSta->btInfoExt & BIT4) )
- {
- // BT auto report already enabled, do nothing
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit4 check, set BT to enable Auto Report!!\n"));
- halbtc8192e1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, true);
- }
-#endif
- }
- }
-
- // check BIT2 first ==> check if bt is under inquiry or page scan
- if(btInfo & BT_INFO_8192E_1ANT_B_INQ_PAGE)
- pCoexSta->bC2hBtInquiryPage = true;
- else
- pCoexSta->bC2hBtInquiryPage = FALSE;
-
- // set link exist status
- if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
- {
- pCoexSta->bBtLinkExist = FALSE;
- pCoexSta->bPanExist = FALSE;
- pCoexSta->bA2dpExist = FALSE;
- pCoexSta->bHidExist = FALSE;
- pCoexSta->bScoExist = FALSE;
- }
- else // connection exists
- {
- pCoexSta->bBtLinkExist = true;
- if(btInfo & BT_INFO_8192E_1ANT_B_FTP)
- pCoexSta->bPanExist = true;
- else
- pCoexSta->bPanExist = FALSE;
- if(btInfo & BT_INFO_8192E_1ANT_B_A2DP)
- pCoexSta->bA2dpExist = true;
- else
- pCoexSta->bA2dpExist = FALSE;
- if(btInfo & BT_INFO_8192E_1ANT_B_HID)
- pCoexSta->bHidExist = true;
- else
- pCoexSta->bHidExist = FALSE;
- if(btInfo & BT_INFO_8192E_1ANT_B_SCO_ESCO)
- pCoexSta->bScoExist = true;
- else
- pCoexSta->bScoExist = FALSE;
- }
-
- halbtc8192e1ant_UpdateBtLinkInfo(pBtCoexist);
-
- if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION))
- {
- pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-connected idle!!!\n"));
- }
- else if(btInfo == BT_INFO_8192E_1ANT_B_CONNECTION) // connection exists but no busy
- {
- pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt connected-idle!!!\n"));
- }
- else if((btInfo&BT_INFO_8192E_1ANT_B_SCO_ESCO) ||
- (btInfo&BT_INFO_8192E_1ANT_B_SCO_BUSY))
- {
- pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_SCO_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt sco busy!!!\n"));
- }
- else if( (btInfo&BT_INFO_8192E_1ANT_B_ACL_BUSY) ||
- (btInfo&BT_INFO_8192E_1ANT_B_A2DP) ||
- (btInfo&BT_INFO_8192E_1ANT_B_FTP) )
- {
- if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus)
- pCoexDm->bAutoTdmaAdjust = FALSE;
- pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_ACL_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt acl busy!!!\n"));
- }
- else
- {
- pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_MAX;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), bt non-defined state!!!\n"));
- }
-
- // ra mask check
- if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist)
- {
- halbtc8192e1ant_Updatera_mask(pBtCoexist, NORMAL_EXEC, BTC_RATE_DISABLE, 0x00000003); // disable tx cck 1M/2M
- }
- else
- {
- halbtc8192e1ant_Updatera_mask(pBtCoexist, NORMAL_EXEC, BTC_RATE_ENABLE, 0x00000003); // enable tx cck 1M/2M
- }
-
- if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) ||
- (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) ||
- (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) )
- {
- bBtBusy = true;
- limited_dig = true;
- if(pBtLinkInfo->bHidExist)
- b_bt_ctrl_agg_buf_size = true;
- }
- else
- {
- bBtBusy = FALSE;
- limited_dig = FALSE;
- }
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
-
- //============================================
- // Aggregation related setting
- //============================================
- // if sco, reject AddBA
- //pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt);
-
- // decide BT control aggregation buf size or not
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &b_bt_ctrl_agg_buf_size);
- // real update aggregation setting
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
- //============================================
-
- pCoexDm->limited_dig = limited_dig;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
-
- halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
-}
-
-VOID
-EXhalbtc8192e1ant_StackOperationNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
- }
- else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
- }
-}
-
-VOID
-EXhalbtc8192e1ant_HaltNotify(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
-
- pBtCoexist->bStopCoexDm = true;
- halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
-
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-
- halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x4f, 0xf);
-
- EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
-}
-
-VOID
-EXhalbtc8192e1ant_PnpNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte pnpState
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n"));
-
- if(BTC_WIFI_PNP_SLEEP == pnpState)
- {
- pBtCoexist->bStopCoexDm = true;
- halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
- }
- else if(BTC_WIFI_PNP_WAKE_UP == pnpState)
- {
-
- }
-}
-
-VOID
-EXhalbtc8192e1ant_Periodical(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- static u1Byte disVerInfoCnt=0;
- u4Byte fwVer=0, btPatchVer=0;
- struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical===========================\n"));
-
- if(disVerInfoCnt <= 5)
- {
- disVerInfoCnt += 1;
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", \
- pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num, pBoardInfo->btdm_ant_pos));
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
- ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion));
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", \
- GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer));
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n"));
- }
-#if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0)
- halbtc8192e1ant_QueryBtInfo(pBtCoexist);
- halbtc8192e1ant_MonitorBtCtr(pBtCoexist);
- halbtc8192e1ant_MonitorBtEnableDisable(pBtCoexist);
-#else
- if( halbtc8192e1ant_IsWifiStatusChanged(pBtCoexist) ||
- pCoexDm->bAutoTdmaAdjust)
- {
- halbtc8192e1ant_RunCoexistMechanism(pBtCoexist);
- }
-#endif
-}
-
-VOID
-EXhalbtc8192e1ant_DbgControl(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte opCode,
- IN u1Byte opLen,
- IN pu1Byte pData
- )
-{
- switch(opCode)
- {
- case BTC_DBG_SET_COEX_NORMAL:
- pBtCoexist->manual_control = FALSE;
- halbtc8192e1ant_InitCoexDm(pBtCoexist);
- break;
- case BTC_DBG_SET_COEX_WIFI_ONLY:
- pBtCoexist->manual_control = true;
- halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
- halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9);
- break;
- case BTC_DBG_SET_COEX_BT_ONLY:
- // todo
- break;
- default:
- break;
- }
-}
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.h b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.h
deleted file mode 100644
index a759b758faef..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e1ant.h
+++ /dev/null
@@ -1,226 +0,0 @@
-//===========================================
-// The following is for 8192E_1ANT BT Co-exist definition
-//===========================================
-#define BT_AUTO_REPORT_ONLY_8192E_1ANT 0
-
-#define BT_INFO_8192E_1ANT_B_FTP BIT7
-#define BT_INFO_8192E_1ANT_B_A2DP BIT6
-#define BT_INFO_8192E_1ANT_B_HID BIT5
-#define BT_INFO_8192E_1ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8192E_1ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8192E_1ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8192E_1ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8192E_1ANT_B_CONNECTION BIT0
-
-#define BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \
- (((_BT_INFO_EXT_&BIT0))? true:FALSE)
-
-#define BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT 2
-
-typedef enum _BT_INFO_SRC_8192E_1ANT{
- BT_INFO_SRC_8192E_1ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8192E_1ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8192E_1ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8192E_1ANT_MAX
-}BT_INFO_SRC_8192E_1ANT,*PBT_INFO_SRC_8192E_1ANT;
-
-typedef enum _BT_8192E_1ANT_BT_STATUS{
- BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8192E_1ANT_BT_STATUS_INQ_PAGE = 0x2,
- BT_8192E_1ANT_BT_STATUS_ACL_BUSY = 0x3,
- BT_8192E_1ANT_BT_STATUS_SCO_BUSY = 0x4,
- BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
- BT_8192E_1ANT_BT_STATUS_MAX
-}BT_8192E_1ANT_BT_STATUS,*PBT_8192E_1ANT_BT_STATUS;
-
-typedef enum _BT_8192E_1ANT_WIFI_STATUS{
- BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4,
- BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5,
- BT_8192E_1ANT_WIFI_STATUS_MAX
-}BT_8192E_1ANT_WIFI_STATUS,*PBT_8192E_1ANT_WIFI_STATUS;
-
-typedef enum _BT_8192E_1ANT_COEX_ALGO{
- BT_8192E_1ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8192E_1ANT_COEX_ALGO_SCO = 0x1,
- BT_8192E_1ANT_COEX_ALGO_HID = 0x2,
- BT_8192E_1ANT_COEX_ALGO_A2DP = 0x3,
- BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS = 0x4,
- BT_8192E_1ANT_COEX_ALGO_PANEDR = 0x5,
- BT_8192E_1ANT_COEX_ALGO_PANHS = 0x6,
- BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
- BT_8192E_1ANT_COEX_ALGO_PANEDR_HID = 0x8,
- BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
- BT_8192E_1ANT_COEX_ALGO_HID_A2DP = 0xa,
- BT_8192E_1ANT_COEX_ALGO_MAX = 0xb,
-}BT_8192E_1ANT_COEX_ALGO,*PBT_8192E_1ANT_COEX_ALGO;
-
-typedef struct _COEX_DM_8192E_1ANT{
- // fw mechanism
- u1Byte preBtDecPwrLvl;
- u1Byte curBtDecPwrLvl;
- BOOLEAN bPreBtLnaConstrain;
- BOOLEAN bCurBtLnaConstrain;
- u1Byte bPreBtPsdMode;
- u1Byte bCurBtPsdMode;
- u1Byte preFwDacSwingLvl;
- u1Byte curFwDacSwingLvl;
- BOOLEAN bCurIgnoreWlanAct;
- BOOLEAN bPreIgnoreWlanAct;
- u1Byte prePsTdma;
- u1Byte curPsTdma;
- u1Byte psTdmaPara[5];
- u1Byte psTdmaDuAdjType;
- BOOLEAN bAutoTdmaAdjust;
- BOOLEAN bPrePsTdmaOn;
- BOOLEAN bCurPsTdmaOn;
- BOOLEAN bPreBtAutoReport;
- BOOLEAN bCurBtAutoReport;
- u1Byte preLps;
- u1Byte curLps;
- u1Byte preRpwm;
- u1Byte curRpwm;
-
- // sw mechanism
- BOOLEAN bPreRfRxLpfShrink;
- BOOLEAN bCurRfRxLpfShrink;
- u4Byte btRf0x1eBackup;
- BOOLEAN bPreLowPenaltyRa;
- BOOLEAN bCurLowPenaltyRa;
- BOOLEAN bPreDacSwingOn;
- u4Byte preDacSwingLvl;
- BOOLEAN bCurDacSwingOn;
- u4Byte curDacSwingLvl;
- BOOLEAN bPreAdcBackOff;
- BOOLEAN bCurAdcBackOff;
- BOOLEAN bPreAgcTableEn;
- BOOLEAN bCurAgcTableEn;
- u4Byte preVal0x6c0;
- u4Byte curVal0x6c0;
- u4Byte preVal0x6c4;
- u4Byte curVal0x6c4;
- u4Byte preVal0x6c8;
- u4Byte curVal0x6c8;
- u1Byte preVal0x6cc;
- u1Byte curVal0x6cc;
- BOOLEAN limited_dig;
-
- // algorithm related
- u1Byte preAlgorithm;
- u1Byte curAlgorithm;
- u1Byte btStatus;
- u1Byte wifiChnlInfo[3];
-
- u1Byte preSsType;
- u1Byte curSsType;
-
- u4Byte prera_mask;
- u4Byte curra_mask;
-
- u1Byte errorCondition;
-} COEX_DM_8192E_1ANT, *PCOEX_DM_8192E_1ANT;
-
-typedef struct _COEX_STA_8192E_1ANT{
- BOOLEAN bBtLinkExist;
- BOOLEAN bScoExist;
- BOOLEAN bA2dpExist;
- BOOLEAN bHidExist;
- BOOLEAN bPanExist;
-
- BOOLEAN bUnderLps;
- BOOLEAN bUnderIps;
- u4Byte highPriorityTx;
- u4Byte highPriorityRx;
- u4Byte lowPriorityTx;
- u4Byte lowPriorityRx;
- u1Byte btRssi;
- u1Byte preBtRssiState;
- u1Byte preWifiRssiState[4];
- BOOLEAN bC2hBtInfoReqSent;
- u1Byte btInfoC2h[BT_INFO_SRC_8192E_1ANT_MAX][10];
- u4Byte btInfoC2hCnt[BT_INFO_SRC_8192E_1ANT_MAX];
- BOOLEAN bC2hBtInquiryPage;
- u1Byte btRetryCnt;
- u1Byte btInfoExt;
-}COEX_STA_8192E_1ANT, *PCOEX_STA_8192E_1ANT;
-
-//===========================================
-// The following is interface which will notify coex module.
-//===========================================
-VOID
-EXhalbtc8192e1ant_InitHwConfig(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8192e1ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8192e1ant_IpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_LpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_ScanNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_ConnectNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_MediaStatusNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_SpecialPacketNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_BtInfoNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN pu1Byte tmpBuf,
- IN u1Byte length
- );
-VOID
-EXhalbtc8192e1ant_StackOperationNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8192e1ant_HaltNotify(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8192e1ant_PnpNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte pnpState
- );
-VOID
-EXhalbtc8192e1ant_Periodical(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8192e1ant_DisplayCoexInfo(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8192e1ant_DbgControl(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte opCode,
- IN u1Byte opLen,
- IN pu1Byte pData
- );
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c
deleted file mode 100644
index d2381794ecc9..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c
+++ /dev/null
@@ -1,4118 +0,0 @@
-/**************************************************************
- * Description:
- *
- * This file is for RTL8192E Co-exist mechanism
- *
- * History
- * 2012/11/15 Cosa first check in.
- *
- **************************************************************/
-
-/**************************************************************
- * include files
- **************************************************************/
-#include "halbt_precomp.h"
-
-/**************************************************************
- * Global variables, these are static variables
- **************************************************************/
-static struct coex_dm_8192e_2ant glcoex_dm_8192e_2ant;
-static struct coex_dm_8192e_2ant *coex_dm = &glcoex_dm_8192e_2ant;
-static struct coex_sta_8192e_2ant glcoex_sta_8192e_2ant;
-static struct coex_sta_8192e_2ant *coex_sta = &glcoex_sta_8192e_2ant;
-
-static const char *const GLBtInfoSrc8192e2Ant[] = {
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-static u32 glcoex_ver_date_8192e_2ant = 20130902;
-static u32 glcoex_ver_8192e_2ant = 0x34;
-
-/**************************************************************
- * local function proto type if needed
- **************************************************************/
-/**************************************************************
- * local function start with halbtc8192e2ant_
- **************************************************************/
-static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh,
- u8 rssi_thresh1)
-{
- int btrssi = coex_sta->bt_rssi;
- u8 btrssi_state = coex_sta->pre_bt_rssi_state;
-
- if (level_num == 2) {
- if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi pre state=LOW\n");
- if (btrssi >= (rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
- btrssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state switch to High\n");
- } else {
- btrssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state stay at Low\n");
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi pre state=HIGH\n");
- if (btrssi < rssi_thresh) {
- btrssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state switch to Low\n");
- } else {
- btrssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state stay at High\n");
- }
- }
- } else if (level_num == 3) {
- if (rssi_thresh > rssi_thresh1) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi thresh error!!\n");
- return coex_sta->pre_bt_rssi_state;
- }
-
- if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi pre state=LOW\n");
- if (btrssi >= (rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
- btrssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state switch to Medium\n");
- } else {
- btrssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state stay at Low\n");
- }
- } else if ((coex_sta->pre_bt_rssi_state ==
- BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_bt_rssi_state ==
- BTC_RSSI_STATE_STAY_MEDIUM)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi pre state=MEDIUM\n");
- if (btrssi >= (rssi_thresh1 +
- BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
- btrssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state switch to High\n");
- } else if (btrssi < rssi_thresh) {
- btrssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state switch to Low\n");
- } else {
- btrssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state stay at Medium\n");
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi pre state=HIGH\n");
- if (btrssi < rssi_thresh1) {
- btrssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state switch to Medium\n");
- } else {
- btrssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "BT Rssi state stay at High\n");
- }
- }
- }
-
- coex_sta->pre_bt_rssi_state = btrssi_state;
-
- return btrssi_state;
-}
-
-static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist *btcoexist,
- u8 index, u8 level_num,
- u8 rssi_thresh, u8 rssi_thresh1)
-{
- int wifirssi = 0;
- u8 wifirssi_state = coex_sta->pre_wifi_rssi_state[index];
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifirssi);
-
- if (level_num == 2) {
- if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_LOW)) {
- if (wifirssi >= (rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
- wifirssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state switch to High\n");
- } else {
- wifirssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state stay at Low\n");
- }
- } else {
- if (wifirssi < rssi_thresh) {
- wifirssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state switch to Low\n");
- } else {
- wifirssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state stay at High\n");
- }
- }
- } else if (level_num == 3) {
- if (rssi_thresh > rssi_thresh1) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE,
- "wifi RSSI thresh error!!\n");
- return coex_sta->pre_wifi_rssi_state[index];
- }
-
- if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_LOW)) {
- if (wifirssi >= (rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
- wifirssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state switch to Medium\n");
- } else {
- wifirssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state stay at Low\n");
- }
- } else if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_MEDIUM)) {
- if (wifirssi >= (rssi_thresh1 +
- BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) {
- wifirssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state switch to High\n");
- } else if (wifirssi < rssi_thresh) {
- wifirssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state switch to Low\n");
- } else {
- wifirssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state stay at Medium\n");
- }
- } else {
- if (wifirssi < rssi_thresh1) {
- wifirssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state switch to Medium\n");
- } else {
- wifirssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "wifi RSSI state stay at High\n");
- }
- }
- }
-
- coex_sta->pre_wifi_rssi_state[index] = wifirssi_state;
-
- return wifirssi_state;
-}
-
-static void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist)
-{
- static bool pre_bt_disabled;
- static u32 bt_disable_cnt;
- bool bt_active = true, bt_disabled = false;
-
- /* This function check if bt is disabled */
-
- if (coex_sta->high_priority_tx == 0 &&
- coex_sta->high_priority_rx == 0 &&
- coex_sta->low_priority_tx == 0 &&
- coex_sta->low_priority_rx == 0)
- bt_active = false;
-
- if (coex_sta->high_priority_tx == 0xffff &&
- coex_sta->high_priority_rx == 0xffff &&
- coex_sta->low_priority_tx == 0xffff &&
- coex_sta->low_priority_rx == 0xffff)
- bt_active = false;
-
- if (bt_active) {
- bt_disable_cnt = 0;
- bt_disabled = false;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
- &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is enabled !!\n");
- } else {
- bt_disable_cnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], bt all counters=0, %d times!!\n",
- bt_disable_cnt);
- if (bt_disable_cnt >= 2) {
- bt_disabled = true;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
- &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is disabled !!\n");
- }
- }
- if (pre_bt_disabled != bt_disabled) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is from %s to %s!!\n",
- (pre_bt_disabled ? "disabled":"enabled"),
- (bt_disabled ? "disabled":"enabled"));
- pre_bt_disabled = bt_disabled;
- }
-}
-
-static u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist,
- u8 sstype, u32 ra_masktype)
-{
- u32 disra_mask = 0x0;
-
- switch (ra_masktype) {
- case 0: /* normal mode */
- if (sstype == 2)
- disra_mask = 0x0; /* enable 2ss */
- else
- disra_mask = 0xfff00000;/* disable 2ss */
- break;
- case 1: /* disable cck 1/2 */
- if (sstype == 2)
- disra_mask = 0x00000003;/* enable 2ss */
- else
- disra_mask = 0xfff00003;/* disable 2ss */
- break;
- case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
- if (sstype == 2)
- disra_mask = 0x0001f1f7;/* enable 2ss */
- else
- disra_mask = 0xfff1f1f7;/* disable 2ss */
- break;
- default:
- break;
- }
-
- return disra_mask;
-}
-
-static void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist,
- bool force_exec, u32 dis_ratemask)
-{
- coex_dm->curra_mask = dis_ratemask;
-
- if (force_exec || (coex_dm->prera_mask != coex_dm->curra_mask))
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_ra_mask,
- &coex_dm->curra_mask);
- coex_dm->prera_mask = coex_dm->curra_mask;
-}
-
-static void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- bool wifi_under_bmode = false;
-
- coex_dm->cur_arfrtype = type;
-
- if (force_exec || (coex_dm->pre_arfrtype != coex_dm->cur_arfrtype)) {
- switch (coex_dm->cur_arfrtype) {
- case 0: /* normal mode */
- btcoexist->btc_write_4byte(btcoexist, 0x430,
- coex_dm->backup_arfr_cnt1);
- btcoexist->btc_write_4byte(btcoexist, 0x434,
- coex_dm->backup_arfr_cnt2);
- break;
- case 1:
- btcoexist->btc_get(btcoexist,
- BTC_GET_BL_WIFI_UNDER_B_MODE,
- &wifi_under_bmode);
- if (wifi_under_bmode) {
- btcoexist->btc_write_4byte(btcoexist, 0x430,
- 0x0);
- btcoexist->btc_write_4byte(btcoexist, 0x434,
- 0x01010101);
- } else {
- btcoexist->btc_write_4byte(btcoexist, 0x430,
- 0x0);
- btcoexist->btc_write_4byte(btcoexist, 0x434,
- 0x04030201);
- }
- break;
- default:
- break;
- }
- }
-
- coex_dm->pre_arfrtype = coex_dm->cur_arfrtype;
-}
-
-static void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- coex_dm->cur_retrylimit_type = type;
-
- if (force_exec || (coex_dm->pre_retrylimit_type !=
- coex_dm->cur_retrylimit_type)) {
- switch (coex_dm->cur_retrylimit_type) {
- case 0: /* normal mode */
- btcoexist->btc_write_2byte(btcoexist, 0x42a,
- coex_dm->backup_retrylimit);
- break;
- case 1: /* retry limit=8 */
- btcoexist->btc_write_2byte(btcoexist, 0x42a,
- 0x0808);
- break;
- default:
- break;
- }
- }
-
- coex_dm->pre_retrylimit_type = coex_dm->cur_retrylimit_type;
-}
-
-static void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- coex_dm->cur_ampdutime_type = type;
-
- if (force_exec || (coex_dm->pre_ampdutime_type !=
- coex_dm->cur_ampdutime_type)) {
- switch (coex_dm->cur_ampdutime_type) {
- case 0: /* normal mode */
- btcoexist->btc_write_1byte(btcoexist, 0x456,
- coex_dm->backup_ampdu_maxtime);
- break;
- case 1: /* AMPDU timw = 0x38 * 32us */
- btcoexist->btc_write_1byte(btcoexist, 0x456, 0x38);
- break;
- default:
- break;
- }
- }
-
- coex_dm->pre_ampdutime_type = coex_dm->cur_ampdutime_type;
-}
-
-static void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist,
- bool force_exec, u8 ra_masktype,
- u8 arfr_type, u8 retrylimit_type,
- u8 ampdutime_type)
-{
- u32 disra_mask = 0x0;
-
- coex_dm->curra_masktype = ra_masktype;
- disra_mask = halbtc8192e2ant_decidera_mask(btcoexist,
- coex_dm->cur_sstype,
- ra_masktype);
- halbtc8192e2ant_Updatera_mask(btcoexist, force_exec, disra_mask);
-
- halbtc8192e2ant_autorate_fallback_retry(btcoexist, force_exec,
- arfr_type);
- halbtc8192e2ant_retrylimit(btcoexist, force_exec, retrylimit_type);
- halbtc8192e2ant_ampdu_maxtime(btcoexist, force_exec, ampdutime_type);
-}
-
-static void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist,
- bool force_exec, bool rej_ap_agg_pkt,
- bool b_bt_ctrl_agg_buf_size,
- u8 agg_buf_size)
-{
- bool reject_rx_agg = rej_ap_agg_pkt;
- bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size;
- u8 rx_agg_size = agg_buf_size;
-
- /*********************************************
- * Rx Aggregation related setting
- *********************************************/
- btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
- &reject_rx_agg);
- /* decide BT control aggregation buf size or not */
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
- &bt_ctrl_rx_agg_size);
- /* aggregation buf size, only work
- * when BT control Rx aggregation size. */
- btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
- /* real update aggregation setting */
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
-
-
-}
-
-static void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
-{
- u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
- u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
-
- reg_hp_txrx = 0x770;
- reg_lp_txrx = 0x774;
-
- u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
- reg_hp_tx = u32tmp & MASKLWORD;
- reg_hp_rx = (u32tmp & MASKHWORD)>>16;
-
- u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
- reg_lp_tx = u32tmp & MASKLWORD;
- reg_lp_rx = (u32tmp & MASKHWORD)>>16;
-
- coex_sta->high_priority_tx = reg_hp_tx;
- coex_sta->high_priority_rx = reg_hp_rx;
- coex_sta->low_priority_tx = reg_lp_tx;
- coex_sta->low_priority_rx = reg_lp_rx;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex] High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex] Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx);
-
- /* reset counter */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
-}
-
-static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist)
-{
- u8 h2c_parameter[1] = {0};
-
- coex_sta->c2h_bt_info_req_sent = true;
-
- h2c_parameter[0] |= BIT0; /* trigger */
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
-}
-
-static void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool bt_hson = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson);
-
- bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
- bt_link_info->sco_exist = coex_sta->sco_exist;
- bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
- bt_link_info->pan_exist = coex_sta->pan_exist;
- bt_link_info->hid_exist = coex_sta->hid_exist;
-
- /* work around for HS mode. */
- if (bt_hson) {
- bt_link_info->pan_exist = true;
- bt_link_info->bt_link_exist = true;
- }
-
- /* check if Sco only */
- if (bt_link_info->sco_exist &&
- !bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist &&
- !bt_link_info->hid_exist)
- bt_link_info->sco_only = true;
- else
- bt_link_info->sco_only = false;
-
- /* check if A2dp only */
- if (!bt_link_info->sco_exist &&
- bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist &&
- !bt_link_info->hid_exist)
- bt_link_info->a2dp_only = true;
- else
- bt_link_info->a2dp_only = false;
-
- /* check if Pan only */
- if (!bt_link_info->sco_exist &&
- !bt_link_info->a2dp_exist &&
- bt_link_info->pan_exist &&
- !bt_link_info->hid_exist)
- bt_link_info->pan_only = true;
- else
- bt_link_info->pan_only = false;
-
- /* check if Hid only */
- if (!bt_link_info->sco_exist &&
- !bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist &&
- bt_link_info->hid_exist)
- bt_link_info->hid_only = true;
- else
- bt_link_info->hid_only = false;
-}
-
-static u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
- bool bt_hson = false;
- u8 algorithm = BT_8192E_2ANT_COEX_ALGO_UNDEFINED;
- u8 numOfDiffProfile = 0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson);
-
- if (!bt_link_info->bt_link_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "No BT link exists!!!\n");
- return algorithm;
- }
-
- if (bt_link_info->sco_exist)
- numOfDiffProfile++;
- if (bt_link_info->hid_exist)
- numOfDiffProfile++;
- if (bt_link_info->pan_exist)
- numOfDiffProfile++;
- if (bt_link_info->a2dp_exist)
- numOfDiffProfile++;
-
- if (numOfDiffProfile == 1) {
- if (bt_link_info->sco_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO only\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
- } else {
- if (bt_link_info->hid_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID only\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_HID;
- } else if (bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "A2DP only\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_A2DP;
- } else if (bt_link_info->pan_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "PAN(HS) only\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_PANHS;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "PAN(EDR) only\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_PANEDR;
- }
- }
- }
- } else if (numOfDiffProfile == 2) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + HID\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
- } else if (bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + A2DP ==> SCO\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
- } else if (bt_link_info->pan_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + PAN(HS)\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_SCO_PAN;
- }
- }
- } else {
- if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) {
- if (stack_info->num_of_hid >= 2) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID*2 + A2DP\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID + A2DP\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_HID_A2DP;
- }
- } else if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID + PAN(HS)\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_HID;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID + PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
- }
- } else if (bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "A2DP + PAN(HS)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "A2DP + PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP;
- }
- }
- }
- } else if (numOfDiffProfile == 3) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + HID + A2DP ==> HID\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
- } else if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + HID + PAN(HS)\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + HID + PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_SCO_PAN;
- }
- } else if (bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + A2DP + PAN(HS)\n");
- algorithm = BT_8192E_2ANT_COEX_ALGO_SCO;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO + A2DP + PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- } else {
- if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID + A2DP + PAN(HS)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_HID_A2DP;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "HID + A2DP + PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
- }
- }
- }
- } else if (numOfDiffProfile >= 3) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hson) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "ErrorSCO+HID+A2DP+PAN(HS)\n");
-
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "SCO+HID+A2DP+PAN(EDR)\n");
- algorithm =
- BT_8192E_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- }
-
- return algorithm;
-}
-
-static void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist,
- u8 dac_swinglvl)
-{
- u8 h2c_parameter[1] = {0};
-
- /* There are several type of dacswing
- * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
- h2c_parameter[0] = dac_swinglvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], Set Dac Swing Level=0x%x\n", dac_swinglvl);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x64=0x%x\n", h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
-}
-
-static void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist,
- u8 dec_btpwr_lvl)
-{
- u8 h2c_parameter[1] = {0};
-
- h2c_parameter[0] = dec_btpwr_lvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex] decrease Bt Power level = %d, FW write 0x62=0x%x\n",
- dec_btpwr_lvl, h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter);
-}
-
-static void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist,
- bool force_exec, u8 dec_btpwr_lvl)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s Dec BT power level = %d\n",
- (force_exec ? "force to":""), dec_btpwr_lvl);
- coex_dm->cur_dec_bt_pwr = dec_btpwr_lvl;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], preBtDecPwrLvl=%d, curBtDecPwrLvl=%d\n",
- coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr);
- }
- halbtc8192e2ant_set_fwdec_btpwr(btcoexist, coex_dm->cur_dec_bt_pwr);
-
- coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr;
-}
-
-static void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist,
- bool enable_autoreport)
-{
- u8 h2c_parameter[1] = {0};
-
- h2c_parameter[0] = 0;
-
- if (enable_autoreport)
- h2c_parameter[0] |= BIT0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
- (enable_autoreport ? "Enabled!!":"Disabled!!"),
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
-}
-
-static void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist,
- bool force_exec,
- bool enable_autoreport)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s BT Auto report = %s\n",
- (force_exec ? "force to":""),
- ((enable_autoreport) ? "Enabled":"Disabled"));
- coex_dm->cur_bt_auto_report = enable_autoreport;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex] bPreBtAutoReport=%d, bCurBtAutoReport=%d\n",
- coex_dm->pre_bt_auto_report,
- coex_dm->cur_bt_auto_report);
-
- if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report)
- return;
- }
- halbtc8192e2ant_set_bt_autoreport(btcoexist,
- coex_dm->cur_bt_auto_report);
-
- coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
-}
-
-static void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist,
- bool force_exec, u8 fw_dac_swinglvl)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s set FW Dac Swing level = %d\n",
- (force_exec ? "force to":""), fw_dac_swinglvl);
- coex_dm->cur_fw_dac_swing_lvl = fw_dac_swinglvl;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex] preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
- coex_dm->pre_fw_dac_swing_lvl,
- coex_dm->cur_fw_dac_swing_lvl);
-
- if (coex_dm->pre_fw_dac_swing_lvl ==
- coex_dm->cur_fw_dac_swing_lvl)
- return;
- }
-
- halbtc8192e2ant_setfw_dac_swinglevel(btcoexist,
- coex_dm->cur_fw_dac_swing_lvl);
-
- coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
-}
-
-static void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist,
- bool rx_rf_shrink_on)
-{
- if (rx_rf_shrink_on) {
- /* Shrink RF Rx LPF corner */
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Shrink RF Rx LPF corner!!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
- 0xfffff, 0xffffc);
- } else {
- /* Resume RF Rx LPF corner
- * After initialized, we can use coex_dm->btRf0x1eBackup */
- if (btcoexist->initilized) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Resume RF Rx LPF corner!!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
- 0xfffff,
- coex_dm->bt_rf0x1e_backup);
- }
- }
-}
-
-static void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist,
- bool force_exec, bool rx_rf_shrink_on)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s turn Rx RF Shrink = %s\n",
- (force_exec ? "force to":""), ((rx_rf_shrink_on) ? "ON":"OFF"));
- coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex]bPreRfRxLpfShrink=%d,bCurRfRxLpfShrink=%d\n",
- coex_dm->pre_rf_rx_lpf_shrink,
- coex_dm->cur_rf_rx_lpf_shrink);
-
- if (coex_dm->pre_rf_rx_lpf_shrink ==
- coex_dm->cur_rf_rx_lpf_shrink)
- return;
- }
- halbtc8192e2ant_set_sw_rf_rx_lpf_corner(btcoexist,
- coex_dm->cur_rf_rx_lpf_shrink);
-
- coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink;
-}
-
-static void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist,
- u32 level)
-{
- u8 val = (u8)level;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Write SwDacSwing = 0x%x\n", level);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val);
-}
-
-static void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist,
- bool sw_dac_swingon,
- u32 sw_dac_swinglvl)
-{
- if (sw_dac_swingon)
- halbtc8192e2ant_set_dac_swingreg(btcoexist, sw_dac_swinglvl);
- else
- halbtc8192e2ant_set_dac_swingreg(btcoexist, 0x18);
-}
-
-static void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist,
- bool force_exec, bool dac_swingon,
- u32 dac_swinglvl)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s turn DacSwing=%s, dac_swinglvl=0x%x\n",
- (force_exec ? "force to":""),
- ((dac_swingon) ? "ON":"OFF"), dac_swinglvl);
- coex_dm->cur_dac_swing_on = dac_swingon;
- coex_dm->cur_dac_swing_lvl = dac_swinglvl;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, ",
- coex_dm->pre_dac_swing_on,
- coex_dm->pre_dac_swing_lvl);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
- coex_dm->cur_dac_swing_on,
- coex_dm->cur_dac_swing_lvl);
-
- if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) &&
- (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl))
- return;
- }
- mdelay(30);
- halbtc8192e2ant_setsw_fulltime_dacswing(btcoexist, dac_swingon,
- dac_swinglvl);
-
- coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on;
- coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
-}
-
-static void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist,
- bool agc_table_en)
-{
-
- /* BB AGC Gain Table */
- if (agc_table_en) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], BB Agc Table On!\n");
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x0a1A0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x091B0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x081C0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x071D0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x061E0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x051F0001);
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], BB Agc Table Off!\n");
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa61E0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa51F0001);
- }
-}
-
-static void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist,
- bool force_exec, bool agc_table_en)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s %s Agc Table\n",
- (force_exec ? "force to":""),
- ((agc_table_en) ? "Enable":"Disable"));
- coex_dm->cur_agc_table_en = agc_table_en;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
- coex_dm->pre_agc_table_en, coex_dm->cur_agc_table_en);
-
- if (coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en)
- return;
- }
- halbtc8192e2ant_set_agc_table(btcoexist, agc_table_en);
-
- coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en;
-}
-
-static void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist,
- u32 val0x6c0, u32 val0x6c4,
- u32 val0x6c8, u8 val0x6cc)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0);
- btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4);
- btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8);
- btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc);
- btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
-}
-
-static void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist,
- bool force_exec,
- u32 val0x6c0, u32 val0x6c4,
- u32 val0x6c8, u8 val0x6cc)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s write Coex Table 0x6c0=0x%x, ",
- (force_exec ? "force to":""), val0x6c0);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
- val0x6c4, val0x6c8, val0x6cc);
- coex_dm->cur_val0x6c0 = val0x6c0;
- coex_dm->cur_val0x6c4 = val0x6c4;
- coex_dm->cur_val0x6c8 = val0x6c8;
- coex_dm->cur_val0x6cc = val0x6cc;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, ",
- coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
- coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x,\n",
- coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
- coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc);
-
- if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
- (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
- (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
- (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
- return;
- }
- halbtc8192e2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4,
- val0x6c8, val0x6cc);
-
- coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
- coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
- coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
- coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
-}
-
-static void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- switch (type) {
- case 0:
- halbtc8192e2ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 1:
- halbtc8192e2ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
- 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 2:
- halbtc8192e2ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x5ffb5ffb, 0xffffff, 0x3);
- break;
- case 3:
- halbtc8192e2ant_coex_table(btcoexist, force_exec, 0xdfffdfff,
- 0x5fdb5fdb, 0xffffff, 0x3);
- break;
- case 4:
- halbtc8192e2ant_coex_table(btcoexist, force_exec, 0xdfffdfff,
- 0x5ffb5ffb, 0xffffff, 0x3);
- break;
- default:
- break;
- }
-}
-
-static void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist,
- bool enable)
-{
- u8 h2c_parameter[1] = {0};
-
- if (enable)
- h2c_parameter[0] |= BIT0; /* function enable */
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex]set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n",
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
-}
-
-static void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist,
- bool force_exec, bool enable)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s turn Ignore WlanAct %s\n",
- (force_exec ? "force to":""), (enable ? "ON":"OFF"));
- coex_dm->cur_ignore_wlan_act = enable;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreIgnoreWlanAct = %d ",
- coex_dm->pre_ignore_wlan_act);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "bCurIgnoreWlanAct = %d!!\n",
- coex_dm->cur_ignore_wlan_act);
-
- if (coex_dm->pre_ignore_wlan_act ==
- coex_dm->cur_ignore_wlan_act)
- return;
- }
- halbtc8192e2ant_set_fw_ignore_wlanact(btcoexist, enable);
-
- coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
-}
-
-static void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1,
- u8 byte2, u8 byte3, u8 byte4, u8 byte5)
-{
- u8 h2c_parameter[5] = {0};
-
- h2c_parameter[0] = byte1;
- h2c_parameter[1] = byte2;
- h2c_parameter[2] = byte3;
- h2c_parameter[3] = byte4;
- h2c_parameter[4] = byte5;
-
- coex_dm->ps_tdma_para[0] = byte1;
- coex_dm->ps_tdma_para[1] = byte2;
- coex_dm->ps_tdma_para[2] = byte3;
- coex_dm->ps_tdma_para[3] = byte4;
- coex_dm->ps_tdma_para[4] = byte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
- h2c_parameter[0],
- h2c_parameter[1] << 24 | h2c_parameter[2] << 16 |
- h2c_parameter[3] << 8 | h2c_parameter[4]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
-}
-
-static void halbtc8192e2ant_sw_mechanism1(struct btc_coexist *btcoexist,
- bool shrink_rx_lpf,
- bool low_penalty_ra,
- bool limited_dig,
- bool btlan_constrain)
-{
- halbtc8192e2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf);
-}
-
-static void halbtc8192e2ant_sw_mechanism2(struct btc_coexist *btcoexist,
- bool agc_table_shift,
- bool adc_backoff,
- bool sw_dac_swing,
- u32 dac_swinglvl)
-{
- halbtc8192e2ant_AgcTable(btcoexist, NORMAL_EXEC, agc_table_shift);
- halbtc8192e2ant_DacSwing(btcoexist, NORMAL_EXEC, sw_dac_swing,
- dac_swinglvl);
-}
-
-static void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist,
- bool force_exec, bool turn_on, u8 type)
-{
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s turn %s PS TDMA, type=%d\n",
- (force_exec ? "force to":""), (turn_on ? "ON":"OFF"), type);
- coex_dm->cur_ps_tdma_on = turn_on;
- coex_dm->cur_ps_tdma = type;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
- coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
- coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma);
-
- if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
- (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
- return;
- }
- if (turn_on) {
- switch (type) {
- case 1:
- default:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe1, 0x90);
- break;
- case 2:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x12,
- 0x12, 0xe1, 0x90);
- break;
- case 3:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1c,
- 0x3, 0xf1, 0x90);
- break;
- case 4:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x10,
- 0x3, 0xf1, 0x90);
- break;
- case 5:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0x60, 0x90);
- break;
- case 6:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x12,
- 0x12, 0x60, 0x90);
- break;
- case 7:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1c,
- 0x3, 0x70, 0x90);
- break;
- case 8:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xa3, 0x10,
- 0x3, 0x70, 0x90);
- break;
- case 9:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe1, 0x10);
- break;
- case 10:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x12,
- 0x12, 0xe1, 0x10);
- break;
- case 11:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1c,
- 0x3, 0xf1, 0x10);
- break;
- case 12:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x10,
- 0x3, 0xf1, 0x10);
- break;
- case 13:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe0, 0x10);
- break;
- case 14:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x12,
- 0x12, 0xe0, 0x10);
- break;
- case 15:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1c,
- 0x3, 0xf0, 0x10);
- break;
- case 16:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x12,
- 0x3, 0xf0, 0x10);
- break;
- case 17:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0x61, 0x20,
- 0x03, 0x10, 0x10);
- break;
- case 18:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x5,
- 0x5, 0xe1, 0x90);
- break;
- case 19:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x25,
- 0x25, 0xe1, 0x90);
- break;
- case 20:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x25,
- 0x25, 0x60, 0x90);
- break;
- case 21:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x15,
- 0x03, 0x70, 0x90);
- break;
- case 71:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe1, 0x90);
- break;
- }
- } else {
- /* disable PS tdma */
- switch (type) {
- default:
- case 0:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0x8, 0x0, 0x0,
- 0x0, 0x0);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x4);
- break;
- case 1:
- halbtc8192e2ant_SetFwPstdma(btcoexist, 0x0, 0x0, 0x0,
- 0x8, 0x0);
- mdelay(5);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x20);
- break;
- }
- }
-
- /* update pre state */
- coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
- coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
-}
-
-static void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist,
- u8 sstype)
-{
- u8 mimops = BTC_MIMO_PS_DYNAMIC;
- u32 disra_mask = 0x0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], REAL set SS Type = %d\n", sstype);
-
- disra_mask = halbtc8192e2ant_decidera_mask(btcoexist, sstype,
- coex_dm->curra_masktype);
- halbtc8192e2ant_Updatera_mask(btcoexist, FORCE_EXEC, disra_mask);
-
- if (sstype == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
- /* switch ofdm path */
- btcoexist->btc_write_1byte(btcoexist, 0xc04, 0x11);
- btcoexist->btc_write_1byte(btcoexist, 0xd04, 0x1);
- btcoexist->btc_write_4byte(btcoexist, 0x90c, 0x81111111);
- /* switch cck patch */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x1);
- btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x81);
- mimops = BTC_MIMO_PS_STATIC;
- } else if (sstype == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0);
- btcoexist->btc_write_1byte(btcoexist, 0xc04, 0x33);
- btcoexist->btc_write_1byte(btcoexist, 0xd04, 0x3);
- btcoexist->btc_write_4byte(btcoexist, 0x90c, 0x81121313);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x0);
- btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x41);
- mimops = BTC_MIMO_PS_DYNAMIC;
- }
- /* set rx 1ss or 2ss */
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimops);
-}
-
-static void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist,
- bool force_exec, u8 new_sstype)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], %s Switch SS Type = %d\n",
- (force_exec ? "force to":""), new_sstype);
- coex_dm->cur_sstype = new_sstype;
-
- if (!force_exec) {
- if (coex_dm->pre_sstype == coex_dm->cur_sstype)
- return;
- }
- halbtc8192e2ant_set_switch_sstype(btcoexist, coex_dm->cur_sstype);
-
- coex_dm->pre_sstype = coex_dm->cur_sstype;
-}
-
-static void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist)
-{
- /* fw all off */
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
-
- /* sw all off */
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
-
- /* hw all off */
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-}
-
-static void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist)
-{
- /* force to reset coex mechanism */
-
- halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, FORCE_EXEC, 6);
- halbtc8192e2ant_dec_btpwr(btcoexist, FORCE_EXEC, 0);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
- halbtc8192e2ant_switch_sstype(btcoexist, FORCE_EXEC, 2);
-
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
-}
-
-static void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist)
-{
- bool low_pwr_disable = true;
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
-
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
-}
-
-static bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool common = false, wifi_connected = false, wifi_busy = false;
- bool bt_hson = false, low_pwr_disable = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
- if (bt_link_info->sco_exist || bt_link_info->hid_exist)
- halbtc8192e2ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 0, 0, 0);
- else
- halbtc8192e2ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
-
- if (!wifi_connected) {
- low_pwr_disable = false;
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi non-connected idle!!\n");
-
- if ((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
- coex_dm->bt_status) ||
- (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE ==
- coex_dm->bt_status)) {
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC,
- 2);
- halbtc8192e2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 1);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
- 0);
- } else {
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC,
- 1);
- halbtc8192e2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 0);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
- 1);
- }
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
-
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false,
- false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false,
- 0x18);
-
- common = true;
- } else {
- if (BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
- coex_dm->bt_status) {
- low_pwr_disable = false;
- btcoexist->btc_set(btcoexist,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Wifi connected + BT non connected-idle!!\n");
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC,
- 2);
- halbtc8192e2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 1);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
- 0);
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC,
- 6);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
-
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- common = true;
- } else if (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE ==
- coex_dm->bt_status) {
- low_pwr_disable = true;
- btcoexist->btc_set(btcoexist,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- if (bt_hson)
- return false;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Wifi connected + BT connected-idle!!\n");
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC,
- 2);
- halbtc8192e2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 1);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
- 0);
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC,
- 6);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
-
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- common = true;
- } else {
- low_pwr_disable = true;
- btcoexist->btc_set(btcoexist,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- if (wifi_busy) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Wifi Connected-Busy + BT Busy!!\n");
- common = false;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Wifi Connected-Idle + BT Busy!!\n");
-
- halbtc8192e2ant_switch_sstype(btcoexist,
- NORMAL_EXEC, 1);
- halbtc8192e2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC,
- 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 21);
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist,
- NORMAL_EXEC, 6);
- halbtc8192e2ant_dec_btpwr(btcoexist,
- NORMAL_EXEC, 0);
- halbtc8192e2ant_sw_mechanism1(btcoexist, false,
- false, false,
- false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false,
- false, false,
- 0x18);
- common = true;
- }
- }
- }
- return common;
-}
-
-static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
- bool sco_hid, bool tx_pause,
- u8 max_interval)
-{
- static int up, dn, m, n, wait_cnt;
- /* 0: no change, +1: increase WiFi duration,
- * -1: decrease WiFi duration */
- int result;
- u8 retry_cnt = 0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], TdmaDurationAdjust()\n");
-
- if (!coex_dm->auto_tdma_adjust) {
- coex_dm->auto_tdma_adjust = true;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], first run TdmaDurationAdjust()!!\n");
- if (sco_hid) {
- if (tx_pause) {
- if (max_interval == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 13);
- coex_dm->ps_tdma_du_adj_type = 13;
- } else if (max_interval == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (max_interval == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- }
- } else {
- if (max_interval == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (max_interval == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (max_interval == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- }
- }
- } else {
- if (tx_pause) {
- if (max_interval == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type = 5;
- } else if (max_interval == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (max_interval == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- }
- } else {
- if (max_interval == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type = 1;
- } else if (max_interval == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (max_interval == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- }
- }
- }
-
- up = 0;
- dn = 0;
- m = 1;
- n = 3;
- result = 0;
- wait_cnt = 0;
- } else {
- /* acquire the BT TRx retry count from BT_Info byte2 */
- retry_cnt = coex_sta->bt_retry_cnt;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], retry_cnt = %d\n", retry_cnt);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], up=%d, dn=%d, m=%d, n=%d, wait_cnt=%d\n",
- up, dn, m, n, wait_cnt);
- result = 0;
- wait_cnt++;
- /* no retry in the last 2-second duration */
- if (retry_cnt == 0) {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if (up >= n) {
- wait_cnt = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex]Increase wifi duration!!\n");
- }
- } else if (retry_cnt <= 3) {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) {
- if (wait_cnt <= 2)
- m++;
- else
- m = 1;
-
- if (m >= 20)
- m = 20;
-
- n = 3 * m;
- up = 0;
- dn = 0;
- wait_cnt = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "Reduce wifi duration for retry<3\n");
- }
- } else {
- if (wait_cnt == 1)
- m++;
- else
- m = 1;
-
- if (m >= 20)
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- wait_cnt = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "Decrease wifi duration for retryCounter>3!!\n");
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], max Interval = %d\n", max_interval);
- if (max_interval == 1) {
- if (tx_pause) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 1\n");
-
- if (coex_dm->cur_ps_tdma == 71) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type = 5;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type = 5;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 4) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type = 8;
- }
- if (coex_dm->cur_ps_tdma == 9) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 13);
- coex_dm->ps_tdma_du_adj_type = 13;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type = 16;
- }
-
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type =
- 8;
- } else if (coex_dm->cur_ps_tdma == 13) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type =
- 16;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 8) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type =
- 5;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 13);
- coex_dm->ps_tdma_du_adj_type =
- 13;
- }
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 0\n");
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 71);
- coex_dm->ps_tdma_du_adj_type = 71;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 8) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type = 4;
- }
- if (coex_dm->cur_ps_tdma == 13) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type = 12;
- }
-
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 71) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type =
- 1;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type =
- 4;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type =
- 12;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 4) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type =
- 1;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 71);
- coex_dm->ps_tdma_du_adj_type =
- 71;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type =
- 9;
- }
- }
- }
- } else if (max_interval == 2) {
- if (tx_pause) {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 1\n");
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 4) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type = 8;
- }
- if (coex_dm->cur_ps_tdma == 9) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type = 16;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type =
- 8;
- } else if (coex_dm->cur_ps_tdma == 13) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type =
- 16;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 8) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- }
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 0\n");
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 8) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type = 4;
- }
- if (coex_dm->cur_ps_tdma == 13) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type = 12;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type =
- 4;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type =
- 12;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 4) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- }
- }
- }
- } else if (max_interval == 3) {
- if (tx_pause) {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 1\n");
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 4) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type = 8;
- }
- if (coex_dm->cur_ps_tdma == 9) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type = 16;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type =
- 8;
- } else if (coex_dm->cur_ps_tdma == 13) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type =
- 16;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 8) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- }
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 0\n");
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 8) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type = 4;
- }
- if (coex_dm->cur_ps_tdma == 13) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8192e2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type = 12;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type =
- 4;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type =
- 12;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 4) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8192e2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- }
- }
- }
- }
- }
-
- /* if current PsTdma not match with
- * the recorded one (when scan, dhcp...),
- * then we have to adjust it back to the previous record one. */
- if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) {
- bool scan = false, link = false, roam = false;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], PsTdma type dismatch!!!, ");
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "curPsTdma=%d, recordPsTdma=%d\n",
- coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
-
- if (!scan && !link && !roam)
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true,
- coex_dm->ps_tdma_du_adj_type);
- else
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n");
- }
-}
-
-/* SCO only or SCO+PAN(HS) */
-static void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
-
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x6);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x6);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x6);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x6);
- }
- }
-}
-
-static void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
-
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x6);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x6);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x6);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x6);
- }
- }
-}
-
-static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
-static void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
- bool long_dist = false;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW ||
- btrssi_state == BTC_RSSI_STATE_STAY_LOW) &&
- (wifirssi_state == BTC_RSSI_STATE_LOW ||
- wifirssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], A2dp, wifi/bt rssi both LOW!!\n");
- long_dist = true;
- }
- if (long_dist) {
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true,
- 0x4);
- } else {
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false,
- 0x8);
- }
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- if (long_dist)
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
- else
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
-
-
- if (long_dist) {
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 17);
- coex_dm->auto_tdma_adjust = false;
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- } else {
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false,
- true, 1);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false,
- false, 1);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false,
- false, 1);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- }
- }
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, true, 2);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false,
- 2);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false,
- 2);
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- }
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- true, 0x6);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- true, 0x6);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- true, 0x6);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- true, 0x6);
- }
- }
-}
-
-static void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1);
- }
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/* PAN(HS) only */
-static void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- }
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/* PAN(EDR)+A2DP */
-static void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, true, 3);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false,
- 3);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false,
- 3);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/* HID+A2DP+PAN(EDR) */
-static void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, true, 3);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 3);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 3);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH;
- u32 wifi_bw;
-
- wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0);
- btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42);
-
- halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1);
- halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 3);
-
- if ((btrssi_state == BTC_RSSI_STATE_LOW) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, true, 2);
- } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 2);
- } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) ||
- (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4);
- halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 2);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifirssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8192e2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8192e2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
-{
- u8 algorithm = 0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], RunCoexistMechanism()===>\n");
-
- if (btcoexist->manual_control) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], return for Manual CTRL <===\n");
- return;
- }
-
- if (coex_sta->under_ips) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], wifi is under IPS !!!\n");
- return;
- }
-
- algorithm = halbtc8192e2ant_action_algorithm(btcoexist);
- if (coex_sta->c2h_bt_inquiry_page &&
- (BT_8192E_2ANT_COEX_ALGO_PANHS != algorithm)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT is under inquiry/page scan !!\n");
- halbtc8192e2ant_action_bt_inquiry(btcoexist);
- return;
- }
-
- coex_dm->cur_algorithm = algorithm;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm);
-
- if (halbtc8192e2ant_is_common_action(btcoexist)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant common.\n");
- coex_dm->auto_tdma_adjust = false;
- } else {
- if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex] preAlgorithm=%d, curAlgorithm=%d\n",
- coex_dm->pre_algorithm,
- coex_dm->cur_algorithm);
- coex_dm->auto_tdma_adjust = false;
- }
- switch (coex_dm->cur_algorithm) {
- case BT_8192E_2ANT_COEX_ALGO_SCO:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = SCO.\n");
- halbtc8192e2ant_action_sco(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_SCO_PAN:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = SCO+PAN(EDR).\n");
- halbtc8192e2ant_action_sco_pan(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = HID.\n");
- halbtc8192e2ant_action_hid(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = A2DP.\n");
- halbtc8192e2ant_action_a2dp(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = A2DP+PAN(HS).\n");
- halbtc8192e2ant_action_a2dp_pan_hs(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = PAN(EDR).\n");
- halbtc8192e2ant_action_pan_edr(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = HS mode.\n");
- halbtc8192e2ant_action_pan_hs(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = PAN+A2DP.\n");
- halbtc8192e2ant_action_pan_edr_a2dp(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_PANEDR_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = PAN(EDR)+HID.\n");
- halbtc8192e2ant_action_pan_edr_hid(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = HID+A2DP+PAN.\n");
- halbtc8192e2ant_action_hid_a2dp_pan_edr(btcoexist);
- break;
- case BT_8192E_2ANT_COEX_ALGO_HID_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = HID+A2DP.\n");
- halbtc8192e2ant_action_hid_a2dp(btcoexist);
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "Action 2-Ant, algorithm = unknown!!\n");
- /* halbtc8192e2ant_coex_alloff(btcoexist); */
- break;
- }
- coex_dm->pre_algorithm = coex_dm->cur_algorithm;
- }
-}
-
-static void halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist,
- bool backup)
-{
- u16 u16tmp = 0;
- u8 u8tmp = 0;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], 2Ant Init HW Config!!\n");
-
- if (backup) {
- /* backup rf 0x1e value */
- coex_dm->bt_rf0x1e_backup =
- btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A,
- 0x1e, 0xfffff);
-
- coex_dm->backup_arfr_cnt1 = btcoexist->btc_read_4byte(btcoexist,
- 0x430);
- coex_dm->backup_arfr_cnt2 = btcoexist->btc_read_4byte(btcoexist,
- 0x434);
- coex_dm->backup_retrylimit = btcoexist->btc_read_2byte(
- btcoexist,
- 0x42a);
- coex_dm->backup_ampdu_maxtime = btcoexist->btc_read_1byte(
- btcoexist,
- 0x456);
- }
-
- /* antenna sw ctrl to bt */
- btcoexist->btc_write_1byte(btcoexist, 0x4f, 0x6);
- btcoexist->btc_write_1byte(btcoexist, 0x944, 0x24);
- btcoexist->btc_write_4byte(btcoexist, 0x930, 0x700700);
- btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x20);
- if (btcoexist->chip_interface == BTC_INTF_USB)
- btcoexist->btc_write_4byte(btcoexist, 0x64, 0x30430004);
- else
- btcoexist->btc_write_4byte(btcoexist, 0x64, 0x30030004);
-
- halbtc8192e2ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
-
- /* antenna switch control parameter */
- btcoexist->btc_write_4byte(btcoexist, 0x858, 0x55555555);
-
- /* coex parameters */
- btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3);
- /* 0x790[5:0]=0x5 */
- u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
- u8tmp &= 0xc0;
- u8tmp |= 0x5;
- btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp);
-
- /* enable counter statistics */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4);
-
- /* enable PTA */
- btcoexist->btc_write_1byte(btcoexist, 0x40, 0x20);
- /* enable mailbox interface */
- u16tmp = btcoexist->btc_read_2byte(btcoexist, 0x40);
- u16tmp |= BIT9;
- btcoexist->btc_write_2byte(btcoexist, 0x40, u16tmp);
-
- /* enable PTA I2C mailbox */
- u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x101);
- u8tmp |= BIT4;
- btcoexist->btc_write_1byte(btcoexist, 0x101, u8tmp);
-
- /* enable bt clock when wifi is disabled. */
- u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x93);
- u8tmp |= BIT0;
- btcoexist->btc_write_1byte(btcoexist, 0x93, u8tmp);
- /* enable bt clock when suspend. */
- u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x7);
- u8tmp |= BIT0;
- btcoexist->btc_write_1byte(btcoexist, 0x7, u8tmp);
-}
-
-/*************************************************************
- * work around function start with wa_halbtc8192e2ant_
- *************************************************************/
-
-/************************************************************
- * extern function start with EXhalbtc8192e2ant_
- ************************************************************/
-
-void ex_halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist)
-{
- halbtc8192e2ant_init_hwconfig(btcoexist, true);
-}
-
-void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], Coex Mechanism Init!!\n");
- halbtc8192e2ant_init_coex_dm(btcoexist);
-}
-
-void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
- u8 *cli_buf = btcoexist->cli_buf;
- u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0;
- u16 u16tmp[4];
- u32 u32tmp[4];
- bool roam = false, scan = false, link = false, wifi_under_5g = false;
- bool bt_hson = false, wifi_busy = false;
- int wifirssi = 0, bt_hs_rssi = 0;
- u32 wifi_bw, wifi_traffic_dir;
- u8 wifi_dot11_chnl, wifi_hs_chnl;
- u32 fw_ver = 0, bt_patch_ver = 0;
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cli_buf);
-
- if (btcoexist->manual_control) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ===========[Under Manual Control]===========");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ==========================================");
- CL_PRINTF(cli_buf);
- }
-
- if (!board_info->bt_exist) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cli_buf);
- return;
- }
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:",
- board_info->pg_ant_num, board_info->btdm_ant_num);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d",
- "BT stack/ hci ext ver",
- ((stack_info->profile_notified) ? "Yes" : "No"),
- stack_info->hci_version);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)",
- "CoexVer/ FwVer/ PatchVer",
- glcoex_ver_date_8192e_2ant, glcoex_ver_8192e_2ant,
- fw_ver, bt_patch_ver, bt_patch_ver);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL,
- &wifi_dot11_chnl);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)",
- "Dot11 channel / HsMode(HsChnl)",
- wifi_dot11_chnl, bt_hson, wifi_hs_chnl);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
- "H2C Wifi inform bt chnl Info", coex_dm->wifi_chnl_info[0],
- coex_dm->wifi_chnl_info[1], coex_dm->wifi_chnl_info[2]);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifirssi);
- btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "Wifi rssi/ HS rssi", wifirssi, bt_hs_rssi);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
- "Wifi link/ roam/ scan", link, roam, scan);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
- &wifi_traffic_dir);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ",
- "Wifi status", (wifi_under_5g ? "5G" : "2.4G"),
- ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" :
- (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))),
- ((!wifi_busy) ? "idle" :
- ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ?
- "uplink" : "downlink")));
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ",
- "BT [status/ rssi/ retryCnt]",
- ((btcoexist->bt_info.bt_disabled) ? ("disabled") :
- ((coex_sta->c2h_bt_inquiry_page) ?
- ("inquiry/page scan") :
- ((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
- coex_dm->bt_status) ? "non-connected idle" :
- ((BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE ==
- coex_dm->bt_status) ? "connected-idle" : "busy")))),
- coex_sta->bt_rssi, coex_sta->bt_retry_cnt);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d",
- "SCO/HID/PAN/A2DP", stack_info->sco_exist,
- stack_info->hid_exist, stack_info->pan_exist,
- stack_info->a2dp_exist);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO);
-
- bt_info_ext = coex_sta->bt_info_ext;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
- "BT Info A2DP rate",
- (bt_info_ext&BIT0) ? "Basic rate" : "EDR rate");
- CL_PRINTF(cli_buf);
-
- for (i = 0; i < BT_INFO_SRC_8192E_2ANT_MAX; i++) {
- if (coex_sta->bt_info_c2h_cnt[i]) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %02x %02x %02x %02x ",
- GLBtInfoSrc8192e2Ant[i],
- coex_sta->bt_info_c2h[i][0],
- coex_sta->bt_info_c2h[i][1],
- coex_sta->bt_info_c2h[i][2],
- coex_sta->bt_info_c2h[i][3]);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "%02x %02x %02x(%d)",
- coex_sta->bt_info_c2h[i][4],
- coex_sta->bt_info_c2h[i][5],
- coex_sta->bt_info_c2h[i][6],
- coex_sta->bt_info_c2h_cnt[i]);
- CL_PRINTF(cli_buf);
- }
- }
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s",
- "PS state, IPS/LPS",
- ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")),
- ((coex_sta->under_lps ? "LPS ON" : "LPS OFF")));
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type",
- coex_dm->cur_sstype);
- CL_PRINTF(cli_buf);
-
- /* Sw mechanism */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Sw mechanism]============");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
- "SM1[ShRf/ LpRA/ LimDig]", coex_dm->cur_rf_rx_lpf_shrink,
- coex_dm->cur_low_penalty_ra, coex_dm->limited_dig);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ",
- "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
- coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off,
- coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask",
- btcoexist->bt_info.ra_mask);
- CL_PRINTF(cli_buf);
-
- /* Fw mechanism */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Fw mechanism]============");
- CL_PRINTF(cli_buf);
-
- ps_tdma_case = coex_dm->cur_ps_tdma;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)",
- "PS TDMA", coex_dm->ps_tdma_para[0],
- coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2],
- coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4],
- ps_tdma_case, coex_dm->auto_tdma_adjust);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
- "DecBtPwr/ IgnWlanAct",
- coex_dm->cur_dec_bt_pwr, coex_dm->cur_ignore_wlan_act);
- CL_PRINTF(cli_buf);
-
- /* Hw setting */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Hw setting]============");
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x",
- "RF-A, 0x1e initVal", coex_dm->bt_rf0x1e_backup);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
- "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm->backup_arfr_cnt1,
- coex_dm->backup_arfr_cnt2, coex_dm->backup_retrylimit,
- coex_dm->backup_ampdu_maxtime);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434);
- u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
- "0x430/0x434/0x42a/0x456",
- u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc04);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xd04);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x90c);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0xc04/ 0xd04/ 0x90c", u32tmp[0], u32tmp[1], u32tmp[2]);
- CL_PRINTF(cli_buf);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778",
- u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x92c);
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x930);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0x92c/ 0x930", (u8tmp[0]), u32tmp[0]);
- CL_PRINTF(cli_buf);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x4f);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0x40/ 0x4f", u8tmp[0], u8tmp[1]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)",
- u32tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
- "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)",
- u32tmp[0], u32tmp[1], u32tmp[2], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "0x770(hp rx[31:16]/tx[15:0])",
- coex_sta->high_priority_rx, coex_sta->high_priority_tx);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "0x774(lp rx[31:16]/tx[15:0])",
- coex_sta->low_priority_rx, coex_sta->low_priority_tx);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-void ex_halbtc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_IPS_ENTER == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], IPS ENTER notify\n");
- coex_sta->under_ips = true;
- halbtc8192e2ant_coex_alloff(btcoexist);
- } else if (BTC_IPS_LEAVE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], IPS LEAVE notify\n");
- coex_sta->under_ips = false;
- }
-}
-
-void ex_halbtc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_LPS_ENABLE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], LPS ENABLE notify\n");
- coex_sta->under_lps = true;
- } else if (BTC_LPS_DISABLE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], LPS DISABLE notify\n");
- coex_sta->under_lps = false;
- }
-}
-
-void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_SCAN_START == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], SCAN START notify\n");
- else if (BTC_SCAN_FINISH == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], SCAN FINISH notify\n");
-}
-
-void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_ASSOCIATE_START == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], CONNECT START notify\n");
- else if (BTC_ASSOCIATE_FINISH == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], CONNECT FINISH notify\n");
-}
-
-void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- u8 h2c_parameter[3] = {0};
- u32 wifi_bw;
- u8 wifi_center_chnl;
-
- if (btcoexist->manual_control ||
- btcoexist->stop_coex_dm ||
- btcoexist->bt_info.bt_disabled)
- return;
-
- if (BTC_MEDIA_CONNECT == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], MEDIA connect notify\n");
- else
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], MEDIA disconnect notify\n");
-
- /* only 2.4G we need to inform bt the chnl mask */
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
- &wifi_center_chnl);
- if ((BTC_MEDIA_CONNECT == type) &&
- (wifi_center_chnl <= 14)) {
- h2c_parameter[0] = 0x1;
- h2c_parameter[1] = wifi_center_chnl;
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw)
- h2c_parameter[2] = 0x30;
- else
- h2c_parameter[2] = 0x20;
- }
-
- coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
- coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
- coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x66=0x%x\n",
- h2c_parameter[0] << 16 | h2c_parameter[1] << 8 |
- h2c_parameter[2]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
-}
-
-void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- if (type == BTC_PACKET_DHCP)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], DHCP Packet notify\n");
-}
-
-void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmp_buf, u8 length)
-{
- u8 bt_info = 0;
- u8 i, rspSource = 0;
- bool bt_busy = false, limited_dig = false;
- bool wifi_connected = false;
-
- coex_sta->c2h_bt_info_req_sent = false;
-
- rspSource = tmp_buf[0] & 0xf;
- if (rspSource >= BT_INFO_SRC_8192E_2ANT_MAX)
- rspSource = BT_INFO_SRC_8192E_2ANT_WIFI_FW;
- coex_sta->bt_info_c2h_cnt[rspSource]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], Bt info[%d], length=%d, hex data=[",
- rspSource, length);
- for (i = 0; i < length; i++) {
- coex_sta->bt_info_c2h[rspSource][i] = tmp_buf[i];
- if (i == 1)
- bt_info = tmp_buf[i];
- if (i == length-1)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "0x%02x]\n", tmp_buf[i]);
- else
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "0x%02x, ", tmp_buf[i]);
- }
-
- if (BT_INFO_SRC_8192E_2ANT_WIFI_FW != rspSource) {
- coex_sta->bt_retry_cnt = /* [3:0] */
- coex_sta->bt_info_c2h[rspSource][2] & 0xf;
-
- coex_sta->bt_rssi =
- coex_sta->bt_info_c2h[rspSource][3] * 2 + 10;
-
- coex_sta->bt_info_ext =
- coex_sta->bt_info_c2h[rspSource][4];
-
- /* Here we need to resend some wifi info to BT
- * because bt is reset and loss of the info. */
- if ((coex_sta->bt_info_ext & BIT1)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "bit1, send wifi BW&Chnl to BT!!\n");
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- if (wifi_connected)
- ex_halbtc8192e2ant_media_status_notify(
- btcoexist,
- BTC_MEDIA_CONNECT);
- else
- ex_halbtc8192e2ant_media_status_notify(
- btcoexist,
- BTC_MEDIA_DISCONNECT);
- }
-
- if ((coex_sta->bt_info_ext & BIT3)) {
- if (!btcoexist->manual_control &&
- !btcoexist->stop_coex_dm) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "bit3, BT NOT ignore Wlan active!\n");
- halbtc8192e2ant_IgnoreWlanAct(btcoexist,
- FORCE_EXEC,
- false);
- }
- } else {
- /* BT already NOT ignore Wlan active,
- * do nothing here. */
- }
-
- if ((coex_sta->bt_info_ext & BIT4)) {
- /* BT auto report already enabled, do nothing */
- } else {
- halbtc8192e2ant_bt_autoreport(btcoexist, FORCE_EXEC,
- true);
- }
- }
-
- /* check BIT2 first ==> check if bt is under inquiry or page scan */
- if (bt_info & BT_INFO_8192E_2ANT_B_INQ_PAGE)
- coex_sta->c2h_bt_inquiry_page = true;
- else
- coex_sta->c2h_bt_inquiry_page = false;
-
- /* set link exist status */
- if (!(bt_info&BT_INFO_8192E_2ANT_B_CONNECTION)) {
- coex_sta->bt_link_exist = false;
- coex_sta->pan_exist = false;
- coex_sta->a2dp_exist = false;
- coex_sta->hid_exist = false;
- coex_sta->sco_exist = false;
- } else {/* connection exists */
- coex_sta->bt_link_exist = true;
- if (bt_info & BT_INFO_8192E_2ANT_B_FTP)
- coex_sta->pan_exist = true;
- else
- coex_sta->pan_exist = false;
- if (bt_info & BT_INFO_8192E_2ANT_B_A2DP)
- coex_sta->a2dp_exist = true;
- else
- coex_sta->a2dp_exist = false;
- if (bt_info & BT_INFO_8192E_2ANT_B_HID)
- coex_sta->hid_exist = true;
- else
- coex_sta->hid_exist = false;
- if (bt_info & BT_INFO_8192E_2ANT_B_SCO_ESCO)
- coex_sta->sco_exist = true;
- else
- coex_sta->sco_exist = false;
- }
-
- halbtc8192e2ant_update_btlink_info(btcoexist);
-
- if (!(bt_info&BT_INFO_8192E_2ANT_B_CONNECTION)) {
- coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Non-Connected idle!!!\n");
- } else if (bt_info == BT_INFO_8192E_2ANT_B_CONNECTION) {
- coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], bt_infoNotify(), BT Connected-idle!!!\n");
- } else if ((bt_info&BT_INFO_8192E_2ANT_B_SCO_ESCO) ||
- (bt_info&BT_INFO_8192E_2ANT_B_SCO_BUSY)) {
- coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_SCO_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], bt_infoNotify(), BT SCO busy!!!\n");
- } else if (bt_info&BT_INFO_8192E_2ANT_B_ACL_BUSY) {
- coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_ACL_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], bt_infoNotify(), BT ACL busy!!!\n");
- } else {
- coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_MAX;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex]bt_infoNotify(), BT Non-Defined state!!!\n");
- }
-
- if ((BT_8192E_2ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
- (BT_8192E_2ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) {
- bt_busy = true;
- limited_dig = true;
- } else {
- bt_busy = false;
- limited_dig = false;
- }
-
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
-
- coex_dm->limited_dig = limited_dig;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
-
- halbtc8192e2ant_run_coexist_mechanism(btcoexist);
-}
-
-void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- if (BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex] StackOP Inquiry/page/pair start notify\n");
- else if (BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex] StackOP Inquiry/page/pair finish notify\n");
-}
-
-void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n");
-
- halbtc8192e2ant_IgnoreWlanAct(btcoexist, FORCE_EXEC, true);
- ex_halbtc8192e2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
-}
-
-void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist)
-{
- static u8 dis_ver_info_cnt;
- u32 fw_ver = 0, bt_patch_ver = 0;
- struct btc_board_info *board_info = &btcoexist->board_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "=======================Periodical=======================\n");
- if (dis_ver_info_cnt <= 5) {
- dis_ver_info_cnt += 1;
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "************************************************\n");
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
- board_info->pg_ant_num, board_info->btdm_ant_num,
- board_info->btdm_ant_pos);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "BT stack/ hci ext ver = %s / %d\n",
- ((stack_info->profile_notified) ? "Yes" : "No"),
- stack_info->hci_version);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER,
- &bt_patch_ver);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
- glcoex_ver_date_8192e_2ant, glcoex_ver_8192e_2ant,
- fw_ver, bt_patch_ver, bt_patch_ver);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "************************************************\n");
- }
-
- halbtc8192e2ant_querybt_info(btcoexist);
- halbtc8192e2ant_monitor_bt_ctr(btcoexist);
- halbtc8192e2ant_monitor_bt_enable_disable(btcoexist);
-}
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h
deleted file mode 100644
index f10bf1be69fe..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*****************************************************************
- * The following is for 8192E 2Ant BT Co-exist definition
- *****************************************************************/
-#define BT_INFO_8192E_2ANT_B_FTP BIT7
-#define BT_INFO_8192E_2ANT_B_A2DP BIT6
-#define BT_INFO_8192E_2ANT_B_HID BIT5
-#define BT_INFO_8192E_2ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8192E_2ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8192E_2ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8192E_2ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8192E_2ANT_B_CONNECTION BIT0
-
-#define BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT 2
-
-enum bt_info_src_8192e_2ant{
- BT_INFO_SRC_8192E_2ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8192E_2ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8192E_2ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8192E_2ANT_MAX
-};
-
-enum bt_8192e_2ant_bt_status{
- BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8192E_2ANT_BT_STATUS_INQ_PAGE = 0x2,
- BT_8192E_2ANT_BT_STATUS_ACL_BUSY = 0x3,
- BT_8192E_2ANT_BT_STATUS_SCO_BUSY = 0x4,
- BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
- BT_8192E_2ANT_BT_STATUS_MAX
-};
-
-enum bt_8192e_2ant_coex_algo{
- BT_8192E_2ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8192E_2ANT_COEX_ALGO_SCO = 0x1,
- BT_8192E_2ANT_COEX_ALGO_SCO_PAN = 0x2,
- BT_8192E_2ANT_COEX_ALGO_HID = 0x3,
- BT_8192E_2ANT_COEX_ALGO_A2DP = 0x4,
- BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS = 0x5,
- BT_8192E_2ANT_COEX_ALGO_PANEDR = 0x6,
- BT_8192E_2ANT_COEX_ALGO_PANHS = 0x7,
- BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP = 0x8,
- BT_8192E_2ANT_COEX_ALGO_PANEDR_HID = 0x9,
- BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0xa,
- BT_8192E_2ANT_COEX_ALGO_HID_A2DP = 0xb,
- BT_8192E_2ANT_COEX_ALGO_MAX = 0xc
-};
-
-struct coex_dm_8192e_2ant{
- /* fw mechanism */
- u8 pre_dec_bt_pwr;
- u8 cur_dec_bt_pwr;
- u8 pre_fw_dac_swing_lvl;
- u8 cur_fw_dac_swing_lvl;
- bool cur_ignore_wlan_act;
- bool pre_ignore_wlan_act;
- u8 pre_ps_tdma;
- u8 cur_ps_tdma;
- u8 ps_tdma_para[5];
- u8 ps_tdma_du_adj_type;
- bool reset_tdma_adjust;
- bool auto_tdma_adjust;
- bool pre_ps_tdma_on;
- bool cur_ps_tdma_on;
- bool pre_bt_auto_report;
- bool cur_bt_auto_report;
-
- /* sw mechanism */
- bool pre_rf_rx_lpf_shrink;
- bool cur_rf_rx_lpf_shrink;
- u32 bt_rf0x1e_backup;
- bool pre_low_penalty_ra;
- bool cur_low_penalty_ra;
- bool pre_dac_swing_on;
- u32 pre_dac_swing_lvl;
- bool cur_dac_swing_on;
- u32 cur_dac_swing_lvl;
- bool pre_adc_back_off;
- bool cur_adc_back_off;
- bool pre_agc_table_en;
- bool cur_agc_table_en;
- u32 pre_val0x6c0;
- u32 cur_val0x6c0;
- u32 pre_val0x6c4;
- u32 cur_val0x6c4;
- u32 pre_val0x6c8;
- u32 cur_val0x6c8;
- u8 pre_val0x6cc;
- u8 cur_val0x6cc;
- bool limited_dig;
-
- u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */
- u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */
- u16 backup_retrylimit;
- u8 backup_ampdu_maxtime;
-
- /* algorithm related */
- u8 pre_algorithm;
- u8 cur_algorithm;
- u8 bt_status;
- u8 wifi_chnl_info[3];
-
- u8 pre_sstype;
- u8 cur_sstype;
-
- u32 prera_mask;
- u32 curra_mask;
- u8 curra_masktype;
- u8 pre_arfrtype;
- u8 cur_arfrtype;
- u8 pre_retrylimit_type;
- u8 cur_retrylimit_type;
- u8 pre_ampdutime_type;
- u8 cur_ampdutime_type;
-};
-
-struct coex_sta_8192e_2ant{
- bool bt_link_exist;
- bool sco_exist;
- bool a2dp_exist;
- bool hid_exist;
- bool pan_exist;
-
- bool under_lps;
- bool under_ips;
- u32 high_priority_tx;
- u32 high_priority_rx;
- u32 low_priority_tx;
- u32 low_priority_rx;
- u8 bt_rssi;
- u8 pre_bt_rssi_state;
- u8 pre_wifi_rssi_state[4];
- bool c2h_bt_info_req_sent;
- u8 bt_info_c2h[BT_INFO_SRC_8192E_2ANT_MAX][10];
- u32 bt_info_c2h_cnt[BT_INFO_SRC_8192E_2ANT_MAX];
- bool c2h_bt_inquiry_page;
- u8 bt_retry_cnt;
- u8 bt_info_ext;
-};
-
-/****************************************************************
- * The following is interface which will notify coex module.
- ****************************************************************/
-void ex_halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmpBuf, u8 length);
-void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist);
-void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist);
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.c
deleted file mode 100644
index 3f5c4fd2e73f..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.c
+++ /dev/null
@@ -1,3780 +0,0 @@
-//============================================================
-// Description:
-//
-// This file is for RTL8723A Co-exist mechanism
-//
-// History
-// 2012/08/22 Cosa first check in.
-// 2012/11/14 Cosa Revise for 8723A 2Ant out sourcing.
-//
-//============================================================
-
-//============================================================
-// include files
-//============================================================
-#include "Mp_Precomp.h"
-#if(BT_30_SUPPORT == 1)
-//============================================================
-// Global variables, these are static variables
-//============================================================
-static COEX_DM_8723A_2ANT GLCoexDm8723a2Ant;
-static PCOEX_DM_8723A_2ANT pCoexDm=&GLCoexDm8723a2Ant;
-static COEX_STA_8723A_2ANT GLCoexSta8723a2Ant;
-static PCOEX_STA_8723A_2ANT pCoexSta=&GLCoexSta8723a2Ant;
-
-const char *const GLBtInfoSrc8723a2Ant[]={
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-//============================================================
-// local function proto type if needed
-//============================================================
-//============================================================
-// local function start with halbtc8723a2ant_
-//============================================================
-BOOLEAN
-halbtc8723a2ant_IsWifiIdle(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bWifiConnected=FALSE, bScan=FALSE, bLink=FALSE, bRoam=FALSE;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
-
- if(bWifiConnected)
- return FALSE;
- if(bScan)
- return FALSE;
- if(bLink)
- return FALSE;
- if(bRoam)
- return FALSE;
-
- return true;
-}
-
-u1Byte
-halbtc8723a2ant_BtRssiState(
- u1Byte levelNum,
- u1Byte rssiThresh,
- u1Byte rssiThresh1
- )
-{
- s4Byte btRssi=0;
- u1Byte btRssiState=pCoexSta->preBtRssiState;
-
- btRssi = pCoexSta->btRssi;
-
- if(levelNum == 2)
- {
- if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
- {
- if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
- {
- btRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
- }
- }
- else
- {
- if(btRssi < rssiThresh)
- {
- btRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
- }
- }
- }
- else if(levelNum == 3)
- {
- if(rssiThresh > rssiThresh1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n"));
- return pCoexSta->preBtRssiState;
- }
-
- if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW))
- {
- if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
- {
- btRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n"));
- }
- }
- else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) ||
- (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM))
- {
- if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
- {
- btRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n"));
- }
- else if(btRssi < rssiThresh)
- {
- btRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n"));
- }
- }
- else
- {
- if(btRssi < rssiThresh1)
- {
- btRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n"));
- }
- else
- {
- btRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n"));
- }
- }
- }
-
- pCoexSta->preBtRssiState = btRssiState;
-
- return btRssiState;
-}
-
-u1Byte
-halbtc8723a2ant_WifiRssiState(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte index,
- IN u1Byte levelNum,
- IN u1Byte rssiThresh,
- IN u1Byte rssiThresh1
- )
-{
- s4Byte wifiRssi=0;
- u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index];
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
-
- if(levelNum == 2)
- {
- if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
- {
- if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
- {
- wifiRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
- }
- }
- else
- {
- if(wifiRssi < rssiThresh)
- {
- wifiRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
- }
- }
- }
- else if(levelNum == 3)
- {
- if(rssiThresh > rssiThresh1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n"));
- return pCoexSta->preWifiRssiState[index];
- }
-
- if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) ||
- (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW))
- {
- if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
- {
- wifiRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n"));
- }
- }
- else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) ||
- (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM))
- {
- if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT))
- {
- wifiRssiState = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n"));
- }
- else if(wifiRssi < rssiThresh)
- {
- wifiRssiState = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n"));
- }
- }
- else
- {
- if(wifiRssi < rssiThresh1)
- {
- wifiRssiState = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n"));
- }
- else
- {
- wifiRssiState = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n"));
- }
- }
- }
-
- pCoexSta->preWifiRssiState[index] = wifiRssiState;
-
- return wifiRssiState;
-}
-
-VOID
-halbtc8723a2ant_IndicateWifiChnlBwInfo(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- u1Byte H2C_Parameter[3] ={0};
- u4Byte wifiBw;
- u1Byte wifiCentralChnl;
-
- // only 2.4G we need to inform bt the chnl mask
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl);
- if( (BTC_MEDIA_CONNECT == type) &&
- (wifiCentralChnl <= 14) )
- {
- H2C_Parameter[0] = 0x1;
- H2C_Parameter[1] = wifiCentralChnl;
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- H2C_Parameter[2] = 0x30;
- else
- H2C_Parameter[2] = 0x20;
- }
-
- pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0];
- pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1];
- pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2];
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x19=0x%x\n",
- H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x19, 3, H2C_Parameter);
-}
-
-VOID
-halbtc8723a2ant_QueryBtInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- pCoexSta->bC2hBtInfoReqSent = true;
-
- H2C_Parameter[0] |= BIT0; // trigger
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x38, 1, H2C_Parameter);
-}
-u1Byte
-halbtc8723a2ant_ActionAlgorithm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
- BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, limited_dig=FALSE;
- u1Byte algorithm=BT_8723A_2ANT_COEX_ALGO_UNDEFINED;
- u1Byte numOfDiffProfile=0;
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
-
- //======================
- // here we get BT status first
- //======================
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_IDLE;
-
- if((pStackInfo->bScoExist) ||(bBtHsOn) ||(pStackInfo->bHidExist))
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO or HID or HS exists, set BT non-idle !!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
- }
- else
- {
- // A2dp profile
- if( (pBtCoexist->stack_info.numOfLink == 1) &&
- (pStackInfo->bA2dpExist) )
- {
- if( (pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 100)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP, low priority tx+rx < 100, set BT connected-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP, low priority tx+rx >= 100, set BT non-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
- }
- }
- // Pan profile
- if( (pBtCoexist->stack_info.numOfLink == 1) &&
- (pStackInfo->bPanExist) )
- {
- if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN, low priority tx+rx < 600, set BT connected-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
- }
- else
- {
- if(pCoexSta->lowPriorityTx)
- {
- if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN, low priority rx/tx > 9, set BT connected-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
- }
- }
- }
- if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN, set BT non-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
- }
- }
- // Pan+A2dp profile
- if( (pBtCoexist->stack_info.numOfLink == 2) &&
- (pStackInfo->bA2dpExist) &&
- (pStackInfo->bPanExist) )
- {
- if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN+A2DP, low priority tx+rx < 600, set BT connected-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
- }
- else
- {
- if(pCoexSta->lowPriorityTx)
- {
- if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN+A2DP, low priority rx/tx > 9, set BT connected-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE;
- }
- }
- }
- if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN+A2DP, set BT non-idle!!!\n"));
- pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE;
- }
- }
- }
- if(BT_8723A_2ANT_BT_STATUS_IDLE != pCoexDm->btStatus)
- {
- bBtBusy = true;
- limited_dig = true;
- }
- else
- {
- bBtBusy = FALSE;
- limited_dig = FALSE;
- }
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy);
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
- //======================
-
- if(!pStackInfo->bBtLinkExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No profile exists!!!\n"));
- return algorithm;
- }
-
- if(pStackInfo->bScoExist)
- numOfDiffProfile++;
- if(pStackInfo->bHidExist)
- numOfDiffProfile++;
- if(pStackInfo->bPanExist)
- numOfDiffProfile++;
- if(pStackInfo->bA2dpExist)
- numOfDiffProfile++;
-
- if(numOfDiffProfile == 1)
- {
- if(pStackInfo->bScoExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
- }
- else
- {
- if(pStackInfo->bHidExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
- }
- else if(pStackInfo->bA2dpExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP;
- }
- else if(pStackInfo->bPanExist)
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANHS;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR;
- }
- }
- }
- }
- else if(numOfDiffProfile == 2)
- {
- if(pStackInfo->bScoExist)
- {
- if(pStackInfo->bHidExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
- }
- else if(pStackInfo->bA2dpExist)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
- }
- else if(pStackInfo->bPanExist)
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- else
- {
- if( pStackInfo->bHidExist &&
- pStackInfo->bA2dpExist )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
- }
- else if( pStackInfo->bHidExist &&
- pStackInfo->bPanExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- else if( pStackInfo->bPanExist &&
- pStackInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP;
- }
- }
- }
- }
- else if(numOfDiffProfile == 3)
- {
- if(pStackInfo->bScoExist)
- {
- if( pStackInfo->bHidExist &&
- pStackInfo->bA2dpExist )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID;
- }
- else if( pStackInfo->bHidExist &&
- pStackInfo->bPanExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- else if( pStackInfo->bPanExist &&
- pStackInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_SCO;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- else
- {
- if( pStackInfo->bHidExist &&
- pStackInfo->bPanExist &&
- pStackInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
- }
- }
- }
- }
- else if(numOfDiffProfile >= 3)
- {
- if(pStackInfo->bScoExist)
- {
- if( pStackInfo->bHidExist &&
- pStackInfo->bPanExist &&
- pStackInfo->bA2dpExist )
- {
- if(bBtHsOn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
-
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n"));
- algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- }
-
- return algorithm;
-}
-
-BOOLEAN
-halbtc8723a2ant_NeedToDecBtPwr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bRet=FALSE;
- BOOLEAN bBtHsOn=FALSE, bWifiConnected=FALSE;
- s4Byte btHsRssi=0;
-
- if(!pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn))
- return FALSE;
- if(!pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected))
- return FALSE;
- if(!pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi))
- return FALSE;
-
- if(bWifiConnected)
- {
- if(bBtHsOn)
- {
- if(btHsRssi > 37)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], Need to decrease bt power for HS mode!!\n"));
- bRet = true;
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], Need to decrease bt power for Wifi is connected!!\n"));
- bRet = true;
- }
- }
-
- return bRet;
-}
-
-VOID
-halbtc8723a2ant_SetFwDacSwingLevel(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte dacSwingLvl
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- // There are several type of dacswing
- // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6
- H2C_Parameter[0] = dacSwingLvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x29=0x%x\n", H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x29, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8723a2ant_SetFwDecBtPwr(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bDecBtPwr
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- H2C_Parameter[0] = 0;
-
- if(bDecBtPwr)
- {
- H2C_Parameter[0] |= BIT1;
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power : %s, FW write 0x21=0x%x\n",
- (bDecBtPwr? "Yes!!":"No!!"), H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x21, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8723a2ant_DecBtPwr(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bDecBtPwr
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power = %s\n",
- (bForceExec? "force to":""), ((bDecBtPwr)? "ON":"OFF")));
- pCoexDm->bCurDecBtPwr = bDecBtPwr;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreDecBtPwr=%d, bCurDecBtPwr=%d\n",
- pCoexDm->bPreDecBtPwr, pCoexDm->bCurDecBtPwr));
-
- if(pCoexDm->bPreDecBtPwr == pCoexDm->bCurDecBtPwr)
- return;
- }
- halbtc8723a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->bCurDecBtPwr);
-
- pCoexDm->bPreDecBtPwr = pCoexDm->bCurDecBtPwr;
-}
-
-VOID
-halbtc8723a2ant_FwDacSwingLvl(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u1Byte fwDacSwingLvl
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n",
- (bForceExec? "force to":""), fwDacSwingLvl));
- pCoexDm->curFwDacSwingLvl = fwDacSwingLvl;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n",
- pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl));
-
- if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl)
- return;
- }
-
- halbtc8723a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl);
-
- pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl;
-}
-
-VOID
-halbtc8723a2ant_SetSwRfRxLpfCorner(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bRxRfShrinkOn
- )
-{
- if(bRxRfShrinkOn)
- {
- //Shrink RF Rx LPF corner
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7);
- }
- else
- {
- //Resume RF Rx LPF corner
- // After initialized, we can use pCoexDm->btRf0x1eBackup
- if(pBtCoexist->initilized)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n"));
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup);
- }
- }
-}
-
-VOID
-halbtc8723a2ant_RfShrink(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bRxRfShrinkOn
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n",
- (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF")));
- pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n",
- pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink));
-
- if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink)
- return;
- }
- halbtc8723a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink);
-
- pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink;
-}
-
-VOID
-halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bLowPenaltyRa
- )
-{
- u1Byte tmpU1;
-
- tmpU1 = pBtCoexist->btc_read_1byte(pBtCoexist, 0x4fd);
- tmpU1 |= BIT0;
- if(bLowPenaltyRa)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n"));
- tmpU1 &= ~BIT2;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n"));
- tmpU1 |= BIT2;
- }
-
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x4fd, tmpU1);
-}
-
-VOID
-halbtc8723a2ant_LowPenaltyRa(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bLowPenaltyRa
- )
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n",
- (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF")));
- pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n",
- pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa));
-
- if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa)
- return;
- }
- halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa);
-
- pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa;
-}
-
-VOID
-halbtc8723a2ant_SetSwFullTimeDacSwing(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bSwDacSwingOn,
- IN u4Byte swDacSwingLvl
- )
-{
- if(bSwDacSwingOn)
- {
- pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, swDacSwingLvl);
- }
- else
- {
- pBtCoexist->btc_setBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0);
- }
-}
-
-
-VOID
-halbtc8723a2ant_DacSwing(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bDacSwingOn,
- IN u4Byte dacSwingLvl
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n",
- (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl));
- pCoexDm->bCurDacSwingOn = bDacSwingOn;
- pCoexDm->curDacSwingLvl = dacSwingLvl;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
- pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl,
- pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl));
-
- if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) &&
- (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) )
- return;
- }
- mdelay(30);
- halbtc8723a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl);
-
- pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn;
- pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl;
-}
-
-VOID
-halbtc8723a2ant_SetAdcBackOff(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bAdcBackOff
- )
-{
- if(bAdcBackOff)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level On!\n"));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc04,0x3a07611);
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB BackOff Level Off!\n"));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc04,0x3a05611);
- }
-}
-
-VOID
-halbtc8723a2ant_AdcBackOff(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bAdcBackOff
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn AdcBackOff = %s\n",
- (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF")));
- pCoexDm->bCurAdcBackOff = bAdcBackOff;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
- pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff));
-
- if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff)
- return;
- }
- halbtc8723a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff);
-
- pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff;
-}
-
-VOID
-halbtc8723a2ant_SetAgcTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bAgcTableEn
- )
-{
- u1Byte rssiAdjustVal=0;
-
- if(bAgcTableEn)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n"));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4e1c0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4d1d0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4c1e0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4b1f0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x4a200001);
-
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00355);
-
- rssiAdjustVal = 6;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n"));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x641c0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x631d0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x621e0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x611f0001);
- pBtCoexist->btc_write_4byte(pBtCoexist, 0xc78,0x60200001);
-
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000);
- pBtCoexist->btc_set_rf_reg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x30355);
- }
-
- // set rssiAdjustVal for wifi module.
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal);
-}
-
-
-VOID
-halbtc8723a2ant_AgcTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bAgcTableEn
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n",
- (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable")));
- pCoexDm->bCurAgcTableEn = bAgcTableEn;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
- pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn));
-
- if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn)
- return;
- }
- halbtc8723a2ant_SetAgcTable(pBtCoexist, bAgcTableEn);
-
- pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn;
-}
-
-VOID
-halbtc8723a2ant_SetCoexTable(
- IN PBTC_COEXIST pBtCoexist,
- IN u4Byte val0x6c0,
- IN u4Byte val0x6c8,
- IN u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8));
- pBtCoexist->btc_write_4byte(pBtCoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc));
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x6cc, val0x6cc);
-}
-
-VOID
-halbtc8723a2ant_CoexTable(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN u4Byte val0x6c0,
- IN u4Byte val0x6c8,
- IN u1Byte val0x6cc
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
- (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc));
- pCoexDm->curVal0x6c0 = val0x6c0;
- pCoexDm->curVal0x6c8 = val0x6c8;
- pCoexDm->curVal0x6cc = val0x6cc;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n",
- pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n",
- pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc));
-
- if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) &&
- (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) &&
- (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) )
- return;
- }
- halbtc8723a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc);
-
- pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0;
- pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8;
- pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc;
-}
-
-VOID
-halbtc8723a2ant_SetFwIgnoreWlanAct(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bEnable
- )
-{
- u1Byte H2C_Parameter[1] ={0};
-
- if(bEnable)
- {
- H2C_Parameter[0] |= BIT0; // function enable
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n",
- H2C_Parameter[0]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x25, 1, H2C_Parameter);
-}
-
-VOID
-halbtc8723a2ant_IgnoreWlanAct(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bEnable
- )
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n",
- (bForceExec? "force to":""), (bEnable? "ON":"OFF")));
- pCoexDm->bCurIgnoreWlanAct = bEnable;
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n",
- pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct));
-
- if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct)
- return;
- }
- halbtc8723a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable);
-
- pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct;
-}
-
-VOID
-halbtc8723a2ant_SetFwPstdma(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte byte1,
- IN u1Byte byte2,
- IN u1Byte byte3,
- IN u1Byte byte4,
- IN u1Byte byte5
- )
-{
- u1Byte H2C_Parameter[5] ={0};
-
- H2C_Parameter[0] = byte1;
- H2C_Parameter[1] = byte2;
- H2C_Parameter[2] = byte3;
- H2C_Parameter[3] = byte4;
- H2C_Parameter[4] = byte5;
-
- pCoexDm->psTdmaPara[0] = byte1;
- pCoexDm->psTdmaPara[1] = byte2;
- pCoexDm->psTdmaPara[2] = byte3;
- pCoexDm->psTdmaPara[3] = byte4;
- pCoexDm->psTdmaPara[4] = byte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n",
- H2C_Parameter[0],
- H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4]));
-
- pBtCoexist->btc_fill_h2c(pBtCoexist, 0x3a, 5, H2C_Parameter);
-}
-
-VOID
-halbtc8723a2ant_PsTdma(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bForceExec,
- IN BOOLEAN bTurnOn,
- IN u1Byte type
- )
-{
- u4Byte btTxRxCnt=0;
-
- btTxRxCnt = pCoexSta->highPriorityTx+pCoexSta->highPriorityRx+
- pCoexSta->lowPriorityTx+pCoexSta->lowPriorityRx;
-
- if(btTxRxCnt > 3000)
- {
- pCoexDm->bCurPsTdmaOn = true;
- pCoexDm->curPsTdma = 8;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], turn ON PS TDMA, type=%d for BT tx/rx counters=%d(>3000)\n",
- pCoexDm->curPsTdma, btTxRxCnt));
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type=%d\n",
- (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type));
- pCoexDm->bCurPsTdmaOn = bTurnOn;
- pCoexDm->curPsTdma = type;
- }
-
- if(!bForceExec)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
- pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
- pCoexDm->prePsTdma, pCoexDm->curPsTdma));
-
- if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) &&
- (pCoexDm->prePsTdma == pCoexDm->curPsTdma) )
- return;
- }
- if(pCoexDm->bCurPsTdmaOn)
- {
- switch(pCoexDm->curPsTdma)
- {
- case 1:
- default:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98);
- break;
- case 2:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98);
- break;
- case 3:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98);
- break;
- case 4:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0xe1, 0x80);
- break;
- case 5:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98);
- break;
- case 6:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98);
- break;
- case 7:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98);
- break;
- case 8:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0x60, 0x80);
- break;
- case 9:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98);
- break;
- case 10:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98);
- break;
- case 11:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98);
- break;
- case 12:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98);
- break;
- case 13:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98);
- break;
- case 14:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98);
- break;
- case 15:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98);
- break;
- case 16:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x98);
- break;
- case 17:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x80);
- break;
- case 18:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98);
- break;
- case 19:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x98);
- break;
- case 20:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x98);
- break;
- }
- }
- else
- {
- // disable PS tdma
- switch(pCoexDm->curPsTdma)
- {
- case 0:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
- break;
- case 1:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0);
- break;
- default:
- halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0);
- break;
- }
- }
-
- // update pre state
- pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn;
- pCoexDm->prePsTdma = pCoexDm->curPsTdma;
-}
-
-
-VOID
-halbtc8723a2ant_CoexAllOff(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // fw all off
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
-
- // sw all off
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
-
- // hw all off
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-}
-
-VOID
-halbtc8723a2ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- // force to reset coex mechanism
- halbtc8723a2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0x55555555, 0xffff, 0x3);
- halbtc8723a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, FALSE);
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
-
- halbtc8723a2ant_AgcTable(pBtCoexist, FORCE_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, FORCE_EXEC, FALSE);
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE);
- halbtc8723a2ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, FORCE_EXEC, FALSE, 0xc0);
-}
-
-VOID
-halbtc8723a2ant_BtInquiryPage(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bLowPwrDisable=true;
-
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
-
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
-}
-
-VOID
-halbtc8723a2ant_BtEnableAction(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BOOLEAN bWifiConnected=FALSE;
-
- // Here we need to resend some wifi info to BT
- // because bt is reset and loss of the info.
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
- if(bWifiConnected)
- {
- halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_CONNECT);
- }
- else
- {
- halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_DISCONNECT);
- }
-
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE);
-}
-
-VOID
-halbtc8723a2ant_MonitorBtCtr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u4Byte regHPTxRx, regLPTxRx, u4Tmp;
- u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0;
- u1Byte u1Tmp;
-
- regHPTxRx = 0x770;
- regLPTxRx = 0x774;
-
- u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regHPTxRx);
- regHPTx = u4Tmp & MASKLWORD;
- regHPRx = (u4Tmp & MASKHWORD)>>16;
-
- u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regLPTxRx);
- regLPTx = u4Tmp & MASKLWORD;
- regLPRx = (u4Tmp & MASKHWORD)>>16;
-
- pCoexSta->highPriorityTx = regHPTx;
- pCoexSta->highPriorityRx = regHPRx;
- pCoexSta->lowPriorityTx = regLPTx;
- pCoexSta->lowPriorityRx = regLPRx;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx));
-
- // reset counter
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0xc);
-}
-
-VOID
-halbtc8723a2ant_MonitorBtEnableDisable(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- static BOOLEAN bPreBtDisabled=FALSE;
- static u4Byte btDisableCnt=0;
- BOOLEAN bBtActive=true, bBtDisabled=FALSE;
-
- // This function check if bt is disabled
-
- if( pCoexSta->highPriorityTx == 0 &&
- pCoexSta->highPriorityRx == 0 &&
- pCoexSta->lowPriorityTx == 0 &&
- pCoexSta->lowPriorityRx == 0)
- {
- bBtActive = FALSE;
- }
- if( pCoexSta->highPriorityTx == 0xffff &&
- pCoexSta->highPriorityRx == 0xffff &&
- pCoexSta->lowPriorityTx == 0xffff &&
- pCoexSta->lowPriorityRx == 0xffff)
- {
- bBtActive = FALSE;
- }
- if(bBtActive)
- {
- btDisableCnt = 0;
- bBtDisabled = FALSE;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n"));
- }
- else
- {
- btDisableCnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n",
- btDisableCnt));
- if(btDisableCnt >= 2)
- {
- bBtDisabled = true;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n"));
- }
- }
- if(bPreBtDisabled != bBtDisabled)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n",
- (bPreBtDisabled ? "disabled":"enabled"),
- (bBtDisabled ? "disabled":"enabled")));
- bPreBtDisabled = bBtDisabled;
- if(!bBtDisabled)
- {
- halbtc8723a2ant_BtEnableAction(pBtCoexist);
- }
- }
-}
-
-BOOLEAN
-halbtc8723a2ant_IsCommonAction(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
- BOOLEAN bCommon=FALSE, bWifiConnected=FALSE;
- BOOLEAN bLowPwrDisable=FALSE;
-
- if(!pStackInfo->bBtLinkExist)
- {
- bLowPwrDisable = FALSE;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
- }
- else
- {
- bLowPwrDisable = true;
- pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable);
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected);
-
- if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
- BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi idle + Bt idle!!\n"));
-
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
-
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
-
- bCommon = true;
- }
- else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
- (BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-idle + BT idle!!\n"));
-
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
-
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
-
- bCommon = true;
- }
- else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
- (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi idle + Bt connected idle!!\n"));
-
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
-
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
-
- bCommon = true;
- }
- else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
- (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-idle + Bt connected idle!!\n"));
-
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
-
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
-
- bCommon = true;
- }
- else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) &&
- (BT_8723A_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) )
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi idle + BT non-idle!!\n"));
-
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
-
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
-
- bCommon = true;
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non-idle + BT non-idle!!\n"));
- halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20);
-
- bCommon = FALSE;
- }
-
- return bCommon;
-}
-VOID
-halbtc8723a2ant_TdmaDurationAdjust(
- IN PBTC_COEXIST pBtCoexist,
- IN BOOLEAN bScoHid,
- IN BOOLEAN bTxPause,
- IN u1Byte maxInterval
- )
-{
- static s4Byte up,dn,m,n,WaitCount;
- s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration
- u1Byte retryCount=0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjust()\n"));
-
- if(pCoexDm->bResetTdmaAdjust)
- {
- pCoexDm->bResetTdmaAdjust = FALSE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
- {
- if(bScoHid)
- {
- if(bTxPause)
- {
- if(maxInterval == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
- pCoexDm->psTdmaDuAdjType = 13;
- }
- else if(maxInterval == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(maxInterval == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- }
- else
- {
- if(maxInterval == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(maxInterval == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(maxInterval == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- }
- }
- else
- {
- if(bTxPause)
- {
- if(maxInterval == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
- pCoexDm->psTdmaDuAdjType = 5;
- }
- else if(maxInterval == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(maxInterval == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- }
- else
- {
- if(maxInterval == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- pCoexDm->psTdmaDuAdjType = 1;
- }
- else if(maxInterval == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(maxInterval == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- }
- }
- }
- //============
- up = 0;
- dn = 0;
- m = 1;
- n= 3;
- result = 0;
- WaitCount = 0;
- }
- else
- {
- //acquire the BT TRx retry count from BT_Info byte2
- retryCount = pCoexSta->btRetryCnt;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount));
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n",
- up, dn, m, n, WaitCount));
- result = 0;
- WaitCount++;
-
- if(retryCount == 0) // no retry in the last 2-second duration
- {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration
- {
- WaitCount = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n"));
- }
- }
- else if (retryCount <= 3) // <=3 retry in the last 2-second duration
- {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration
- {
- if (WaitCount <= 2)
- m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^
- else
- m = 1;
-
- if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- WaitCount = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
- }
- }
- else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration
- {
- if (WaitCount == 1)
- m++; // ÁקK¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^
- else
- m = 1;
-
- if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration.
- m = 20;
-
- n = 3*m;
- up = 0;
- dn = 0;
- WaitCount = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], max Interval = %d\n", maxInterval));
- if(maxInterval == 1)
- {
- if(bTxPause)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
-
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
- pCoexDm->psTdmaDuAdjType = 5;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 4)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- pCoexDm->psTdmaDuAdjType = 8;
- }
- if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
- pCoexDm->psTdmaDuAdjType = 13;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 12)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- pCoexDm->psTdmaDuAdjType = 16;
- }
-
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 5)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- pCoexDm->psTdmaDuAdjType = 8;
- }
- else if(pCoexDm->curPsTdma == 13)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- pCoexDm->psTdmaDuAdjType = 16;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 8)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5);
- pCoexDm->psTdmaDuAdjType = 5;
- }
- else if(pCoexDm->curPsTdma == 16)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
- pCoexDm->psTdmaDuAdjType = 13;
- }
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
- if(pCoexDm->curPsTdma == 5)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- pCoexDm->psTdmaDuAdjType = 1;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 8)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- pCoexDm->psTdmaDuAdjType = 4;
- }
- if(pCoexDm->curPsTdma == 13)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 16)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- pCoexDm->psTdmaDuAdjType = 12;
- }
-
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- pCoexDm->psTdmaDuAdjType = 4;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- pCoexDm->psTdmaDuAdjType = 12;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 4)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1);
- pCoexDm->psTdmaDuAdjType = 1;
- }
- else if(pCoexDm->curPsTdma == 12)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- pCoexDm->psTdmaDuAdjType = 9;
- }
- }
- }
- }
- else if(maxInterval == 2)
- {
- if(bTxPause)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 4)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- pCoexDm->psTdmaDuAdjType = 8;
- }
- if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 12)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- pCoexDm->psTdmaDuAdjType = 16;
- }
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 5)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- pCoexDm->psTdmaDuAdjType = 8;
- }
- else if(pCoexDm->curPsTdma == 13)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- pCoexDm->psTdmaDuAdjType = 16;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 8)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- pCoexDm->psTdmaDuAdjType = 6;
- }
- else if(pCoexDm->curPsTdma == 16)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- pCoexDm->psTdmaDuAdjType = 14;
- }
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
- if(pCoexDm->curPsTdma == 5)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 8)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- pCoexDm->psTdmaDuAdjType = 4;
- }
- if(pCoexDm->curPsTdma == 13)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 16)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- pCoexDm->psTdmaDuAdjType = 12;
- }
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- pCoexDm->psTdmaDuAdjType = 4;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- pCoexDm->psTdmaDuAdjType = 12;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 4)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- pCoexDm->psTdmaDuAdjType = 2;
- }
- else if(pCoexDm->curPsTdma == 12)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- pCoexDm->psTdmaDuAdjType = 10;
- }
- }
- }
- }
- else if(maxInterval == 3)
- {
- if(bTxPause)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n"));
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 4)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- pCoexDm->psTdmaDuAdjType = 8;
- }
- if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 12)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- pCoexDm->psTdmaDuAdjType = 16;
- }
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 5)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- pCoexDm->psTdmaDuAdjType = 8;
- }
- else if(pCoexDm->curPsTdma == 13)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- pCoexDm->psTdmaDuAdjType = 16;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 8)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7);
- pCoexDm->psTdmaDuAdjType = 7;
- }
- else if(pCoexDm->curPsTdma == 16)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- pCoexDm->psTdmaDuAdjType = 15;
- }
- }
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n"));
- if(pCoexDm->curPsTdma == 5)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 6)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 7)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 8)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- pCoexDm->psTdmaDuAdjType = 4;
- }
- if(pCoexDm->curPsTdma == 13)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 14)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 15)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 16)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- pCoexDm->psTdmaDuAdjType = 12;
- }
- if(result == -1)
- {
- if(pCoexDm->curPsTdma == 1)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- pCoexDm->psTdmaDuAdjType = 4;
- }
- else if(pCoexDm->curPsTdma == 9)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- pCoexDm->psTdmaDuAdjType = 12;
- }
- }
- else if (result == 1)
- {
- if(pCoexDm->curPsTdma == 4)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 3)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 2)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3);
- pCoexDm->psTdmaDuAdjType = 3;
- }
- else if(pCoexDm->curPsTdma == 12)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 11)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- else if(pCoexDm->curPsTdma == 10)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- pCoexDm->psTdmaDuAdjType = 11;
- }
- }
- }
- }
- }
-
- // if current PsTdma not match with the recorded one (when scan, dhcp...),
- // then we have to adjust it back to the previous record one.
- if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType)
- {
- BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n",
- pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType));
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
-
- if( !bScan && !bLink && !bRoam)
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType);
- }
- else
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
- }
- }
-}
-
-// SCO only or SCO+PAN(HS)
-VOID
-halbtc8723a2ant_ActionSco(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1;
- u4Byte wifiBw;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15);
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-
-VOID
-halbtc8723a2ant_ActionHid(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1;
- u4Byte wifiBw;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13);
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-//A2DP only / PAN(EDR) only/ A2DP+PAN(HS)
-VOID
-halbtc8723a2ant_ActionA2dp(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
- }
- else
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 3);
- }
- else
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 1);
- }
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3);
- }
- else
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 3);
- }
- else
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, true, 1);
- }
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-VOID
-halbtc8723a2ant_ActionPanEdr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-
-//PAN(HS) only
-VOID
-halbtc8723a2ant_ActionPanHs(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState;
- u4Byte wifiBw;
-
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- }
- else
- {
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- }
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- }
- else
- {
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0);
- }
-
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-//PAN(EDR)+A2DP
-VOID
-halbtc8723a2ant_ActionPanEdrA2dp(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- }
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6);
- }
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-VOID
-halbtc8723a2ant_ActionPanEdrHid(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1;
- u4Byte wifiBw;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- }
- else
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- }
-
- // sw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-// HID+A2DP+PAN(EDR)
-VOID
-halbtc8723a2ant_ActionHidA2dpPanEdr(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- }
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14);
- }
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-VOID
-halbtc8723a2ant_ActionHidA2dp(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte wifiRssiState, wifiRssiState1, btInfoExt;
- u4Byte wifiBw;
-
- btInfoExt = pCoexSta->btInfoExt;
-
- if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist))
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, true);
- else
- halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- if(BTC_WIFI_BW_HT40 == wifiBw)
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 3);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 1);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 1);
- }
- }
-
- // sw mechanism
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0);
- wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0);
-
- // fw mechanism
- if( (wifiRssiState == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) )
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 3);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, FALSE, 1);
- }
- }
- else
- {
- if(btInfoExt&BIT0) //a2dp basic rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3);
- }
- else //a2dp edr rate
- {
- halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, true, true, 1);
- }
- }
-
- // sw mechanism
- if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) ||
- (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) )
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, true);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- else
- {
- halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE);
- halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0);
- }
- }
-}
-
-VOID
-halbtc8723a2ant_RunCoexistMechanism(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
- u1Byte btInfoOriginal=0, btRetryCnt=0;
- u1Byte algorithm=0;
-
- if(pBtCoexist->manual_control)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Manual control!!!\n"));
- return;
- }
-
- if(pStackInfo->bProfileNotified)
- {
- if(pCoexSta->bHoldForStackOperation)
- {
- // if bt inquiry/page/pair, do not execute.
- return;
- }
-
- algorithm = halbtc8723a2ant_ActionAlgorithm(pBtCoexist);
- if(pCoexSta->bHoldPeriodCnt && (BT_8723A_2ANT_COEX_ALGO_PANHS!=algorithm))
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex],Hold BT inquiry/page scan setting (cnt = %d)!!\n",
- pCoexSta->bHoldPeriodCnt));
- if(pCoexSta->bHoldPeriodCnt >= 6)
- {
- pCoexSta->bHoldPeriodCnt = 0;
- // next time the coexist parameters should be reset again.
- }
- else
- pCoexSta->bHoldPeriodCnt++;
- return;
- }
-
- pCoexDm->curAlgorithm = algorithm;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm));
- if(halbtc8723a2ant_IsCommonAction(pBtCoexist))
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant common.\n"));
- pCoexDm->bResetTdmaAdjust = true;
- }
- else
- {
- if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n",
- pCoexDm->preAlgorithm, pCoexDm->curAlgorithm));
- pCoexDm->bResetTdmaAdjust = true;
- }
- switch(pCoexDm->curAlgorithm)
- {
- case BT_8723A_2ANT_COEX_ALGO_SCO:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n"));
- halbtc8723a2ant_ActionSco(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID.\n"));
- halbtc8723a2ant_ActionHid(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n"));
- halbtc8723a2ant_ActionA2dp(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"));
- halbtc8723a2ant_ActionPanEdr(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n"));
- halbtc8723a2ant_ActionPanHs(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"));
- halbtc8723a2ant_ActionPanEdrA2dp(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_PANEDR_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
- halbtc8723a2ant_ActionPanEdrHid(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
- halbtc8723a2ant_ActionHidA2dpPanEdr(pBtCoexist);
- break;
- case BT_8723A_2ANT_COEX_ALGO_HID_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"));
- halbtc8723a2ant_ActionHidA2dp(pBtCoexist);
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"));
- halbtc8723a2ant_CoexAllOff(pBtCoexist);
- break;
- }
- pCoexDm->preAlgorithm = pCoexDm->curAlgorithm;
- }
- }
-}
-
-//============================================================
-// work around function start with wa_halbtc8723a2ant_
-//============================================================
-VOID
-wa_halbtc8723a2ant_MonitorC2h(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u1Byte tmp1b=0x0;
- u4Byte curC2hTotalCnt=0x0;
- static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0;
-
- curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_2ANT_BT_RSP];
-
- if(curC2hTotalCnt == preC2hTotalCnt)
- {
- sameCntPollingTime++;
- }
- else
- {
- preC2hTotalCnt = curC2hTotalCnt;
- sameCntPollingTime = 0;
- }
-
- if(sameCntPollingTime >= 2)
- {
- tmp1b = pBtCoexist->btc_read_1byte(pBtCoexist, 0x1af);
- if(tmp1b != 0x0)
- {
- pCoexSta->c2hHangDetectCnt++;
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x1af, 0x0);
- }
- }
-}
-
-//============================================================
-// extern function start with EXhalbtc8723a2ant_
-//============================================================
-VOID
-EXhalbtc8723a2ant_InitHwConfig(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- u4Byte u4Tmp=0;
- u1Byte u1Tmp=0;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 2Ant Init HW Config!!\n"));
-
- // backup rf 0x1e value
- pCoexDm->btRf0x1eBackup =
- pBtCoexist->btc_get_rf_reg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff);
-
- // Enable counter statistics
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0x4);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x778, 0x3);
- pBtCoexist->btc_write_1byte(pBtCoexist, 0x40, 0x20);
-}
-
-VOID
-EXhalbtc8723a2ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n"));
-
- halbtc8723a2ant_InitCoexDm(pBtCoexist);
-}
-
-VOID
-EXhalbtc8723a2ant_DisplayCoexInfo(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- struct btc_board_info * pBoardInfo=&pBtCoexist->board_info;
- PBTC_STACK_INFO pStackInfo=&pBtCoexist->stack_info;
- pu1Byte cliBuf=pBtCoexist->cli_buf;
- u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0;
- u4Byte u4Tmp[4];
- BOOLEAN bRoam=FALSE, bScan=FALSE, bLink=FALSE, bWifiUnder5G=FALSE;
- BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE;
- s4Byte wifiRssi=0, btHsRssi=0;
- u4Byte wifiBw, wifiTrafficDir;
- u1Byte wifiDot11Chnl, wifiHsChnl;
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cliBuf);
-
- if(!pBoardInfo->bt_exist)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cliBuf);
- return;
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \
- pBoardInfo->pg_ant_num, pBoardInfo->btdm_ant_num);
- CL_PRINTF(cliBuf);
-
- if(pBtCoexist->manual_control)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!");
- CL_PRINTF(cliBuf);
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
- ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \
- wifiDot11Chnl, wifiHsChnl, bBtHsOn);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \
- pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1],
- pCoexDm->wifiChnlInfo[2]);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \
- wifiRssi, btHsRssi);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \
- bLink, bRoam, bScan);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \
- (bWifiUnder5G? "5G":"2.4G"),
- ((BTC_WIFI_BW_LEGACY==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40==wifiBw)? "HT40":"HT20"))),
- ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")));
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \
- ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))),
- pCoexSta->btRssi, pCoexSta->btRetryCnt);
- CL_PRINTF(cliBuf);
-
- if(pStackInfo->bProfileNotified)
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \
- pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO);
- }
-
- btInfoExt = pCoexSta->btInfoExt;
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \
- (btInfoExt&BIT0)? "Basic rate":"EDR rate");
- CL_PRINTF(cliBuf);
-
- for(i=0; i<BT_INFO_SRC_8723A_2ANT_MAX; i++)
- {
- if(pCoexSta->btInfoC2hCnt[i])
- {
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a2Ant[i], \
- pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1],
- pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3],
- pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5],
- pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]);
- CL_PRINTF(cliBuf);
- }
- }
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \
- pCoexSta->c2hHangDetectCnt);
- CL_PRINTF(cliBuf);
-
- // Sw mechanism
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============");
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \
- pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->limited_dig);
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
- pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl);
- CL_PRINTF(cliBuf);
-
- // Fw mechanism
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============");
- CL_PRINTF(cliBuf);
-
- if(!pBtCoexist->manual_control)
- {
- psTdmaCase = pCoexDm->curPsTdma;
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \
- pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1],
- pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3],
- pCoexDm->psTdmaPara[4], psTdmaCase);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \
- pCoexDm->bCurDecBtPwr, pCoexDm->bCurIgnoreWlanAct);
- CL_PRINTF(cliBuf);
- }
-
- // Hw setting
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============");
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \
- pCoexDm->btRf0x1eBackup);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x778);
- u1Tmp[1] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x783);
- u1Tmp[2] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x796);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
- u1Tmp[0], u1Tmp[1], u1Tmp[2]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x880);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x40);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \
- u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x550);
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x522);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \
- u4Tmp[0], u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x484);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xc50);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \
- u4Tmp[0]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda0);
- u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda4);
- u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xda8);
- u4Tmp[3] = pBtCoexist->btc_read_4byte(pBtCoexist, 0xdac);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \
- u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]);
- CL_PRINTF(cliBuf);
-
- u4Tmp[0] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c0);
- u4Tmp[1] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c4);
- u4Tmp[2] = pBtCoexist->btc_read_4byte(pBtCoexist, 0x6c8);
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x6cc);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
- u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \
- pCoexSta->highPriorityRx, pCoexSta->highPriorityTx);
- CL_PRINTF(cliBuf);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \
- pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx);
- CL_PRINTF(cliBuf);
-
- // Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang
- u1Tmp[0] = pBtCoexist->btc_read_1byte(pBtCoexist, 0x41b);
- CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x41b (mgntQ hang chk == 0xf)", \
- u1Tmp[0]);
- CL_PRINTF(cliBuf);
-
- pBtCoexist->btc_disp_dbg_msg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-VOID
-EXhalbtc8723a2ant_IpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_IPS_ENTER == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n"));
- halbtc8723a2ant_CoexAllOff(pBtCoexist);
- }
- else if(BTC_IPS_LEAVE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n"));
- //halbtc8723a2ant_InitCoexDm(pBtCoexist);
- }
-}
-
-VOID
-EXhalbtc8723a2ant_LpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_LPS_ENABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n"));
- }
- else if(BTC_LPS_DISABLE == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n"));
- }
-}
-
-VOID
-EXhalbtc8723a2ant_ScanNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_SCAN_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n"));
- }
- else if(BTC_SCAN_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n"));
- }
-}
-
-VOID
-EXhalbtc8723a2ant_ConnectNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_ASSOCIATE_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n"));
- }
- else if(BTC_ASSOCIATE_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n"));
- }
-}
-
-VOID
-EXhalbtc8723a2ant_MediaStatusNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_MEDIA_CONNECT == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n"));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n"));
- }
-
- halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, type);
-}
-
-VOID
-EXhalbtc8723a2ant_SpecialPacketNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(type == BTC_PACKET_DHCP)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n"));
- }
-}
-
-VOID
-EXhalbtc8723a2ant_BtInfoNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN pu1Byte tmpBuf,
- IN u1Byte length
- )
-{
- u1Byte btInfo=0;
- u1Byte i, rspSource=0;
- BOOLEAN bBtBusy=FALSE, limited_dig=FALSE;
- BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE;
-
- pCoexSta->bC2hBtInfoReqSent = FALSE;
-
- rspSource = BT_INFO_SRC_8723A_2ANT_BT_RSP;
- pCoexSta->btInfoC2hCnt[rspSource]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length));
- for(i=0; i<length; i++)
- {
- pCoexSta->btInfoC2h[rspSource][i] = tmpBuf[i];
- if(i == 0)
- btInfo = tmpBuf[i];
- if(i == length-1)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]));
- }
- else
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i]));
- }
- }
-
- if(BT_INFO_SRC_8723A_2ANT_WIFI_FW != rspSource)
- {
- pCoexSta->btRetryCnt =
- pCoexSta->btInfoC2h[rspSource][1];
-
- pCoexSta->btRssi =
- pCoexSta->btInfoC2h[rspSource][2]*2+10;
-
- pCoexSta->btInfoExt =
- pCoexSta->btInfoC2h[rspSource][3];
- }
-
- pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn);
- // check BIT2 first ==> check if bt is under inquiry or page scan
- if(btInfo & BT_INFO_8723A_2ANT_B_INQ_PAGE)
- {
- pCoexSta->bC2hBtInquiryPage = true;
- }
- else
- {
- pCoexSta->bC2hBtInquiryPage = FALSE;
- }
-}
-
-VOID
-EXhalbtc8723a2ant_StackOperationNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- )
-{
- if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair start notify\n"));
- pCoexSta->bHoldForStackOperation = true;
- pCoexSta->bHoldPeriodCnt = 1;
- halbtc8723a2ant_BtInquiryPage(pBtCoexist);
- }
- else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type)
- {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n"));
- pCoexSta->bHoldForStackOperation = FALSE;
- }
-}
-
-VOID
-EXhalbtc8723a2ant_HaltNotify(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n"));
-
- halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true);
- EXhalbtc8723a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT);
-}
-
-VOID
-EXhalbtc8723a2ant_Periodical(
- IN PBTC_COEXIST pBtCoexist
- )
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 2Ant Periodical!!\n"));
-
- // work around for c2h hang
- wa_halbtc8723a2ant_MonitorC2h(pBtCoexist);
-
- halbtc8723a2ant_QueryBtInfo(pBtCoexist);
- halbtc8723a2ant_MonitorBtCtr(pBtCoexist);
- halbtc8723a2ant_MonitorBtEnableDisable(pBtCoexist);
-
- halbtc8723a2ant_RunCoexistMechanism(pBtCoexist);
-}
-
-
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.h b/drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.h
deleted file mode 100644
index c07d3738aadc..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723a2ant.h
+++ /dev/null
@@ -1,179 +0,0 @@
-//===========================================
-// The following is for 8723A 2Ant BT Co-exist definition
-//===========================================
-#define BT_INFO_8723A_2ANT_B_FTP BIT7
-#define BT_INFO_8723A_2ANT_B_A2DP BIT6
-#define BT_INFO_8723A_2ANT_B_HID BIT5
-#define BT_INFO_8723A_2ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8723A_2ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8723A_2ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8723A_2ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8723A_2ANT_B_CONNECTION BIT0
-
-#define BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT 2
-
-typedef enum _BT_INFO_SRC_8723A_2ANT{
- BT_INFO_SRC_8723A_2ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8723A_2ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8723A_2ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8723A_2ANT_MAX
-}BT_INFO_SRC_8723A_2ANT,*PBT_INFO_SRC_8723A_2ANT;
-
-typedef enum _BT_8723A_2ANT_BT_STATUS{
- BT_8723A_2ANT_BT_STATUS_IDLE = 0x0,
- BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8723A_2ANT_BT_STATUS_NON_IDLE = 0x2,
- BT_8723A_2ANT_BT_STATUS_MAX
-}BT_8723A_2ANT_BT_STATUS,*PBT_8723A_2ANT_BT_STATUS;
-
-typedef enum _BT_8723A_2ANT_COEX_ALGO{
- BT_8723A_2ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8723A_2ANT_COEX_ALGO_SCO = 0x1,
- BT_8723A_2ANT_COEX_ALGO_HID = 0x2,
- BT_8723A_2ANT_COEX_ALGO_A2DP = 0x3,
- BT_8723A_2ANT_COEX_ALGO_PANEDR = 0x4,
- BT_8723A_2ANT_COEX_ALGO_PANHS = 0x5,
- BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x6,
- BT_8723A_2ANT_COEX_ALGO_PANEDR_HID = 0x7,
- BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x8,
- BT_8723A_2ANT_COEX_ALGO_HID_A2DP = 0x9,
- BT_8723A_2ANT_COEX_ALGO_MAX
-}BT_8723A_2ANT_COEX_ALGO,*PBT_8723A_2ANT_COEX_ALGO;
-
-typedef struct _COEX_DM_8723A_2ANT{
- // fw mechanism
- BOOLEAN bPreDecBtPwr;
- BOOLEAN bCurDecBtPwr;
- //BOOLEAN bPreBtLnaConstrain;
- //BOOLEAN bCurBtLnaConstrain;
- //u1Byte bPreBtPsdMode;
- //u1Byte bCurBtPsdMode;
- u1Byte preFwDacSwingLvl;
- u1Byte curFwDacSwingLvl;
- BOOLEAN bCurIgnoreWlanAct;
- BOOLEAN bPreIgnoreWlanAct;
- u1Byte prePsTdma;
- u1Byte curPsTdma;
- u1Byte psTdmaPara[5];
- u1Byte psTdmaDuAdjType;
- BOOLEAN bResetTdmaAdjust;
- BOOLEAN bPrePsTdmaOn;
- BOOLEAN bCurPsTdmaOn;
- //BOOLEAN bPreBtAutoReport;
- //BOOLEAN bCurBtAutoReport;
-
- // sw mechanism
- BOOLEAN bPreRfRxLpfShrink;
- BOOLEAN bCurRfRxLpfShrink;
- u4Byte btRf0x1eBackup;
- BOOLEAN bPreLowPenaltyRa;
- BOOLEAN bCurLowPenaltyRa;
- BOOLEAN bPreDacSwingOn;
- u4Byte preDacSwingLvl;
- BOOLEAN bCurDacSwingOn;
- u4Byte curDacSwingLvl;
- BOOLEAN bPreAdcBackOff;
- BOOLEAN bCurAdcBackOff;
- BOOLEAN bPreAgcTableEn;
- BOOLEAN bCurAgcTableEn;
- u4Byte preVal0x6c0;
- u4Byte curVal0x6c0;
- u4Byte preVal0x6c8;
- u4Byte curVal0x6c8;
- u1Byte preVal0x6cc;
- u1Byte curVal0x6cc;
- BOOLEAN limited_dig;
-
- // algorithm related
- u1Byte preAlgorithm;
- u1Byte curAlgorithm;
- u1Byte btStatus;
- u1Byte wifiChnlInfo[3];
-} COEX_DM_8723A_2ANT, *PCOEX_DM_8723A_2ANT;
-
-typedef struct _COEX_STA_8723A_2ANT{
- u4Byte highPriorityTx;
- u4Byte highPriorityRx;
- u4Byte lowPriorityTx;
- u4Byte lowPriorityRx;
- u1Byte btRssi;
- u1Byte preBtRssiState;
- u1Byte preBtRssiState1;
- u1Byte preWifiRssiState[4];
- BOOLEAN bC2hBtInfoReqSent;
- u1Byte btInfoC2h[BT_INFO_SRC_8723A_2ANT_MAX][10];
- u4Byte btInfoC2hCnt[BT_INFO_SRC_8723A_2ANT_MAX];
- BOOLEAN bC2hBtInquiryPage;
- u1Byte btRetryCnt;
- u1Byte btInfoExt;
- BOOLEAN bHoldForStackOperation;
- u1Byte bHoldPeriodCnt;
- // this is for c2h hang work-around
- u4Byte c2hHangDetectCnt;
-}COEX_STA_8723A_2ANT, *PCOEX_STA_8723A_2ANT;
-
-//===========================================
-// The following is interface which will notify coex module.
-//===========================================
-VOID
-EXhalbtc8723a2ant_InitHwConfig(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a2ant_InitCoexDm(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a2ant_IpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_LpsNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_ScanNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_ConnectNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_MediaStatusNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_SpecialPacketNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_HaltNotify(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a2ant_Periodical(
- IN PBTC_COEXIST pBtCoexist
- );
-VOID
-EXhalbtc8723a2ant_BtInfoNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN pu1Byte tmpBuf,
- IN u1Byte length
- );
-VOID
-EXhalbtc8723a2ant_StackOperationNotify(
- IN PBTC_COEXIST pBtCoexist,
- IN u1Byte type
- );
-VOID
-EXhalbtc8723a2ant_DisplayCoexInfo(
- IN PBTC_COEXIST pBtCoexist
- );
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c
deleted file mode 100644
index c9693944c137..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c
+++ /dev/null
@@ -1,3892 +0,0 @@
-/***************************************************************
- * Description:
- *
- * This file is for RTL8723B Co-exist mechanism
- *
- * History
- * 2012/11/15 Cosa first check in.
- *
- ***************************************************************/
-
-
-/***************************************************************
- * include files
- ***************************************************************/
-#include "halbt_precomp.h"
-#if 1
-/***************************************************************
- * Global variables, these are static variables
- ***************************************************************/
-static struct coex_dm_8723b_1ant glcoex_dm_8723b_1ant;
-static struct coex_dm_8723b_1ant *coex_dm = &glcoex_dm_8723b_1ant;
-static struct coex_sta_8723b_1ant glcoex_sta_8723b_1ant;
-static struct coex_sta_8723b_1ant *coex_sta = &glcoex_sta_8723b_1ant;
-
-static const char *const GLBtInfoSrc8723b1Ant[] = {
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-static u32 glcoex_ver_date_8723b_1ant = 20130906;
-static u32 glcoex_ver_8723b_1ant = 0x45;
-
-/***************************************************************
- * local function proto type if needed
- ***************************************************************/
-/***************************************************************
- * local function start with halbtc8723b1ant_
- ***************************************************************/
-static u8 halbtc8723b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh,
- u8 rssi_thresh1)
-{
- s32 bt_rssi=0;
- u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
-
- bt_rssi = coex_sta->bt_rssi;
-
- if (level_num == 2){
- if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- if (bt_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) {
- bt_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to High\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at Low\n");
- }
- } else {
- if (bt_rssi < rssi_thresh) {
- bt_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Low\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at High\n");
- }
- }
- } else if (level_num == 3) {
- if (rssi_thresh > rssi_thresh1) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi thresh error!!\n");
- return coex_sta->pre_bt_rssi_state;
- }
-
- if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- if (bt_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) {
- bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Medium\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at Low\n");
- }
- } else if ((coex_sta->pre_bt_rssi_state ==
- BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_bt_rssi_state ==
- BTC_RSSI_STATE_STAY_MEDIUM)) {
- if (bt_rssi >= rssi_thresh1 +
- BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) {
- bt_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to High\n");
- } else if (bt_rssi < rssi_thresh) {
- bt_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Low\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at Medium\n");
- }
- } else {
- if (bt_rssi < rssi_thresh1) {
- bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Medium\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at High\n");
- }
- }
- }
-
- coex_sta->pre_bt_rssi_state = bt_rssi_state;
-
- return bt_rssi_state;
-}
-
-static u8 halbtc8723b1ant_wifi_rssi_state(struct btc_coexist *btcoexist,
- u8 index, u8 level_num,
- u8 rssi_thresh, u8 rssi_thresh1)
-{
- s32 wifi_rssi=0;
- u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
-
- btcoexist->btc_get(btcoexist,
- BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
-
- if (level_num == 2) {
- if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_LOW)) {
- if (wifi_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) {
- wifi_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to High\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at Low\n");
- }
- } else {
- if (wifi_rssi < rssi_thresh) {
- wifi_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Low\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at High\n");
- }
- }
- } else if (level_num == 3) {
- if (rssi_thresh > rssi_thresh1) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI thresh error!!\n");
- return coex_sta->pre_wifi_rssi_state[index];
- }
-
- if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_LOW)) {
- if (wifi_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) {
- wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Medium\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at Low\n");
- }
- } else if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_MEDIUM)) {
- if (wifi_rssi >= rssi_thresh1 +
- BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) {
- wifi_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to High\n");
- } else if (wifi_rssi < rssi_thresh) {
- wifi_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Low\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at Medium\n");
- }
- } else {
- if (wifi_rssi < rssi_thresh1) {
- wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Medium\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at High\n");
- }
- }
- }
-
- coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
-
- return wifi_rssi_state;
-}
-
-static void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist,
- bool force_exec, u32 dis_rate_mask)
-{
- coex_dm->curra_mask = dis_rate_mask;
-
- if (force_exec || (coex_dm->prera_mask != coex_dm->curra_mask))
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_ra_mask,
- &coex_dm->curra_mask);
-
- coex_dm->prera_mask = coex_dm->curra_mask;
-}
-
-static void halbtc8723b1ant_auto_rate_fallback_retry(
- struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- bool wifi_under_bmode = false;
-
- coex_dm->cur_arfr_type = type;
-
- if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) {
- switch (coex_dm->cur_arfr_type) {
- case 0: /* normal mode */
- btcoexist->btc_write_4byte(btcoexist, 0x430,
- coex_dm->backup_arfr_cnt1);
- btcoexist->btc_write_4byte(btcoexist, 0x434,
- coex_dm->backup_arfr_cnt2);
- break;
- case 1:
- btcoexist->btc_get(btcoexist,
- BTC_GET_BL_WIFI_UNDER_B_MODE,
- &wifi_under_bmode);
- if (wifi_under_bmode) {
- btcoexist->btc_write_4byte(btcoexist,
- 0x430, 0x0);
- btcoexist->btc_write_4byte(btcoexist,
- 0x434, 0x01010101);
- } else {
- btcoexist->btc_write_4byte(btcoexist,
- 0x430, 0x0);
- btcoexist->btc_write_4byte(btcoexist,
- 0x434, 0x04030201);
- }
- break;
- default:
- break;
- }
- }
-
- coex_dm->pre_arfr_type = coex_dm->cur_arfr_type;
-}
-
-static void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- coex_dm->cur_retry_limit_type = type;
-
- if (force_exec || (coex_dm->pre_retry_limit_type !=
- coex_dm->cur_retry_limit_type)) {
-
- switch (coex_dm->cur_retry_limit_type) {
- case 0: /* normal mode */
- btcoexist->btc_write_2byte(btcoexist, 0x42a,
- coex_dm->backup_retry_limit);
- break;
- case 1: /* retry limit=8 */
- btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808);
- break;
- default:
- break;
- }
- }
-
- coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type;
-}
-
-static void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- coex_dm->cur_ampdu_time_type = type;
-
- if (force_exec || (coex_dm->pre_ampdu_time_type !=
- coex_dm->cur_ampdu_time_type)) {
- switch (coex_dm->cur_ampdu_time_type) {
- case 0: /* normal mode */
- btcoexist->btc_write_1byte(btcoexist, 0x456,
- coex_dm->backup_ampdu_max_time);
- break;
- case 1: /* AMPDU timw = 0x38 * 32us */
- btcoexist->btc_write_1byte(btcoexist,
- 0x456, 0x38);
- break;
- default:
- break;
- }
- }
-
- coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type;
-}
-
-static void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist,
- bool force_exec, u8 ra_maskType, u8 arfr_type,
- u8 retry_limit_type, u8 ampdu_time_type)
-{
- switch (ra_maskType) {
- case 0: /* normal mode */
- halbtc8723b1ant_updatera_mask(btcoexist, force_exec, 0x0);
- break;
- case 1: /* disable cck 1/2 */
- halbtc8723b1ant_updatera_mask(btcoexist, force_exec,
- 0x00000003);
- break;
- /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4*/
- case 2:
- halbtc8723b1ant_updatera_mask(btcoexist, force_exec,
- 0x0001f1f7);
- break;
- default:
- break;
- }
-
- halbtc8723b1ant_auto_rate_fallback_retry(btcoexist, force_exec,
- arfr_type);
- halbtc8723b1ant_retry_limit(btcoexist, force_exec, retry_limit_type);
- halbtc8723b1ant_ampdu_maxtime(btcoexist, force_exec, ampdu_time_type);
-}
-
-static void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist,
- bool force_exec, bool rej_ap_agg_pkt,
- bool b_bt_ctrl_agg_buf_size, u8 agg_buf_size)
-{
- bool reject_rx_agg = rej_ap_agg_pkt;
- bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size;
- u8 rxAggSize = agg_buf_size;
-
- /**********************************************
- * Rx Aggregation related setting
- **********************************************/
- btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT,
- &reject_rx_agg);
- /* decide BT control aggregation buf size or not */
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
- &bt_ctrl_rx_agg_size);
- /* aggregation buf size, only work
- *when BT control Rx aggregation size. */
- btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize);
- /* real update aggregation setting */
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
-}
-
-static void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
-{
- u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
- u32 reg_hp_tx = 0, reg_hp_rx = 0;
- u32 reg_lp_tx = 0, reg_lp_rx = 0;
-
- reg_hp_txrx = 0x770;
- reg_lp_txrx = 0x774;
-
- u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
- reg_hp_tx = u32tmp & MASKLWORD;
- reg_hp_rx = (u32tmp & MASKHWORD) >> 16;
-
- u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
- reg_lp_tx = u32tmp & MASKLWORD;
- reg_lp_rx = (u32tmp & MASKHWORD) >> 16;
-
- coex_sta->high_priority_tx = reg_hp_tx;
- coex_sta->high_priority_rx = reg_hp_rx;
- coex_sta->low_priority_tx = reg_lp_tx;
- coex_sta->low_priority_rx = reg_lp_rx;
-
- /* reset counter */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
-}
-
-static void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist)
-{
- u8 h2c_parameter[1] = {0};
-
- coex_sta->c2h_bt_info_req_sent = true;
-
- h2c_parameter[0] |= BIT0; /* trigger*/
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
-}
-
-static bool halbtc8723b1ant_is_wifi_status_changed(
- struct btc_coexist *btcoexist)
-{
- static bool pre_wifi_busy = false;
- static bool pre_under_4way = false, pre_bt_hs_on = false;
- bool wifi_busy = false, under_4way = false, bt_hs_on = false;
- bool wifi_connected = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
- &under_4way);
-
- if (wifi_connected) {
- if (wifi_busy != pre_wifi_busy) {
- pre_wifi_busy = wifi_busy;
- return true;
- }
- if (under_4way != pre_under_4way) {
- pre_under_4way = under_4way;
- return true;
- }
- if (bt_hs_on != pre_bt_hs_on) {
- pre_bt_hs_on = bt_hs_on;
- return true;
- }
- }
-
- return false;
-}
-
-static void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool bt_hs_on = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
- bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
- bt_link_info->sco_exist = coex_sta->sco_exist;
- bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
- bt_link_info->pan_exist = coex_sta->pan_exist;
- bt_link_info->hid_exist = coex_sta->hid_exist;
-
- /* work around for HS mode. */
- if (bt_hs_on) {
- bt_link_info->pan_exist = true;
- bt_link_info->bt_link_exist = true;
- }
-
- /* check if Sco only */
- if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist && !bt_link_info->hid_exist)
- bt_link_info->sco_only = true;
- else
- bt_link_info->sco_only = false;
-
- /* check if A2dp only */
- if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist && !bt_link_info->hid_exist)
- bt_link_info->a2dp_only = true;
- else
- bt_link_info->a2dp_only = false;
-
- /* check if Pan only */
- if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
- bt_link_info->pan_exist && !bt_link_info->hid_exist)
- bt_link_info->pan_only = true;
- else
- bt_link_info->pan_only = false;
-
- /* check if Hid only */
- if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist && bt_link_info->hid_exist )
- bt_link_info->hid_only = true;
- else
- bt_link_info->hid_only = false;
-}
-
-static u8 halbtc8723b1ant_action_algorithm(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool bt_hs_on = false;
- u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED;
- u8 numOfDiffProfile = 0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
- if (!bt_link_info->bt_link_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], No BT link exists!!!\n");
- return algorithm;
- }
-
- if (bt_link_info->sco_exist)
- numOfDiffProfile++;
- if (bt_link_info->hid_exist)
- numOfDiffProfile++;
- if (bt_link_info->pan_exist)
- numOfDiffProfile++;
- if (bt_link_info->a2dp_exist)
- numOfDiffProfile++;
-
- if (numOfDiffProfile == 1) {
- if (bt_link_info->sco_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = SCO only\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
- } else {
- if (bt_link_info->hid_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = HID only\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
- } else if (bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = A2DP only\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP;
- } else if (bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "PAN(HS) only\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANHS;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "PAN(EDR) only\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR;
- }
- }
- }
- } else if (numOfDiffProfile == 2) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = SCO + HID\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
- } else if (bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "SCO + A2DP ==> SCO\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
- } else if (bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile "
- "= SCO + PAN(HS)\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile "
- "= SCO + PAN(EDR)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- } else {
- if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "HID + A2DP\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
- } else if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "HID + PAN(HS)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "HID + PAN(EDR)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
- }
- } else if (bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "A2DP + PAN(HS)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "A2DP + PAN(EDR)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP;
- }
- }
- }
- } else if (numOfDiffProfile == 3) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "SCO + HID + A2DP ==> HID\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_HID;
- } else if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "SCO + HID + PAN(HS)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "SCO + HID + PAN(EDR)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
- }
- } else if (bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "SCO + A2DP + PAN(HS)\n");
- algorithm = BT_8723B_1ANT_COEX_ALGO_SCO;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = SCO + "
- "A2DP + PAN(EDR) ==> HID\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- } else {
- if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "HID + A2DP + PAN(HS)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_HID_A2DP;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "HID + A2DP + PAN(EDR)\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
- }
- }
- }
- } else if (numOfDiffProfile >= 3) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Error!!! "
- "BT Profile = SCO + "
- "HID + A2DP + PAN(HS)\n");
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT Profile = "
- "SCO + HID + A2DP + PAN(EDR)"
- "==>PAN(EDR)+HID\n");
- algorithm =
- BT_8723B_1ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- }
-
- return algorithm;
-}
-
-static bool halbtc8723b1ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist)
-{
- bool ret = false;
- bool bt_hs_on = false, wifi_connected = false;
- s32 bt_hs_rssi = 0;
- u8 bt_rssi_state;
-
- if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on))
- return false;
- if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected))
- return false;
- if (!btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi))
- return false;
-
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 35, 0);
-
- if (wifi_connected) {
- if (bt_hs_on) {
- if (bt_hs_rssi > 37)
- ret = true;
- } else {
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- ret = true;
- }
- }
-
- return ret;
-}
-
-static void halbtc8723b1ant_set_fw_dac_swing_level(
- struct btc_coexist *btcoexist,
- u8 dac_swing_lvl)
-{
- u8 h2c_parameter[1] = {0};
-
- /* There are several type of dacswing
- * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
- h2c_parameter[0] = dac_swing_lvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], Set Dac Swing Level=0x%x\n", dac_swing_lvl);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x64=0x%x\n", h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
-}
-
-static void halbtc8723b1ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist,
- bool dec_bt_pwr)
-{
- u8 h2c_parameter[1] = {0};
-
- h2c_parameter[0] = 0;
-
- if (dec_bt_pwr)
- h2c_parameter[0] |= BIT1;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], decrease Bt Power : %s, FW write 0x62=0x%x\n",
- (dec_bt_pwr? "Yes!!":"No!!"),h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter);
-}
-
-static void halbtc8723b1ant_dec_bt_pwr(struct btc_coexist *btcoexist,
- bool force_exec, bool dec_bt_pwr)
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s Dec BT power = %s\n",
- (force_exec ? "force to" : ""), (dec_bt_pwr ? "ON" : "OFF"));
- coex_dm->cur_dec_bt_pwr = dec_bt_pwr;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreDecBtPwr=%d, bCurDecBtPwr=%d\n",
- coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr);
-
- if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr)
- return;
- }
- halbtc8723b1ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr);
-
- coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr;
-}
-
-#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
-static void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist,
- bool enable_auto_report)
-{
- u8 h2c_parameter[1] = {0};
-
- h2c_parameter[0] = 0;
-
- if (enable_auto_report)
- h2c_parameter[0] |= BIT0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
- (enable_auto_report? "Enabled!!":"Disabled!!"),
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
-}
-
-static void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist,
- bool force_exec, bool enable_auto_report)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s BT Auto report = %s\n",
- (force_exec? "force to":""),
- ((enable_auto_report)? "Enabled":"Disabled"));
- coex_dm->cur_bt_auto_report = enable_auto_report;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreBtAutoReport=%d, "
- "bCurBtAutoReport=%d\n",
- coex_dm->pre_bt_auto_report,
- coex_dm->cur_bt_auto_report);
-
- if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report)
- return;
- }
- halbtc8723b1ant_set_bt_auto_report(btcoexist,
- coex_dm->cur_bt_auto_report);
-
- coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
-}
-#endif
-
-static void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist,
- bool force_exec, u8 fw_dac_swing_lvl)
-{
- return;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s set FW Dac Swing level = %d\n",
- (force_exec? "force to":""), fw_dac_swing_lvl);
- coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], preFwDacSwingLvl=%d, "
- "curFwDacSwingLvl=%d\n",
- coex_dm->pre_fw_dac_swing_lvl,
- coex_dm->cur_fw_dac_swing_lvl);
-
- if (coex_dm->pre_fw_dac_swing_lvl ==
- coex_dm->cur_fw_dac_swing_lvl)
- return;
- }
-
- halbtc8723b1ant_set_fw_dac_swing_level(btcoexist,
- coex_dm->cur_fw_dac_swing_lvl);
-
- coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
-}
-
-static void halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive(
- struct btc_coexist *btcoexist,
- bool low_penalty_ra)
-{
- u8 h2c_parameter[6] = {0};
-
- h2c_parameter[0] = 0x6; /* opCode, 0x6= Retry_Penalty */
-
- if (low_penalty_ra) {
- h2c_parameter[1] |= BIT0;
- /*normal rate except MCS7/6/5, OFDM54/48/36 */
- h2c_parameter[2] = 0x00;
- h2c_parameter[3] = 0xf7; /*MCS7 or OFDM54 */
- h2c_parameter[4] = 0xf8; /*MCS6 or OFDM48 */
- h2c_parameter[5] = 0xf9; /*MCS5 or OFDM36 */
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], set WiFi Low-Penalty Retry: %s",
- (low_penalty_ra ? "ON!!" : "OFF!!"));
-
- btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
-}
-
-static void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist,
- bool force_exec, bool low_penalty_ra)
-{
- coex_dm->cur_low_penalty_ra = low_penalty_ra;
-
- if (!force_exec) {
- if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
- return;
- }
- halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive(btcoexist,
- coex_dm->cur_low_penalty_ra);
-
- coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
-}
-
-static void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist,
- u32 val0x6c0, u32 val0x6c4,
- u32 val0x6c8, u8 val0x6cc)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0);
- btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4);
- btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8);
- btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc);
- btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
-}
-
-static void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist,
- bool force_exec, u32 val0x6c0,
- u32 val0x6c4, u32 val0x6c8,
- u8 val0x6cc)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s write Coex Table 0x6c0=0x%x,"
- " 0x6c4=0x%x, 0x6cc=0x%x\n", (force_exec ? "force to" : ""),
- val0x6c0, val0x6c4, val0x6cc);
- coex_dm->cur_val0x6c0 = val0x6c0;
- coex_dm->cur_val0x6c4 = val0x6c4;
- coex_dm->cur_val0x6c8 = val0x6c8;
- coex_dm->cur_val0x6cc = val0x6cc;
-
- if (!force_exec) {
- if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
- (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
- (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
- (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
- return;
- }
- halbtc8723b1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4,
- val0x6c8, val0x6cc);
-
- coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
- coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
- coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
- coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
-}
-
-static void halbtc8723b1ant_coex_table_with_type(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- switch (type) {
- case 0:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x55555555, 0xffffff, 0x3);
- break;
- case 1:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 2:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
- 0x5a5a5a5a, 0xffffff, 0x3);
- break;
- case 3:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0xaaaaaaaa, 0xffffff, 0x3);
- break;
- case 4:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x5aaa5aaa, 0xffffff, 0x3);
- break;
- case 5:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
- 0xaaaa5a5a, 0xffffff, 0x3);
- break;
- case 6:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0xaaaa5a5a, 0xffffff, 0x3);
- break;
- case 7:
- halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5afa5afa,
- 0x5afa5afa, 0xffffff, 0x3);
- break;
- default:
- break;
- }
-}
-
-static void halbtc8723b1ant_SetFwIgnoreWlanAct(struct btc_coexist *btcoexist,
- bool enable)
-{
- u8 h2c_parameter[1] = {0};
-
- if (enable)
- h2c_parameter[0] |= BIT0; /* function enable */
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], set FW for BT Ignore Wlan_Act,"
- " FW write 0x63=0x%x\n", h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
-}
-
-static void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist,
- bool force_exec, bool enable)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s turn Ignore WlanAct %s\n",
- (force_exec ? "force to" : ""), (enable ? "ON" : "OFF"));
- coex_dm->cur_ignore_wlan_act = enable;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreIgnoreWlanAct = %d, "
- "bCurIgnoreWlanAct = %d!!\n",
- coex_dm->pre_ignore_wlan_act,
- coex_dm->cur_ignore_wlan_act);
-
- if (coex_dm->pre_ignore_wlan_act ==
- coex_dm->cur_ignore_wlan_act)
- return;
- }
- halbtc8723b1ant_SetFwIgnoreWlanAct(btcoexist, enable);
-
- coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
-}
-
-static void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist,
- u8 byte1, u8 byte2, u8 byte3,
- u8 byte4, u8 byte5)
-{
- u8 h2c_parameter[5] = {0};
- u8 real_byte1 = byte1, real_byte5 = byte5;
- bool ap_enable = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
- &ap_enable);
-
- if (ap_enable) {
- if ((byte1 & BIT4) && !(byte1 & BIT5)) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], FW for 1Ant AP mode\n");
- real_byte1 &= ~BIT4;
- real_byte1 |= BIT5;
-
- real_byte5 |= BIT5;
- real_byte5 &= ~BIT6;
- }
- }
-
- h2c_parameter[0] = real_byte1;
- h2c_parameter[1] = byte2;
- h2c_parameter[2] = byte3;
- h2c_parameter[3] = byte4;
- h2c_parameter[4] = real_byte5;
-
- coex_dm->ps_tdma_para[0] = real_byte1;
- coex_dm->ps_tdma_para[1] = byte2;
- coex_dm->ps_tdma_para[2] = byte3;
- coex_dm->ps_tdma_para[3] = byte4;
- coex_dm->ps_tdma_para[4] = real_byte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
- h2c_parameter[0],
- h2c_parameter[1] << 24 |
- h2c_parameter[2] << 16 |
- h2c_parameter[3] << 8 |
- h2c_parameter[4]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
-}
-
-static void halbtc8723b1ant_SetLpsRpwm(struct btc_coexist *btcoexist,
- u8 lps_val, u8 rpwm_val)
-{
- u8 lps = lps_val;
- u8 rpwm = rpwm_val;
-
- btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_LPS, &lps);
- btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_RPWM, &rpwm);
-}
-
-static void halbtc8723b1ant_LpsRpwm(struct btc_coexist *btcoexist,
- bool force_exec, u8 lps_val, u8 rpwm_val)
-{
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s set lps/rpwm=0x%x/0x%x \n",
- (force_exec ? "force to" : ""), lps_val, rpwm_val);
- coex_dm->cur_lps = lps_val;
- coex_dm->cur_rpwm = rpwm_val;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], LPS-RxBeaconMode=0x%x , LPS-RPWM=0x%x!!\n",
- coex_dm->cur_lps, coex_dm->cur_rpwm);
-
- if ((coex_dm->pre_lps == coex_dm->cur_lps) &&
- (coex_dm->pre_rpwm == coex_dm->cur_rpwm)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], LPS-RPWM_Last=0x%x"
- " , LPS-RPWM_Now=0x%x!!\n",
- coex_dm->pre_rpwm, coex_dm->cur_rpwm);
-
- return;
- }
- }
- halbtc8723b1ant_SetLpsRpwm(btcoexist, lps_val, rpwm_val);
-
- coex_dm->pre_lps = coex_dm->cur_lps;
- coex_dm->pre_rpwm = coex_dm->cur_rpwm;
-}
-
-static void halbtc8723b1ant_sw_mechanism1(struct btc_coexist *btcoexist,
- bool shrink_rx_lpf, bool low_penalty_ra,
- bool limited_dig, bool bt_lna_constrain)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], SM1[ShRf/ LpRA/ LimDig/ btLna] = %d %d %d %d\n",
- shrink_rx_lpf, low_penalty_ra, limited_dig, bt_lna_constrain);
-
- halbtc8723b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
-}
-
-static void halbtc8723b1ant_sw_mechanism2(struct btc_coexist *btcoexist,
- bool agc_table_shift, bool adc_backoff,
- bool sw_dac_swing, u32 dac_swing_lvl)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], SM2[AgcT/ AdcB/ SwDacSwing(lvl)] = %d %d %d\n",
- agc_table_shift, adc_backoff, sw_dac_swing);
-}
-
-static void halbtc8723b1ant_SetAntPath(struct btc_coexist *btcoexist,
- u8 ant_pos_type, bool init_hw_cfg,
- bool wifi_off)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- u32 fw_ver = 0, u32tmp = 0;
- bool pg_ext_switch = false;
- bool use_ext_switch = false;
- u8 h2c_parameter[2] = {0};
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_EXT_SWITCH, &pg_ext_switch);
- /* [31:16]=fw ver, [15:0]=fw sub ver */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
-
-
- if ((fw_ver < 0xc0000) || pg_ext_switch)
- use_ext_switch = true;
-
- if (init_hw_cfg){
- /*BT select s0/s1 is controlled by WiFi */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x1);
-
- /*Force GNT_BT to Normal */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
- } else if (wifi_off) {
- /*Force GNT_BT to High */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3);
- /*BT select s0/s1 is controlled by BT */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0);
-
- /* 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL
- * BT Vendor 0xac=0xf002 */
- u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u32tmp &= ~BIT23;
- u32tmp &= ~BIT24;
- btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp);
- }
-
- if (use_ext_switch) {
- if (init_hw_cfg) {
- /* 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT */
- u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u32tmp &= ~BIT23;
- u32tmp |= BIT24;
- btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp);
-
- if (board_info->btdm_ant_pos ==
- BTC_ANTENNA_AT_MAIN_PORT) {
- /* Main Ant to BT for IPS case 0x4c[23]=1 */
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x64, 0x1,
- 0x1);
-
- /*tell firmware "no antenna inverse"*/
- h2c_parameter[0] = 0;
- h2c_parameter[1] = 1; /*ext switch type*/
- btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
- h2c_parameter);
- } else {
- /*Aux Ant to BT for IPS case 0x4c[23]=1 */
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x64, 0x1,
- 0x0);
-
- /*tell firmware "antenna inverse"*/
- h2c_parameter[0] = 1;
- h2c_parameter[1] = 1; /*ext switch type*/
- btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
- h2c_parameter);
- }
- }
-
- /* fixed internal switch first*/
- /* fixed internal switch S1->WiFi, S0->BT*/
- if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
- else/* fixed internal switch S0->WiFi, S1->BT*/
- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
-
- /* ext switch setting */
- switch (ant_pos_type) {
- case BTC_ANT_PATH_WIFI:
- if (board_info->btdm_ant_pos ==
- BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3,
- 0x1);
- else
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3,
- 0x2);
- break;
- case BTC_ANT_PATH_BT:
- if (board_info->btdm_ant_pos ==
- BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3,
- 0x2);
- else
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3,
- 0x1);
- break;
- default:
- case BTC_ANT_PATH_PTA:
- if (board_info->btdm_ant_pos ==
- BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3,
- 0x1);
- else
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3,
- 0x2);
- break;
- }
-
- } else {
- if (init_hw_cfg) {
- /* 0x4c[23]=1, 0x4c[24]=0 Antenna control by 0x64*/
- u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u32tmp |= BIT23;
- u32tmp &= ~BIT24;
- btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp);
-
- if (board_info->btdm_ant_pos ==
- BTC_ANTENNA_AT_MAIN_PORT) {
- /*Main Ant to WiFi for IPS case 0x4c[23]=1*/
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x64, 0x1,
- 0x0);
-
- /*tell firmware "no antenna inverse"*/
- h2c_parameter[0] = 0;
- h2c_parameter[1] = 0; /*internal switch type*/
- btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
- h2c_parameter);
- } else {
- /*Aux Ant to BT for IPS case 0x4c[23]=1*/
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x64, 0x1,
- 0x1);
-
- /*tell firmware "antenna inverse"*/
- h2c_parameter[0] = 1;
- h2c_parameter[1] = 0; /*internal switch type*/
- btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
- h2c_parameter);
- }
- }
-
- /* fixed external switch first*/
- /*Main->WiFi, Aux->BT*/
- if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c,
- 0x3, 0x1);
- else/*Main->BT, Aux->WiFi */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c,
- 0x3, 0x2);
-
- /* internal switch setting*/
- switch (ant_pos_type) {
- case BTC_ANT_PATH_WIFI:
- if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- 0x0);
- else
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- 0x280);
- break;
- case BTC_ANT_PATH_BT:
- if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- 0x280);
- else
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- 0x0);
- break;
- default:
- case BTC_ANT_PATH_PTA:
- if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- 0x200);
- else
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- 0x80);
- break;
- }
- }
-}
-
-static void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist,
- bool force_exec, bool turn_on, u8 type)
-{
- bool wifi_busy = false;
- u8 rssi_adjust_val = 0;
-
- coex_dm->cur_ps_tdma_on = turn_on;
- coex_dm->cur_ps_tdma = type;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
- if (!force_exec) {
- if (coex_dm->cur_ps_tdma_on)
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], ******** TDMA(on, %d) *********\n",
- coex_dm->cur_ps_tdma);
- else
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], ******** TDMA(off, %d) ********\n",
- coex_dm->cur_ps_tdma);
-
-
- if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
- (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
- return;
- }
- if (turn_on) {
- switch (type) {
- default:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1a,
- 0x1a, 0x0, 0x50);
- break;
- case 1:
- if (wifi_busy)
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x3a, 0x03,
- 0x10, 0x50);
- else
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist,0x51,
- 0x3a, 0x03,
- 0x10, 0x51);
-
- rssi_adjust_val = 11;
- break;
- case 2:
- if (wifi_busy)
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x2b, 0x03,
- 0x10, 0x50);
- else
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x2b, 0x03,
- 0x10, 0x51);
- rssi_adjust_val = 14;
- break;
- case 3:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1d,
- 0x1d, 0x0, 0x52);
- break;
- case 4:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15,
- 0x3, 0x14, 0x0);
- rssi_adjust_val = 17;
- break;
- case 5:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15,
- 0x3, 0x11, 0x10);
- break;
- case 6:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x20,
- 0x3, 0x11, 0x13);
- break;
- case 7:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xc,
- 0x5, 0x0, 0x0);
- break;
- case 8:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25,
- 0x3, 0x10, 0x0);
- break;
- case 9:
- if(wifi_busy)
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x21, 0x3,
- 0x10, 0x50);
- else
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x21, 0x3,
- 0x10, 0x50);
- rssi_adjust_val = 18;
- break;
- case 10:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
- 0xa, 0x0, 0x40);
- break;
- case 11:
- if (wifi_busy)
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x15, 0x03,
- 0x10, 0x50);
- else
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51,
- 0x15, 0x03,
- 0x10, 0x50);
- rssi_adjust_val = 20;
- break;
- case 12:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x0a,
- 0x0a, 0x0, 0x50);
- break;
- case 13:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15,
- 0x15, 0x0, 0x50);
- break;
- case 14:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21,
- 0x3, 0x10, 0x52);
- break;
- case 15:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
- 0x3, 0x8, 0x0);
- break;
- case 16:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15,
- 0x3, 0x10, 0x0);
- rssi_adjust_val = 18;
- break;
- case 18:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25,
- 0x3, 0x10, 0x0);
- rssi_adjust_val = 14;
- break;
- case 20:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x35,
- 0x03, 0x11, 0x10);
- break;
- case 21:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15,
- 0x03, 0x11, 0x10);
- break;
- case 22:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25,
- 0x03, 0x11, 0x10);
- break;
- case 23:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
- 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 24:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15,
- 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 25:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
- 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 26:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
- 0x3, 0x31, 0x18);
- rssi_adjust_val = 22;
- break;
- case 27:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
- 0x3, 0x31, 0x98);
- rssi_adjust_val = 22;
- break;
- case 28:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x69, 0x25,
- 0x3, 0x31, 0x0);
- break;
- case 29:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xab, 0x1a,
- 0x1a, 0x1, 0x10);
- break;
- case 30:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x14,
- 0x3, 0x10, 0x50);
- break;
- case 31:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x1a,
- 0x1a, 0, 0x58);
- break;
- case 32:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0xa,
- 0x3, 0x10, 0x0);
- break;
- case 33:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x25,
- 0x3, 0x30, 0x90);
- break;
- case 34:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x53, 0x1a,
- 0x1a, 0x0, 0x10);
- break;
- case 35:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x63, 0x1a,
- 0x1a, 0x0, 0x10);
- break;
- case 36:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12,
- 0x3, 0x14, 0x50);
- break;
- /* SoftAP only with no sta associated,BT disable ,
- * TDMA mode for power saving
- * here softap mode screen off will cost 70-80mA for phone */
- case 40:
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x23, 0x18,
- 0x00, 0x10, 0x24);
- break;
- }
- } else {
- switch (type) {
- case 8: /*PTA Control */
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x8, 0x0,
- 0x0, 0x0, 0x0);
- halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_PTA,
- false, false);
- break;
- case 0:
- default: /*Software control, Antenna at BT side */
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0,
- 0x0, 0x0, 0x0);
- halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_BT,
- false, false);
- break;
- case 9: /*Software control, Antenna at WiFi side */
- halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0,
- 0x0, 0x0, 0x0);
- halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_WIFI,
- false, false);
- break;
- }
- }
- rssi_adjust_val = 0;
- btcoexist->btc_set(btcoexist,
- BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE,
- &rssi_adjust_val);
-
- /* update pre state */
- coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
- coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
-}
-
-static bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist)
-{
- bool commom = false, wifi_connected = false;
- bool wifi_busy = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
- if (!wifi_connected &&
- BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi non connected-idle + "
- "BT non connected-idle!!\n");
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- commom = true;
- } else if (wifi_connected &&
- (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
- coex_dm->bt_status)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi connected + "
- "BT non connected-idle!!\n");
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- commom = true;
- } else if (!wifi_connected &&
- (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE ==
- coex_dm->bt_status)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi non connected-idle + "
- "BT connected-idle!!\n");
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- commom = true;
- } else if (wifi_connected &&
- (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE ==
- coex_dm->bt_status)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi connected + BT connected-idle!!\n");
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- commom = true;
- } else if (!wifi_connected &&
- (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE !=
- coex_dm->bt_status)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- ("[BTCoex], Wifi non connected-idle + BT Busy!!\n"));
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- commom = true;
- } else {
- if (wifi_busy)
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi Connected-Busy"
- " + BT Busy!!\n");
- else
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi Connected-Idle"
- " + BT Busy!!\n");
-
- commom = false;
- }
-
- return commom;
-}
-
-
-static void halbtc8723b1ant_tdma_duration_adjust_for_acl(
- struct btc_coexist *btcoexist,
- u8 wifi_status)
-{
- static s32 up, dn, m, n, wait_count;
- /* 0: no change, +1: increase WiFi duration,
- * -1: decrease WiFi duration */
- s32 result;
- u8 retry_count = 0, bt_info_ext;
- static bool pre_wifi_busy = false;
- bool wifi_busy = false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], TdmaDurationAdjustForAcl()\n");
-
- if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifi_status)
- wifi_busy = true;
- else
- wifi_busy = false;
-
- if ((BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN ==
- wifi_status) ||
- (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifi_status) ||
- (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifi_status)) {
- if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 &&
- coex_dm->cur_ps_tdma != 3 && coex_dm->cur_ps_tdma != 9) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
-
- up = 0;
- dn = 0;
- m = 1;
- n = 3;
- result = 0;
- wait_count = 0;
- }
- return;
- }
-
- if (!coex_dm->auto_tdma_adjust) {
- coex_dm->auto_tdma_adjust = true;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], first run TdmaDurationAdjust()!!\n");
-
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
-
- up = 0;
- dn = 0;
- m = 1;
- n = 3;
- result = 0;
- wait_count = 0;
- } else {
- /*acquire the BT TRx retry count from BT_Info byte2 */
- retry_count = coex_sta->bt_retry_cnt;
- bt_info_ext = coex_sta->bt_info_ext;
- result = 0;
- wait_count++;
- /* no retry in the last 2-second duration */
- if (retry_count == 0) {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if (up >= n) {
- wait_count = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], Increase wifi "
- "duration!!\n");
- }
- } else if (retry_count <= 3) {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) {
- if (wait_count <= 2)
- m++;
- else
- m = 1;
-
- if (m >= 20)
- m = 20;
-
- n = 3 * m;
- up = 0;
- dn = 0;
- wait_count = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], Decrease wifi duration"
- " for retryCounter<3!!\n");
- }
- } else {
- if (wait_count == 1)
- m++;
- else
- m = 1;
-
- if (m >= 20)
- m = 20;
-
- n = 3 * m;
- up = 0;
- dn = 0;
- wait_count = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], Decrease wifi duration"
- " for retryCounter>3!!\n");
- }
-
- if (result == -1) {
- if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(bt_info_ext)) &&
- ((coex_dm->cur_ps_tdma == 1) ||
- (coex_dm->cur_ps_tdma == 2))) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- }
- } else if(result == 1) {
- if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(bt_info_ext)) &&
- ((coex_dm->cur_ps_tdma == 1) ||
- (coex_dm->cur_ps_tdma == 2))) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type = 1;
- }
- } else { /*no change */
- /*if busy / idle change */
- if (wifi_busy != pre_wifi_busy) {
- pre_wifi_busy = wifi_busy;
- halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC,
- true,
- coex_dm->cur_ps_tdma);
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex],********* TDMA(on, %d) ********\n",
- coex_dm->cur_ps_tdma);
- }
-
- if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 &&
- coex_dm->cur_ps_tdma != 9 && coex_dm->cur_ps_tdma != 11) {
- /* recover to previous adjust type */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
- coex_dm->ps_tdma_du_adj_type);
- }
- }
-}
-
-static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(
- struct btc_coexist *btcoexist, bool new_ps_state)
-{
- u8 lps_mode = 0x0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode);
-
- if (lps_mode) { /* already under LPS state */
- if (new_ps_state) {
- /* keep state under LPS, do nothing. */
- } else {
- /* will leave LPS state, turn off psTdma first */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- false, 0);
- }
- } else { /* NO PS state */
- if (new_ps_state) {
- /* will enter LPS state, turn off psTdma first */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- false, 0);
- } else {
- /* keep state under NO PS state, do nothing. */
- }
- }
-}
-
-static void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist,
- u8 ps_type, u8 lps_val,
- u8 rpwm_val)
-{
- bool low_pwr_disable = false;
-
- switch (ps_type) {
- case BTC_PS_WIFI_NATIVE:
- /* recover to original 32k low power setting */
- low_pwr_disable = false;
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
- break;
- case BTC_PS_LPS_ON:
- halbtc8723b1ant_PsTdmaCheckForPowerSaveState(btcoexist, true);
- halbtc8723b1ant_LpsRpwm(btcoexist, NORMAL_EXEC, lps_val,
- rpwm_val);
- /* when coex force to enter LPS, do not enter 32k low power. */
- low_pwr_disable = true;
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
- /* power save must executed before psTdma. */
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
- break;
- case BTC_PS_LPS_OFF:
- halbtc8723b1ant_PsTdmaCheckForPowerSaveState(btcoexist, false);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
- break;
- default:
- break;
- }
-}
-
-#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
-static void halbtc8723b1ant_action_wifi_only(struct btc_coexist *btcoexist)
-{
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9);
-}
-
-static void halbtc8723b1ant_monitor_bt_enable_disable(
- struct btc_coexist *btcoexist)
-{
- static bool pre_bt_disabled = false;
- static u32 bt_disable_cnt = 0;
- bool bt_active = true, bt_disabled = false;
-
- /* This function check if bt is disabled */
-
- if (coex_sta->high_priority_tx == 0 &&
- coex_sta->high_priority_rx == 0 &&
- coex_sta->low_priority_tx == 0 &&
- coex_sta->low_priority_rx == 0)
- bt_active = false;
-
- if (coex_sta->high_priority_tx == 0xffff &&
- coex_sta->high_priority_rx == 0xffff &&
- coex_sta->low_priority_tx == 0xffff &&
- coex_sta->low_priority_rx == 0xffff)
- bt_active = false;
-
- if (bt_active) {
- bt_disable_cnt = 0;
- bt_disabled = false;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
- &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is enabled !!\n");
- } else {
- bt_disable_cnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], bt all counters=0, %d times!!\n",
- bt_disable_cnt);
- if (bt_disable_cnt >= 2) {
- bt_disabled = true;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
- &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is disabled !!\n");
- halbtc8723b1ant_action_wifi_only(btcoexist);
- }
- }
- if (pre_bt_disabled != bt_disabled) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is from %s to %s!!\n",
- (pre_bt_disabled ? "disabled" : "enabled"),
- (bt_disabled ? "disabled" : "enabled"));
- pre_bt_disabled = bt_disabled;
- if (!bt_disabled) {
- } else {
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS,
- NULL);
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS,
- NULL);
- }
- }
-}
-#endif
-
-/***************************************************
- *
- * Software Coex Mechanism start
- *
- ***************************************************/
-/* SCO only or SCO+PAN(HS) */
-static void halbtc8723b1ant_action_sco(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state =
- halbtc8723b1ant_wifi_rssi_state(btcoexist, 0, 2, 25, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-
-static void halbtc8723b1ant_action_hid(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist,
- BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/*A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
-static void halbtc8723b1ant_action_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u32 wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b1ant_action_pan_edr(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-
-/* PAN(HS) only */
-static void halbtc8723b1ant_action_pan_hs(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* fw mechanism */
- if((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC,
- false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC,
- false);
-
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* fw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC,
- false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC,
- false);
-
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/*PAN(EDR)+A2DP */
-static void halbtc8723b1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u32 wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist,
- BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b1ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/* HID+A2DP+PAN(EDR) */
-static void halbtc8723b1ant_action_hid_a2dp_pan_edr(
- struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u32 wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b1ant_action_hid_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state, bt_info_ext;
- u32 wifi_bw;
-
- bt_info_ext = coex_sta->bt_info_ext;
- wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 0, 2, 25, 0);
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0);
-
- if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- else
- halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- /* sw mechanism */
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- } else {
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/*****************************************************
- *
- * Non-Software Coex Mechanism start
- *
- *****************************************************/
-static void halbtc8723b1ant_action_hs(struct btc_coexist *btcoexist)
-{
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
- halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2);
-}
-
-static void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool wifi_connected = false, ap_enable = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
- &ap_enable);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
-
- if (!wifi_connected) {
- halbtc8723b1ant_power_save_state(btcoexist,
- BTC_PS_WIFI_NATIVE, 0x0, 0x0);
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- } else if (bt_link_info->sco_exist || bt_link_info->hid_only) {
- /* SCO/HID-only busy */
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- } else {
- if (ap_enable)
- halbtc8723b1ant_power_save_state(btcoexist,
- BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
- else
- halbtc8723b1ant_power_save_state(btcoexist,
- BTC_PS_LPS_ON,
- 0x50, 0x4);
-
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 30);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- }
-}
-
-static void halbtc8723b1ant_action_bt_sco_hid_only_busy(
- struct btc_coexist *btcoexist,
- u8 wifi_status)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool wifi_connected = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
-
- /* tdma and coex table */
-
- if (bt_link_info->sco_exist) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
- } else { /* HID */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 6);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5);
- }
-}
-
-static void halbtc8723b1ant_action_wifi_connected_bt_acl_busy(
- struct btc_coexist *btcoexist,
- u8 wifi_status)
-{
- u8 bt_rssi_state;
-
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 28, 0);
-
- if (bt_link_info->hid_only) { /*HID */
- halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist,
- wifi_status);
- coex_dm->auto_tdma_adjust = false;
- return;
- } else if (bt_link_info->a2dp_only) { /*A2DP */
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_tdma_duration_adjust_for_acl(btcoexist,
- wifi_status);
- } else { /*for low BT RSSI */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 11);
- coex_dm->auto_tdma_adjust = false;
- }
-
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- } else if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) { /*HID+A2DP */
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 14);
- coex_dm->auto_tdma_adjust = false;
- } else { /*for low BT RSSI*/
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 14);
- coex_dm->auto_tdma_adjust = false;
- }
-
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
- /*PAN(OPP,FTP), HID+PAN(OPP,FTP) */
- } else if (bt_link_info->pan_only ||
- (bt_link_info->hid_exist && bt_link_info->pan_exist)) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
- coex_dm->auto_tdma_adjust = false;
- /*A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)*/
- } else if ((bt_link_info->a2dp_exist && bt_link_info->pan_exist) ||
- (bt_link_info->hid_exist && bt_link_info->a2dp_exist &&
- bt_link_info->pan_exist)) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- coex_dm->auto_tdma_adjust = false;
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- coex_dm->auto_tdma_adjust = false;
- }
-}
-
-static void halbtc8723b1ant_action_wifi_not_connected(
- struct btc_coexist *btcoexist)
-{
- /* power save state */
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
-
- /* tdma and coex table */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-}
-
-static void halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(
- struct btc_coexist *btcoexist)
-{
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
-
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
-}
-
-static void halbtc8723b1ant_ActionWifiConnectedScan(
- struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
-
- /* tdma and coex table */
- if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
- if (bt_link_info->a2dp_exist &&
- bt_link_info->pan_exist) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 22);
- halbtc8723b1ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 1);
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- }
- } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
- coex_dm->bt_status)) {
- halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN);
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- }
-}
-
-static void halbtc8723b1ant_action_wifi_connected_special_packet(
- struct btc_coexist *btcoexist)
-{
- bool hs_connecting = false;
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting);
-
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
-
- /* tdma and coex table */
- if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
- if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 22);
- halbtc8723b1ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 1);
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 20);
- halbtc8723b1ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 1);
- }
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
- halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
- }
-}
-
-static void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist)
-{
- bool wifi_busy = false;
- bool scan = false, link = false, roam = false;
- bool under_4way = false, ap_enable = false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], CoexForWifiConnect()===>\n");
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
- &under_4way);
- if (under_4way) {
- halbtc8723b1ant_action_wifi_connected_special_packet(btcoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], CoexForWifiConnect(), "
- "return for wifi is under 4way<===\n");
- return;
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
-
- if (scan || link || roam) {
- halbtc8723b1ant_ActionWifiConnectedScan(btcoexist);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], CoexForWifiConnect(), "
- "return for wifi is under scan<===\n");
- return;
- }
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
- &ap_enable);
- /* power save state */
- if (!ap_enable &&
- BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status &&
- !btcoexist->bt_link_info.hid_only)
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_LPS_ON,
- 0x50, 0x4);
- else
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
-
- /* tdma and coex table */
- btcoexist->btc_get(btcoexist,
- BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- if (!wifi_busy) {
- if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
- halbtc8723b1ant_action_wifi_connected_bt_acl_busy(btcoexist,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
- } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY ==
- coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
- coex_dm->bt_status)) {
- halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE);
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC,
- false, 8);
- halbtc8723b1ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 2);
- }
- } else {
- if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
- halbtc8723b1ant_action_wifi_connected_bt_acl_busy(btcoexist,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
- } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY ==
- coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY ==
- coex_dm->bt_status)) {
- halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY);
- } else {
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
- halbtc8723b1ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 2);
- }
- }
-}
-
-static void halbtc8723b1ant_run_sw_coexist_mechanism(
- struct btc_coexist *btcoexist)
-{
- u8 algorithm = 0;
-
- algorithm = halbtc8723b1ant_action_algorithm(btcoexist);
- coex_dm->cur_algorithm = algorithm;
-
- if (halbtc8723b1ant_is_common_action(btcoexist)) {
- } else {
- switch (coex_dm->cur_algorithm) {
- case BT_8723B_1ANT_COEX_ALGO_SCO:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = SCO.\n");
- halbtc8723b1ant_action_sco(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = HID.\n");
- halbtc8723b1ant_action_hid(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = A2DP.\n");
- halbtc8723b1ant_action_a2dp(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = "
- "A2DP+PAN(HS).\n");
- halbtc8723b1ant_action_a2dp_pan_hs(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = PAN(EDR).\n");
- halbtc8723b1ant_action_pan_edr(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = HS mode.\n");
- halbtc8723b1ant_action_pan_hs(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = PAN+A2DP.\n");
- halbtc8723b1ant_action_pan_edr_a2dp(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = "
- "PAN(EDR)+HID.\n");
- halbtc8723b1ant_action_pan_edr_hid(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = "
- "HID+A2DP+PAN.\n");
- halbtc8723b1ant_action_hid_a2dp_pan_edr(btcoexist);
- break;
- case BT_8723B_1ANT_COEX_ALGO_HID_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = HID+A2DP.\n");
- halbtc8723b1ant_action_hid_a2dp(btcoexist);
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action algorithm = "
- "coexist All Off!!\n");
- break;
- }
- coex_dm->pre_algorithm = coex_dm->cur_algorithm;
- }
-}
-
-static void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool wifi_connected = false, bt_hs_on = false;
- bool limited_dig = false, bIncreaseScanDevNum = false;
- bool b_bt_ctrl_agg_buf_size = false;
- u8 agg_buf_size = 5;
- u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], RunCoexistMechanism()===>\n");
-
- if (btcoexist->manual_control) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], RunCoexistMechanism(), "
- "return for Manual CTRL <===\n");
- return;
- }
-
- if (btcoexist->stop_coex_dm) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], RunCoexistMechanism(), "
- "return for Stop Coex DM <===\n");
- return;
- }
-
- if (coex_sta->under_ips) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], wifi is under IPS !!!\n");
- return;
- }
-
- if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) {
- limited_dig = true;
- bIncreaseScanDevNum = true;
- }
-
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
- btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM,
- &bIncreaseScanDevNum);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
-
- if (!bt_link_info->sco_exist && !bt_link_info->hid_exist) {
- halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
- } else {
- if (wifi_connected) {
- wifi_rssi_state =
- halbtc8723b1ant_wifi_rssi_state(btcoexist,
- 1, 2, 30, 0);
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b1ant_limited_tx(btcoexist,
- NORMAL_EXEC,
- 1, 1, 1, 1);
- } else {
- halbtc8723b1ant_limited_tx(btcoexist,
- NORMAL_EXEC,
- 1, 1, 1, 1);
- }
- } else {
- halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC,
- 0, 0, 0, 0);
- }
- }
-
- if (bt_link_info->sco_exist) {
- b_bt_ctrl_agg_buf_size = true;
- agg_buf_size = 0x3;
- } else if (bt_link_info->hid_exist) {
- b_bt_ctrl_agg_buf_size = true;
- agg_buf_size = 0x5;
- } else if (bt_link_info->a2dp_exist || bt_link_info->pan_exist) {
- b_bt_ctrl_agg_buf_size = true;
- agg_buf_size = 0x8;
- }
- halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
- b_bt_ctrl_agg_buf_size, agg_buf_size);
-
- halbtc8723b1ant_run_sw_coexist_mechanism(btcoexist);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
- if (coex_sta->c2h_bt_inquiry_page) {
- halbtc8723b1ant_action_bt_inquiry(btcoexist);
- return;
- } else if (bt_hs_on) {
- halbtc8723b1ant_action_hs(btcoexist);
- return;
- }
-
-
- if (!wifi_connected) {
- bool scan = false, link = false, roam = false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], wifi is non connected-idle !!!\n");
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
-
- if (scan || link || roam)
- halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(btcoexist);
- else
- halbtc8723b1ant_action_wifi_not_connected(btcoexist);
- } else { /* wifi LPS/Busy */
- halbtc8723b1ant_action_wifi_connected(btcoexist);
- }
-}
-
-static void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist)
-{
- /* force to reset coex mechanism */
- halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
- halbtc8723b1ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false);
-
- /* sw all off */
- halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8723b1ant_sw_mechanism2(btcoexist,false, false, false, 0x18);
-
- halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
- halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
-}
-
-static void halbtc8723b1ant_init_hw_config(struct btc_coexist *btcoexist,
- bool backup)
-{
- u32 u32tmp = 0;
- u8 u8tmp = 0;
- u32 cnt_bt_cal_chk = 0;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], 1Ant Init HW Config!!\n");
-
- if (backup) {/* backup rf 0x1e value */
- coex_dm->bt_rf0x1e_backup =
- btcoexist->btc_get_rf_reg(btcoexist,
- BTC_RF_A, 0x1e, 0xfffff);
-
- coex_dm->backup_arfr_cnt1 =
- btcoexist->btc_read_4byte(btcoexist, 0x430);
- coex_dm->backup_arfr_cnt2 =
- btcoexist->btc_read_4byte(btcoexist, 0x434);
- coex_dm->backup_retry_limit =
- btcoexist->btc_read_2byte(btcoexist, 0x42a);
- coex_dm->backup_ampdu_max_time =
- btcoexist->btc_read_1byte(btcoexist, 0x456);
- }
-
- /* WiFi goto standby while GNT_BT 0-->1 */
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x780);
- /* BT goto standby while GNT_BT 1-->0 */
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x2, 0xfffff, 0x500);
-
- btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x944, 0x3, 0x3);
- btcoexist->btc_write_1byte(btcoexist, 0x930, 0x77);
-
-
- /* BT calibration check */
- while (cnt_bt_cal_chk <= 20) {
- u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x49d);
- cnt_bt_cal_chk++;
- if (u32tmp & BIT0) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], ########### BT "
- "calibration(cnt=%d) ###########\n",
- cnt_bt_cal_chk);
- mdelay(50);
- } else {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], ********** BT NOT "
- "calibration (cnt=%d)**********\n",
- cnt_bt_cal_chk);
- break;
- }
- }
-
- /* 0x790[5:0]=0x5 */
- u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
- u8tmp &= 0xc0;
- u8tmp |= 0x5;
- btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp);
-
- /* Enable counter statistics */
- /*0x76e[3] =1, WLAN_Act control by PTA */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
- btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
-
- /*Antenna config */
- halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_PTA, true, false);
- /* PTA parameter */
- halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
-
-}
-
-static void halbtc8723b1ant_wifi_off_hw_cfg(struct btc_coexist *btcoexist)
-{
- /* set wlan_act to low */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0);
-}
-
-/**************************************************************
- * work around function start with wa_halbtc8723b1ant_
- **************************************************************/
-/**************************************************************
- * extern function start with EXhalbtc8723b1ant_
- **************************************************************/
-
-void ex_halbtc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist)
-{
- halbtc8723b1ant_init_hw_config(btcoexist, true);
-}
-
-void ex_halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], Coex Mechanism Init!!\n");
-
- btcoexist->stop_coex_dm = false;
-
- halbtc8723b1ant_init_coex_dm(btcoexist);
-
- halbtc8723b1ant_query_bt_info(btcoexist);
-}
-
-void ex_halbtc8723b1ant_display_coex_info(struct btc_coexist *btcoexist)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- u8 *cli_buf = btcoexist->cli_buf;
- u8 u8tmp[4], i, bt_info_ext, psTdmaCase=0;
- u16 u16tmp[4];
- u32 u32tmp[4];
- bool roam = false, scan = false;
- bool link = false, wifi_under_5g = false;
- bool bt_hs_on = false, wifi_busy = false;
- s32 wifi_rssi =0, bt_hs_rssi = 0;
- u32 wifi_bw, wifi_traffic_dir, fa_ofdm, fa_cck;
- u8 wifi_dot11_chnl, wifi_hs_chnl;
- u32 fw_ver = 0, bt_patch_ver = 0;
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cli_buf);
-
- if (btcoexist->manual_control) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ============[Under Manual Control]==========");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ==========================================");
- CL_PRINTF(cli_buf);
- }
- if (btcoexist->stop_coex_dm) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ============[Coex is STOPPED]============");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ==========================================");
- CL_PRINTF(cli_buf);
- }
-
- if (!board_info->bt_exist) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cli_buf);
- return;
- }
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d",
- "Ant PG Num/ Ant Mech/ Ant Pos:", \
- board_info->pg_ant_num, board_info->btdm_ant_num,
- board_info->btdm_ant_pos);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d",
- "BT stack/ hci ext ver", \
- ((stack_info->profile_notified)? "Yes":"No"),
- stack_info->hci_version);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)",
- "CoexVer/ FwVer/ PatchVer", \
- glcoex_ver_date_8723b_1ant, glcoex_ver_8723b_1ant,
- fw_ver, bt_patch_ver, bt_patch_ver);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL,
- &wifi_dot11_chnl);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)",
- "Dot11 channel / HsChnl(HsMode)", \
- wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
- "H2C Wifi inform bt chnl Info", \
- coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1],
- coex_dm->wifi_chnl_info[2]);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
- btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "Wifi rssi/ HS rssi", wifi_rssi, bt_hs_rssi);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
- "Wifi link/ roam/ scan", link, roam, scan);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist,BTC_GET_BL_WIFI_UNDER_5G,
- &wifi_under_5g);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
- &wifi_traffic_dir);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ",
- "Wifi status", (wifi_under_5g? "5G":"2.4G"),
- ((BTC_WIFI_BW_LEGACY==wifi_bw)? "Legacy":
- (((BTC_WIFI_BW_HT40==wifi_bw)? "HT40":"HT20"))),
- ((!wifi_busy)? "idle":
- ((BTC_WIFI_TRAFFIC_TX==wifi_traffic_dir)?
- "uplink":"downlink")));
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ",
- "BT [status/ rssi/ retryCnt]",
- ((btcoexist->bt_info.bt_disabled)? ("disabled"):
- ((coex_sta->c2h_bt_inquiry_page)?("inquiry/page scan"):
- ((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)?
- "non-connected idle":
- ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)?
- "connected-idle":"busy")))),
- coex_sta->bt_rssi, coex_sta->bt_retry_cnt);
- CL_PRINTF(cli_buf);
-
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d",
- "SCO/HID/PAN/A2DP", bt_link_info->sco_exist,
- bt_link_info->hid_exist, bt_link_info->pan_exist,
- bt_link_info->a2dp_exist);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO);
-
- bt_info_ext = coex_sta->bt_info_ext;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
- "BT Info A2DP rate",
- (bt_info_ext & BIT0) ? "Basic rate" : "EDR rate");
- CL_PRINTF(cli_buf);
-
- for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) {
- if (coex_sta->bt_info_c2h_cnt[i]) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %02x %02x %02x "
- "%02x %02x %02x %02x(%d)",
- GLBtInfoSrc8723b1Ant[i],
- coex_sta->bt_info_c2h[i][0],
- coex_sta->bt_info_c2h[i][1],
- coex_sta->bt_info_c2h[i][2],
- coex_sta->bt_info_c2h[i][3],
- coex_sta->bt_info_c2h[i][4],
- coex_sta->bt_info_c2h[i][5],
- coex_sta->bt_info_c2h[i][6],
- coex_sta->bt_info_c2h_cnt[i]);
- CL_PRINTF(cli_buf);
- }
- }
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %s/%s, (0x%x/0x%x)",
- "PS state, IPS/LPS, (lps/rpwm)", \
- ((coex_sta->under_ips? "IPS ON":"IPS OFF")),
- ((coex_sta->under_lps? "LPS ON":"LPS OFF")),
- btcoexist->bt_info.lps_1ant,
- btcoexist->bt_info.rpwm_1ant);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
-
- if (!btcoexist->manual_control) {
- /* Sw mechanism */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Sw mechanism]============");
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
- "SM1[ShRf/ LpRA/ LimDig]", \
- coex_dm->cur_rf_rx_lpf_shrink,
- coex_dm->cur_low_penalty_ra,
- btcoexist->bt_info.limited_dig);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %d/ %d/ %d(0x%x) ",
- "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \
- coex_dm->cur_agc_table_en,
- coex_dm->cur_adc_backoff,
- coex_dm->cur_dac_swing_on,
- coex_dm->cur_dac_swing_lvl);
- CL_PRINTF(cli_buf);
-
-
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ",
- "Rate Mask", btcoexist->bt_info.ra_mask);
- CL_PRINTF(cli_buf);
-
- /* Fw mechanism */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Fw mechanism]============");
- CL_PRINTF(cli_buf);
-
- psTdmaCase = coex_dm->cur_ps_tdma;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %02x %02x %02x %02x %02x "
- "case-%d (auto:%d)",
- "PS TDMA", coex_dm->ps_tdma_para[0],
- coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2],
- coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4],
- psTdmaCase, coex_dm->auto_tdma_adjust);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ",
- "Latest error condition(should be 0)", \
- coex_dm->error_condition);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
- "DecBtPwr/ IgnWlanAct", coex_dm->cur_dec_bt_pwr,
- coex_dm->cur_ignore_wlan_act);
- CL_PRINTF(cli_buf);
- }
-
- /* Hw setting */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Hw setting]============");
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x",
- "RF-A, 0x1e initVal", coex_dm->bt_rf0x1e_backup);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
- "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm->backup_arfr_cnt1,
- coex_dm->backup_arfr_cnt2, coex_dm->backup_retry_limit,
- coex_dm->backup_ampdu_max_time);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434);
- u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x",
- "0x430/0x434/0x42a/0x456",
- u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6cc);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x880);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0x778/0x6cc/0x880[29:25]", u8tmp[0], u32tmp[0],
- (u32tmp[1] & 0x3e000000) >> 25);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x948);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x67);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x765);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0x948/ 0x67[5] / 0x765",
- u32tmp[0], ((u8tmp[0] & 0x20)>> 5), u8tmp[1]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x92c);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x930);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x944);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]",
- u32tmp[0] & 0x3, u32tmp[1] & 0xff, u32tmp[2] & 0x3);
- CL_PRINTF(cli_buf);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x39);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40);
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0x64);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
- "0x38[11]/0x40/0x4c[24:23]/0x64[0]",
- ((u8tmp[0] & 0x8)>>3), u8tmp[1],
- ((u32tmp[0] & 0x01800000) >> 23), u8tmp[2] & 0x1);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0xc50(dig)/0x49c(null-drop)", u32tmp[0] & 0xff, u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8);
- u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
-
- fa_ofdm = ((u32tmp[0] & 0xffff0000) >> 16) +
- ((u32tmp[1] & 0xffff0000) >> 16) +
- (u32tmp[1] & 0xffff) +
- (u32tmp[2] & 0xffff) + \
- ((u32tmp[3] & 0xffff0000) >> 16) +
- (u32tmp[3] & 0xffff) ;
- fa_cck = (u8tmp[0] << 8) + u8tmp[1];
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "OFDM-CCA/OFDM-FA/CCK-FA",
- u32tmp[0] & 0xffff, fa_ofdm, fa_cck);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0x6c0/0x6c4/0x6c8(coexTable)",
- u32tmp[0], u32tmp[1], u32tmp[2]);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "0x770(high-pri rx/tx)", coex_sta->high_priority_rx,
- coex_sta->high_priority_tx);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "0x774(low-pri rx/tx)", coex_sta->low_priority_rx,
- coex_sta->low_priority_tx);
- CL_PRINTF(cli_buf);
-#if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 1)
- halbtc8723b1ant_monitor_bt_ctr(btcoexist);
-#endif
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-void ex_halbtc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
-{
-
- if (btcoexist->manual_control || btcoexist->stop_coex_dm)
- return;
-
- if (BTC_IPS_ENTER == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], IPS ENTER notify\n");
- coex_sta->under_ips = true;
-
- halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_BT,
- false, true);
- /* set PTA control */
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
- halbtc8723b1ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 0);
- } else if (BTC_IPS_LEAVE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], IPS LEAVE notify\n");
- coex_sta->under_ips = false;
-
- halbtc8723b1ant_run_coexist_mechanism(btcoexist);
- }
-}
-
-void ex_halbtc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (btcoexist->manual_control || btcoexist->stop_coex_dm)
- return;
-
- if (BTC_LPS_ENABLE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], LPS ENABLE notify\n");
- coex_sta->under_lps = true;
- } else if (BTC_LPS_DISABLE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], LPS DISABLE notify\n");
- coex_sta->under_lps = false;
- }
-}
-
-void ex_halbtc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
-{
- bool wifi_connected = false, bt_hs_on = false;
-
- if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
- btcoexist->bt_info.bt_disabled)
- return;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
-
- halbtc8723b1ant_query_bt_info(btcoexist);
-
- if (coex_sta->c2h_bt_inquiry_page) {
- halbtc8723b1ant_action_bt_inquiry(btcoexist);
- return;
- } else if (bt_hs_on) {
- halbtc8723b1ant_action_hs(btcoexist);
- return;
- }
-
- if (BTC_SCAN_START == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], SCAN START notify\n");
- if (!wifi_connected) /* non-connected scan */
- halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(btcoexist);
- else /* wifi is connected */
- halbtc8723b1ant_ActionWifiConnectedScan(btcoexist);
- } else if (BTC_SCAN_FINISH == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], SCAN FINISH notify\n");
- if (!wifi_connected) /* non-connected scan */
- halbtc8723b1ant_action_wifi_not_connected(btcoexist);
- else
- halbtc8723b1ant_action_wifi_connected(btcoexist);
- }
-}
-
-void ex_halbtc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
-{
- bool wifi_connected = false, bt_hs_on = false;
-
- if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
- btcoexist->bt_info.bt_disabled)
- return;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- if (coex_sta->c2h_bt_inquiry_page) {
- halbtc8723b1ant_action_bt_inquiry(btcoexist);
- return;
- } else if (bt_hs_on) {
- halbtc8723b1ant_action_hs(btcoexist);
- return;
- }
-
- if (BTC_ASSOCIATE_START == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], CONNECT START notify\n");
- halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(btcoexist);
- } else if (BTC_ASSOCIATE_FINISH == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], CONNECT FINISH notify\n");
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- if (!wifi_connected) /* non-connected scan */
- halbtc8723b1ant_action_wifi_not_connected(btcoexist);
- else
- halbtc8723b1ant_action_wifi_connected(btcoexist);
- }
-}
-
-void ex_halbtc8723b1ant_media_status_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- u8 h2c_parameter[3] ={0};
- u32 wifi_bw;
- u8 wifiCentralChnl;
-
- if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
- btcoexist->bt_info.bt_disabled )
- return;
-
- if (BTC_MEDIA_CONNECT == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], MEDIA connect notify\n");
- else
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], MEDIA disconnect notify\n");
-
- /* only 2.4G we need to inform bt the chnl mask */
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL,
- &wifiCentralChnl);
-
- if ((BTC_MEDIA_CONNECT == type) &&
- (wifiCentralChnl <= 14)) {
- h2c_parameter[0] = 0x0;
- h2c_parameter[1] = wifiCentralChnl;
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw)
- h2c_parameter[2] = 0x30;
- else
- h2c_parameter[2] = 0x20;
- }
-
- coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
- coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
- coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x66=0x%x\n",
- h2c_parameter[0] << 16 | h2c_parameter[1] << 8 |
- h2c_parameter[2]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
-}
-
-void ex_halbtc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- bool bt_hs_on = false;
-
- if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
- btcoexist->bt_info.bt_disabled)
- return;
-
- coex_sta->special_pkt_period_cnt = 0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- if (coex_sta->c2h_bt_inquiry_page) {
- halbtc8723b1ant_action_bt_inquiry(btcoexist);
- return;
- } else if (bt_hs_on) {
- halbtc8723b1ant_action_hs(btcoexist);
- return;
- }
-
- if (BTC_PACKET_DHCP == type ||
- BTC_PACKET_EAPOL == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], special Packet(%d) notify\n", type);
- halbtc8723b1ant_action_wifi_connected_special_packet(btcoexist);
- }
-}
-
-void ex_halbtc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmp_buf, u8 length)
-{
- u8 bt_info = 0;
- u8 i, rsp_source = 0;
- bool wifi_connected = false;
- bool bt_busy = false;
-
- coex_sta->c2h_bt_info_req_sent = false;
-
- rsp_source = tmp_buf[0] & 0xf;
- if (rsp_source >= BT_INFO_SRC_8723B_1ANT_MAX)
- rsp_source = BT_INFO_SRC_8723B_1ANT_WIFI_FW;
- coex_sta->bt_info_c2h_cnt[rsp_source]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], Bt info[%d], length=%d, hex data=[",
- rsp_source, length);
- for (i=0; i<length; i++) {
- coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
- if (i == 1)
- bt_info = tmp_buf[i];
- if (i == length - 1)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "0x%02x]\n", tmp_buf[i]);
- else
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "0x%02x, ", tmp_buf[i]);
- }
-
- if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rsp_source) {
- coex_sta->bt_retry_cnt = /* [3:0] */
- coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
-
- coex_sta->bt_rssi =
- coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;
-
- coex_sta->bt_info_ext =
- coex_sta->bt_info_c2h[rsp_source][4];
-
- /* Here we need to resend some wifi info to BT
- * because bt is reset and loss of the info.*/
- if(coex_sta->bt_info_ext & BIT1)
- {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT ext info bit1 check, "
- "send wifi BW&Chnl to BT!!\n");
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- if(wifi_connected)
- ex_halbtc8723b1ant_media_status_notify(btcoexist,
- BTC_MEDIA_CONNECT);
- else
- ex_halbtc8723b1ant_media_status_notify(btcoexist,
- BTC_MEDIA_DISCONNECT);
- }
-
- if (coex_sta->bt_info_ext & BIT3) {
- if (!btcoexist->manual_control &&
- !btcoexist->stop_coex_dm) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT ext info bit3 check, "
- "set BT NOT ignore Wlan active!!\n");
- halbtc8723b1ant_ignore_wlan_act(btcoexist,
- FORCE_EXEC,
- false);
- }
- } else {
- /* BT already NOT ignore Wlan active, do nothing here.*/
- }
-#if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
- if (coex_sta->bt_info_ext & BIT4) {
- /* BT auto report already enabled, do nothing */
- } else {
- halbtc8723b1ant_bt_auto_report(btcoexist, FORCE_EXEC,
- true);
- }
-#endif
- }
-
- /* check BIT2 first ==> check if bt is under inquiry or page scan */
- if (bt_info & BT_INFO_8723B_1ANT_B_INQ_PAGE)
- coex_sta->c2h_bt_inquiry_page = true;
- else
- coex_sta->c2h_bt_inquiry_page = false;
-
- /* set link exist status */
- if (!(bt_info & BT_INFO_8723B_1ANT_B_CONNECTION)) {
- coex_sta->bt_link_exist = false;
- coex_sta->pan_exist = false;
- coex_sta->a2dp_exist = false;
- coex_sta->hid_exist = false;
- coex_sta->sco_exist = false;
- } else { /* connection exists */
- coex_sta->bt_link_exist = true;
- if (bt_info & BT_INFO_8723B_1ANT_B_FTP)
- coex_sta->pan_exist = true;
- else
- coex_sta->pan_exist = false;
- if (bt_info & BT_INFO_8723B_1ANT_B_A2DP)
- coex_sta->a2dp_exist = true;
- else
- coex_sta->a2dp_exist = false;
- if (bt_info & BT_INFO_8723B_1ANT_B_HID)
- coex_sta->hid_exist = true;
- else
- coex_sta->hid_exist = false;
- if (bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO)
- coex_sta->sco_exist = true;
- else
- coex_sta->sco_exist = false;
- }
-
- halbtc8723b1ant_update_bt_link_info(btcoexist);
-
- if (!(bt_info&BT_INFO_8723B_1ANT_B_CONNECTION)) {
- coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), "
- "BT Non-Connected idle!!!\n");
- /* connection exists but no busy */
- } else if (bt_info == BT_INFO_8723B_1ANT_B_CONNECTION) {
- coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
- } else if ((bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) ||
- (bt_info & BT_INFO_8723B_1ANT_B_SCO_BUSY)) {
- coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_SCO_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), "
- "BT SCO busy!!!\n");
- } else if (bt_info & BT_INFO_8723B_1ANT_B_ACL_BUSY) {
- if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status)
- coex_dm->auto_tdma_adjust = false;
-
- coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_ACL_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
- } else {
- coex_dm->bt_status =
- BT_8723B_1ANT_BT_STATUS_MAX;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), BT Non-Defined state!!\n");
- }
-
- if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status))
- bt_busy = true;
- else
- bt_busy = false;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
-
- halbtc8723b1ant_run_coexist_mechanism(btcoexist);
-}
-
-void ex_halbtc8723b1ant_halt_notify(struct btc_coexist *btcoexist)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n");
-
- btcoexist->stop_coex_dm = true;
-
- halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_BT, false, true);
-
- halbtc8723b1ant_wifi_off_hw_cfg(btcoexist);
- halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
-
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
- halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0);
-
- ex_halbtc8723b1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
-}
-
-void ex_halbtc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Pnp notify\n");
-
- if (BTC_WIFI_PNP_SLEEP == pnp_state) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], Pnp notify to SLEEP\n");
- btcoexist->stop_coex_dm = true;
- halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
- halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
- 0x0, 0x0);
- halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9);
- } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], Pnp notify to WAKE UP\n");
- btcoexist->stop_coex_dm = false;
- halbtc8723b1ant_init_hw_config(btcoexist, false);
- halbtc8723b1ant_init_coex_dm(btcoexist);
- halbtc8723b1ant_query_bt_info(btcoexist);
- }
-}
-
-void ex_halbtc8723b1ant_periodical(struct btc_coexist *btcoexist)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
- static u8 dis_ver_info_cnt = 0;
- u32 fw_ver = 0, bt_patch_ver = 0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], =========================="
- "Periodical===========================\n");
-
- if (dis_ver_info_cnt <= 5) {
- dis_ver_info_cnt += 1;
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], *************************"
- "***************************************\n");
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], Ant PG Num/ Ant Mech/ "
- "Ant Pos = %d/ %d/ %d\n", \
- board_info->pg_ant_num, board_info->btdm_ant_num,
- board_info->btdm_ant_pos);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], BT stack/ hci ext ver = %s / %d\n", \
- ((stack_info->profile_notified)? "Yes":"No"),
- stack_info->hci_version);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER,
- &bt_patch_ver);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], CoexVer/ FwVer/ PatchVer "
- "= %d_%x/ 0x%x/ 0x%x(%d)\n", \
- glcoex_ver_date_8723b_1ant,
- glcoex_ver_8723b_1ant, fw_ver,
- bt_patch_ver, bt_patch_ver);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], *****************************"
- "***********************************\n");
- }
-
-#if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0)
- halbtc8723b1ant_query_bt_info(btcoexist);
- halbtc8723b1ant_monitor_bt_ctr(btcoexist);
- halbtc8723b1ant_monitor_bt_enable_disable(btcoexist);
-#else
- if (halbtc8723b1ant_is_wifi_status_changed(btcoexist) ||
- coex_dm->auto_tdma_adjust) {
- if (coex_sta->special_pkt_period_cnt > 2)
- halbtc8723b1ant_run_coexist_mechanism(btcoexist);
- }
-
- coex_sta->special_pkt_period_cnt++;
-#endif
-}
-
-
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.h b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.h
deleted file mode 100644
index 5ce292f2e7c6..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/**********************************************************************
- * The following is for 8723B 1ANT BT Co-exist definition
- **********************************************************************/
-#define BT_AUTO_REPORT_ONLY_8723B_1ANT 1
-
-#define BT_INFO_8723B_1ANT_B_FTP BIT7
-#define BT_INFO_8723B_1ANT_B_A2DP BIT6
-#define BT_INFO_8723B_1ANT_B_HID BIT5
-#define BT_INFO_8723B_1ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8723B_1ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8723B_1ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8723B_1ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8723B_1ANT_B_CONNECTION BIT0
-
-#define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \
- (((_BT_INFO_EXT_&BIT0))? true:false)
-
-#define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2
-
-typedef enum _BT_INFO_SRC_8723B_1ANT{
- BT_INFO_SRC_8723B_1ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8723B_1ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8723B_1ANT_MAX
-}BT_INFO_SRC_8723B_1ANT,*PBT_INFO_SRC_8723B_1ANT;
-
-typedef enum _BT_8723B_1ANT_BT_STATUS{
- BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8723B_1ANT_BT_STATUS_INQ_PAGE = 0x2,
- BT_8723B_1ANT_BT_STATUS_ACL_BUSY = 0x3,
- BT_8723B_1ANT_BT_STATUS_SCO_BUSY = 0x4,
- BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
- BT_8723B_1ANT_BT_STATUS_MAX
-}BT_8723B_1ANT_BT_STATUS,*PBT_8723B_1ANT_BT_STATUS;
-
-typedef enum _BT_8723B_1ANT_WIFI_STATUS{
- BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4,
- BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5,
- BT_8723B_1ANT_WIFI_STATUS_MAX
-}BT_8723B_1ANT_WIFI_STATUS,*PBT_8723B_1ANT_WIFI_STATUS;
-
-typedef enum _BT_8723B_1ANT_COEX_ALGO{
- BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8723B_1ANT_COEX_ALGO_SCO = 0x1,
- BT_8723B_1ANT_COEX_ALGO_HID = 0x2,
- BT_8723B_1ANT_COEX_ALGO_A2DP = 0x3,
- BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4,
- BT_8723B_1ANT_COEX_ALGO_PANEDR = 0x5,
- BT_8723B_1ANT_COEX_ALGO_PANHS = 0x6,
- BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
- BT_8723B_1ANT_COEX_ALGO_PANEDR_HID = 0x8,
- BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
- BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa,
- BT_8723B_1ANT_COEX_ALGO_MAX = 0xb,
-}BT_8723B_1ANT_COEX_ALGO,*PBT_8723B_1ANT_COEX_ALGO;
-
-struct coex_dm_8723b_1ant{
- /* fw mechanism */
- bool pre_dec_bt_pwr;
- bool cur_dec_bt_pwr;
- u8 pre_fw_dac_swing_lvl;
- u8 cur_fw_dac_swing_lvl;
- bool cur_ignore_wlan_act;
- bool pre_ignore_wlan_act;
- u8 pre_ps_tdma;
- u8 cur_ps_tdma;
- u8 ps_tdma_para[5];
- u8 ps_tdma_du_adj_type;
- bool auto_tdma_adjust;
- bool pre_ps_tdma_on;
- bool cur_ps_tdma_on;
- bool pre_bt_auto_report;
- bool cur_bt_auto_report;
- u8 pre_lps;
- u8 cur_lps;
- u8 pre_rpwm;
- u8 cur_rpwm;
-
- /* sw mechanism */
- bool pre_rf_rx_lpf_shrink;
- bool cur_rf_rx_lpf_shrink;
- u32 bt_rf0x1e_backup;
- bool pre_low_penalty_ra;
- bool cur_low_penalty_ra;
- bool pre_dac_swing_on;
- u32 pre_dac_swing_lvl;
- bool cur_dac_swing_on;
- u32 cur_dac_swing_lvl;
- bool pre_adc_backoff;
- bool cur_adc_backoff;
- bool pre_agc_table_en;
- bool cur_agc_table_en;
- u32 pre_val0x6c0;
- u32 cur_val0x6c0;
- u32 pre_val0x6c4;
- u32 cur_val0x6c4;
- u32 pre_val0x6c8;
- u32 cur_val0x6c8;
- u8 pre_val0x6cc;
- u8 cur_val0x6cc;
- bool limited_dig;
-
- u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */
- u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */
- u16 backup_retry_limit;
- u8 backup_ampdu_max_time;
-
- /* algorithm related */
- u8 pre_algorithm;
- u8 cur_algorithm;
- u8 bt_status;
- u8 wifi_chnl_info[3];
-
- u32 prera_mask;
- u32 curra_mask;
- u8 pre_arfr_type;
- u8 cur_arfr_type;
- u8 pre_retry_limit_type;
- u8 cur_retry_limit_type;
- u8 pre_ampdu_time_type;
- u8 cur_ampdu_time_type;
-
- u8 error_condition;
-};
-
-struct coex_sta_8723b_1ant{
- bool bt_link_exist;
- bool sco_exist;
- bool a2dp_exist;
- bool hid_exist;
- bool pan_exist;
-
- bool under_lps;
- bool under_ips;
- u32 special_pkt_period_cnt;
- u32 high_priority_tx;
- u32 high_priority_rx;
- u32 low_priority_tx;
- u32 low_priority_rx;
- u8 bt_rssi;
- u8 pre_bt_rssi_state;
- u8 pre_wifi_rssi_state[4];
- bool c2h_bt_info_req_sent;
- u8 bt_info_c2h[BT_INFO_SRC_8723B_1ANT_MAX][10];
- u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_1ANT_MAX];
- bool c2h_bt_inquiry_page;
- u8 bt_retry_cnt;
- u8 bt_info_ext;
-};
-
-/*************************************************************************
- * The following is interface which will notify coex module.
- *************************************************************************/
-void ex_halbtc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist);
-void ex_halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist);
-void ex_halbtc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b1ant_media_status_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmpbuf, u8 length);
-void ex_halbtc8723b1ant_halt_notify(struct btc_coexist *btcoexist);
-void ex_halbtc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnpState);
-void ex_halbtc8723b1ant_periodical(struct btc_coexist *btcoexist);
-void ex_halbtc8723b1ant_display_coex_info(struct btc_coexist *btcoexist);
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c
deleted file mode 100644
index da3f62da4e40..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c
+++ /dev/null
@@ -1,4200 +0,0 @@
-/***************************************************************
- * Description:
- *
- * This file is for RTL8723B Co-exist mechanism
- *
- * History
- * 2012/11/15 Cosa first check in.
- *
- **************************************************************/
-/**************************************************************
- * include files
- **************************************************************/
-#include "halbt_precomp.h"
-#if 1
-/**************************************************************
- * Global variables, these are static variables
- **************************************************************/
-static struct coex_dm_8723b_2ant glcoex_dm_8723b_2ant;
-static struct coex_dm_8723b_2ant *coex_dm = &glcoex_dm_8723b_2ant;
-static struct coex_sta_8723b_2ant glcoex_sta_8723b_2ant;
-static struct coex_sta_8723b_2ant *coex_sta = &glcoex_sta_8723b_2ant;
-
-static const char *const glbt_info_src_8723b_2ant[] = {
- "BT Info[wifi fw]",
- "BT Info[bt rsp]",
- "BT Info[bt auto report]",
-};
-
-static u32 glcoex_ver_date_8723b_2ant = 20131113;
-static u32 glcoex_ver_8723b_2ant = 0x3f;
-
-/**************************************************************
- * local function proto type if needed
- **************************************************************/
-/**************************************************************
- * local function start with halbtc8723b2ant_
- **************************************************************/
-static u8 halbtc8723b2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh,
- u8 rssi_thresh1)
-{
- s32 bt_rssi = 0;
- u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
-
- bt_rssi = coex_sta->bt_rssi;
-
- if (level_num == 2) {
- if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- if (bt_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) {
- bt_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to High\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at Low\n");
- }
- } else {
- if (bt_rssi < rssi_thresh) {
- bt_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Low\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at High\n");
- }
- }
- } else if (level_num == 3) {
- if (rssi_thresh > rssi_thresh1) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi thresh error!!\n");
- return coex_sta->pre_bt_rssi_state;
- }
-
- if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
- if (bt_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) {
- bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Medium\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at Low\n");
- }
- } else if ((coex_sta->pre_bt_rssi_state ==
- BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_bt_rssi_state ==
- BTC_RSSI_STATE_STAY_MEDIUM)) {
- if (bt_rssi >= rssi_thresh1 +
- BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) {
- bt_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to High\n");
- } else if (bt_rssi < rssi_thresh) {
- bt_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Low\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at Medium\n");
- }
- } else {
- if (bt_rssi < rssi_thresh1) {
- bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "switch to Medium\n");
- } else {
- bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE,
- "[BTCoex], BT Rssi state "
- "stay at High\n");
- }
- }
- }
-
- coex_sta->pre_bt_rssi_state = bt_rssi_state;
-
- return bt_rssi_state;
-}
-
-static u8 halbtc8723b2ant_wifi_rssi_state(struct btc_coexist *btcoexist,
- u8 index, u8 level_num,
- u8 rssi_thresh, u8 rssi_thresh1)
-{
- s32 wifi_rssi=0;
- u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
-
- if (level_num == 2) {
- if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_LOW)) {
- if (wifi_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) {
- wifi_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to High\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at Low\n");
- }
- } else {
- if (wifi_rssi < rssi_thresh) {
- wifi_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Low\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at High\n");
- }
- }
- } else if (level_num == 3) {
- if (rssi_thresh > rssi_thresh1) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI thresh error!!\n");
- return coex_sta->pre_wifi_rssi_state[index];
- }
-
- if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_LOW) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_LOW)) {
- if(wifi_rssi >= rssi_thresh +
- BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) {
- wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Medium\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at Low\n");
- }
- } else if ((coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_MEDIUM) ||
- (coex_sta->pre_wifi_rssi_state[index] ==
- BTC_RSSI_STATE_STAY_MEDIUM)) {
- if (wifi_rssi >= rssi_thresh1 +
- BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) {
- wifi_rssi_state = BTC_RSSI_STATE_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to High\n");
- } else if (wifi_rssi < rssi_thresh) {
- wifi_rssi_state = BTC_RSSI_STATE_LOW;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Low\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at Medium\n");
- }
- } else {
- if (wifi_rssi < rssi_thresh1) {
- wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "switch to Medium\n");
- } else {
- wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_WIFI_RSSI_STATE,
- "[BTCoex], wifi RSSI state "
- "stay at High\n");
- }
- }
- }
-
- coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
-
- return wifi_rssi_state;
-}
-
-#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0)
-static void halbtc8723b2ant_monitor_bt_enable_disable(
- struct btc_coexist *btcoexist)
-{
- static bool pre_bt_disabled = false;
- static u32 bt_disable_cnt = 0;
- bool bt_active = true, bt_disabled = false;
-
- /* This function check if bt is disabled */
- if (coex_sta->high_priority_tx == 0 &&
- coex_sta->high_priority_rx == 0 &&
- coex_sta->low_priority_tx == 0 &&
- coex_sta->low_priority_rx == 0)
- bt_active = false;
-
- if (coex_sta->high_priority_tx == 0xffff &&
- coex_sta->high_priority_rx == 0xffff &&
- coex_sta->low_priority_tx == 0xffff &&
- coex_sta->low_priority_rx == 0xffff)
- bt_active = true;
-
- if (bt_active) {
- bt_disable_cnt = 0;
- bt_disabled = false;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
- &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is enabled !!\n");
- } else {
- bt_disable_cnt++;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], bt all counters=0, %d times!!\n",
- bt_disable_cnt);
- if (bt_disable_cnt >= 2) {
- bt_disabled = true;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE,
- &bt_disabled);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is disabled !!\n");
- }
- }
-
- if (pre_bt_disabled != bt_disabled) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], BT is from %s to %s!!\n",
- (pre_bt_disabled ? "disabled":"enabled"),
- (bt_disabled ? "disabled":"enabled"));
-
- pre_bt_disabled = bt_disabled;
- if (!bt_disabled) {
- } else {
- }
- }
-}
-#endif
-
-static void halbtc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
-{
- u32 reg_hp_txrx, reg_lp_txrx, u32tmp;
- u32 reg_hp_tx = 0, reg_hp_rx = 0;
- u32 reg_lp_tx = 0, reg_lp_rx = 0;
-
- reg_hp_txrx = 0x770;
- reg_lp_txrx = 0x774;
-
- u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx);
- reg_hp_tx = u32tmp & MASKLWORD;
- reg_hp_rx = (u32tmp & MASKHWORD) >> 16;
-
- u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx);
- reg_lp_tx = u32tmp & MASKLWORD;
- reg_lp_rx = (u32tmp & MASKHWORD) >> 16;
-
- coex_sta->high_priority_tx = reg_hp_tx;
- coex_sta->high_priority_rx = reg_hp_rx;
- coex_sta->low_priority_tx = reg_lp_tx;
- coex_sta->low_priority_rx = reg_lp_rx;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], High Priority Tx/Rx(reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR,
- "[BTCoex], Low Priority Tx/Rx(reg 0x%x)=0x%x(%d)/0x%x(%d)\n",
- reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx);
-
- /* reset counter */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
-}
-
-static void halbtc8723b2ant_query_bt_info(struct btc_coexist *btcoexist)
-{
- u8 h2c_parameter[1] ={0};
-
- coex_sta->c2h_bt_info_req_sent = true;
-
- h2c_parameter[0] |= BIT0; /* trigger */
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], Query Bt Info, FW write 0x61=0x%x\n",
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
-}
-
-static bool halbtc8723b2ant_is_wifi_status_changed(
- struct btc_coexist *btcoexist)
-{
- static bool pre_wifi_busy = false;
- static bool pre_under_4way = false;
- static bool pre_bt_hs_on = false;
- bool wifi_busy = false, under_4way = false, bt_hs_on = false;
- bool wifi_connected = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
- &under_4way);
-
- if (wifi_connected) {
- if (wifi_busy != pre_wifi_busy) {
- pre_wifi_busy = wifi_busy;
- return true;
- }
-
- if (under_4way != pre_under_4way) {
- pre_under_4way = under_4way;
- return true;
- }
-
- if (bt_hs_on != pre_bt_hs_on) {
- pre_bt_hs_on = bt_hs_on;
- return true;
- }
- }
-
- return false;
-}
-
-static void halbtc8723b2ant_update_bt_link_info(struct btc_coexist *btcoexist)
-{
- /*struct btc_stack_info *stack_info = &btcoexist->stack_info;*/
- struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
- bool bt_hs_on = false;
-
-#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 1) /* profile from bt patch */
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
- bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
- bt_link_info->sco_exist = coex_sta->sco_exist;
- bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
- bt_link_info->pan_exist = coex_sta->pan_exist;
- bt_link_info->hid_exist = coex_sta->hid_exist;
-
- /* work around for HS mode. */
- if (bt_hs_on) {
- bt_link_info->pan_exist = true;
- bt_link_info->bt_link_exist = true;
- }
-#else /* profile from bt stack */
- bt_link_info->bt_link_exist = stack_info->bt_link_exist;
- bt_link_info->sco_exist = stack_info->sco_exist;
- bt_link_info->a2dp_exist = stack_info->a2dp_exist;
- bt_link_info->pan_exist = stack_info->pan_exist;
- bt_link_info->hid_exist = stack_info->hid_exist;
-
- /*for win-8 stack HID report error*/
- if (!stack_info->hid_exist)
- stack_info->hid_exist = coex_sta->hid_exist;
- /*sync BTInfo with BT firmware and stack*/
- /* when stack HID report error, here we use the info from bt fw.*/
- if (!stack_info->bt_link_exist)
- stack_info->bt_link_exist = coex_sta->bt_link_exist;
-#endif
- /* check if Sco only */
- if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist && !bt_link_info->hid_exist)
- bt_link_info->sco_only = true;
- else
- bt_link_info->sco_only = false;
-
- /* check if A2dp only */
- if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist && !bt_link_info->hid_exist)
- bt_link_info->a2dp_only = true;
- else
- bt_link_info->a2dp_only = false;
-
- /* check if Pan only */
- if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
- bt_link_info->pan_exist && !bt_link_info->hid_exist)
- bt_link_info->pan_only = true;
- else
- bt_link_info->pan_only = false;
-
- /* check if Hid only */
- if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist &&
- !bt_link_info->pan_exist && bt_link_info->hid_exist)
- bt_link_info->hid_only = true;
- else
- bt_link_info->hid_only = false;
-}
-
-static u8 halbtc8723b2ant_action_algorithm(struct btc_coexist *btcoexist)
-{
- struct btc_bt_link_info *bt_link_info=&btcoexist->bt_link_info;
- bool bt_hs_on = false;
- u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED;
- u8 num_of_diff_profile = 0;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
-
- if (!bt_link_info->bt_link_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], No BT link exists!!!\n");
- return algorithm;
- }
-
- if (bt_link_info->sco_exist)
- num_of_diff_profile++;
- if (bt_link_info->hid_exist)
- num_of_diff_profile++;
- if (bt_link_info->pan_exist)
- num_of_diff_profile++;
- if (bt_link_info->a2dp_exist)
- num_of_diff_profile++;
-
- if (num_of_diff_profile == 1) {
- if (bt_link_info->sco_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO only\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
- } else {
- if (bt_link_info->hid_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], HID only\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
- } else if (bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], A2DP only\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP;
- } else if (bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], PAN(HS) only\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANHS;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], PAN(EDR) only\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR;
- }
- }
- }
- } else if (num_of_diff_profile == 2) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + HID\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- } else if (bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + A2DP ==> SCO\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- } else if (bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + PAN(HS)\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_SCO;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + PAN(EDR)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- } else {
- if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], HID + A2DP\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
- } else if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], HID + PAN(HS)\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_HID;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], HID + PAN(EDR)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- }
- } else if (bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], A2DP + PAN(HS)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex],A2DP + PAN(EDR)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP;
- }
- }
- }
- } else if (num_of_diff_profile == 3) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist &&
- bt_link_info->a2dp_exist) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + HID + A2DP"
- " ==> HID\n");
- algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- } else if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + HID + "
- "PAN(HS)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + HID + "
- "PAN(EDR)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- }
- } else if (bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + A2DP + "
- "PAN(HS)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + A2DP + "
- "PAN(EDR) ==> HID\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- } else {
- if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], HID + A2DP + "
- "PAN(HS)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_HID_A2DP;
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], HID + A2DP + "
- "PAN(EDR)\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR;
- }
- }
- }
- } else if (num_of_diff_profile >= 3) {
- if (bt_link_info->sco_exist) {
- if (bt_link_info->hid_exist &&
- bt_link_info->pan_exist &&
- bt_link_info->a2dp_exist) {
- if (bt_hs_on) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Error!!! SCO + HID"
- " + A2DP + PAN(HS)\n");
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], SCO + HID + A2DP +"
- " PAN(EDR)==>PAN(EDR)+HID\n");
- algorithm =
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID;
- }
- }
- }
- }
-
- return algorithm;
-}
-
-static bool halbtc8723b2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist)
-{
- bool bRet = false;
- bool bt_hs_on = false, wifi_connected = false;
- s32 bt_hs_rssi=0;
- u8 bt_rssi_state;
-
- if (!btcoexist->btc_get(btcoexist,
- BTC_GET_BL_HS_OPERATION, &bt_hs_on))
- return false;
- if (!btcoexist->btc_get(btcoexist,
- BTC_GET_BL_WIFI_CONNECTED, &wifi_connected))
- return false;
- if (!btcoexist->btc_get(btcoexist,
- BTC_GET_S4_HS_RSSI, &bt_hs_rssi))
- return false;
-
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- if (wifi_connected) {
- if (bt_hs_on) {
- if (bt_hs_rssi > 37) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], Need to decrease bt "
- "power for HS mode!!\n");
- bRet = true;
- }
- } else {
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], Need to decrease bt "
- "power for Wifi is connected!!\n");
- bRet = true;
- }
- }
- }
-
- return bRet;
-}
-
-static void halbtc8723b2ant_set_fw_dac_swing_level(
- struct btc_coexist *btcoexist,
- u8 dac_swing_lvl)
-{
- u8 h2c_parameter[1] ={0};
-
- /* There are several type of dacswing
- * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */
- h2c_parameter[0] = dac_swing_lvl;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], Set Dac Swing Level=0x%x\n", dac_swing_lvl);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x64=0x%x\n", h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter);
-}
-
-static void halbtc8723b2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist,
- bool dec_bt_pwr)
-{
- u8 h2c_parameter[1] = {0};
-
- h2c_parameter[0] = 0;
-
- if (dec_bt_pwr)
- h2c_parameter[0] |= BIT1;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], decrease Bt Power : %s, FW write 0x62=0x%x\n",
- (dec_bt_pwr? "Yes!!":"No!!"), h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter);
-}
-
-static void halbtc8723b2ant_dec_bt_pwr(struct btc_coexist *btcoexist,
- bool force_exec, bool dec_bt_pwr)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s Dec BT power = %s\n",
- (force_exec? "force to":""), (dec_bt_pwr? "ON":"OFF"));
- coex_dm->cur_dec_bt_pwr = dec_bt_pwr;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreDecBtPwr=%d, bCurDecBtPwr=%d\n",
- coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr);
-
- if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr)
- return;
- }
- halbtc8723b2ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr);
-
- coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr;
-}
-
-#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0)
-static void halbtc8723b2ant_set_bt_auto_report(struct btc_coexist *btcoexist,
- bool enable_auto_report)
-{
- u8 h2c_parameter[1] = {0};
- h2c_parameter[0] = 0;
-
- if (enable_auto_report)
- h2c_parameter[0] |= BIT0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n",
- (enable_auto_report? "Enabled!!":"Disabled!!"),
- h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter);
-}
-
-static void halbtc8723b2ant_bt_auto_report(struct btc_coexist *btcoexist,
- bool force_exec, bool enable_auto_report)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s BT Auto report = %s\n",
- (force_exec? "force to":""),
- ((enable_auto_report)? "Enabled":"Disabled"));
- coex_dm->cur_bt_auto_report = enable_auto_report;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreBtAutoReport=%d, "
- "bCurBtAutoReport=%d\n",
- coex_dm->pre_bt_auto_report,
- coex_dm->cur_bt_auto_report);
-
- if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report)
- return;
- }
- halbtc8723b2ant_set_bt_auto_report(btcoexist,
- coex_dm->cur_bt_auto_report);
-
- coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report;
-}
-#endif
-
-static void halbtc8723b2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist,
- bool force_exec, u8 fw_dac_swing_lvl)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s set FW Dac Swing level = %d\n",
- (force_exec? "force to":""), fw_dac_swing_lvl);
- coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], preFwDacSwingLvl=%d, "
- "curFwDacSwingLvl=%d\n",
- coex_dm->pre_fw_dac_swing_lvl,
- coex_dm->cur_fw_dac_swing_lvl);
-
- if(coex_dm->pre_fw_dac_swing_lvl ==
- coex_dm->cur_fw_dac_swing_lvl)
- return;
- }
-
- halbtc8723b2ant_set_fw_dac_swing_level(btcoexist,
- coex_dm->cur_fw_dac_swing_lvl);
- coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl;
-}
-
-static void halbtc8723b2ant_set_sw_rf_rx_lpf_corner(
- struct btc_coexist *btcoexist,
- bool rx_rf_shrink_on)
-{
- if (rx_rf_shrink_on) {
- /* Shrink RF Rx LPF corner */
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Shrink RF Rx LPF corner!!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
- 0xfffff, 0xffffc);
- } else {
- /* Resume RF Rx LPF corner */
- /* After initialized, we can use coex_dm->btRf0x1eBackup */
- if (btcoexist->initilized) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Resume RF Rx LPF corner!!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e,
- 0xfffff,
- coex_dm->bt_rf0x1e_backup);
- }
- }
-}
-
-static void halbtc8723b2ant_rf_shrink(struct btc_coexist *btcoexist,
- bool force_exec, bool rx_rf_shrink_on)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s turn Rx RF Shrink = %s\n",
- (force_exec? "force to":""), (rx_rf_shrink_on? "ON":"OFF"));
- coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreRfRxLpfShrink=%d, "
- "bCurRfRxLpfShrink=%d\n",
- coex_dm->pre_rf_rx_lpf_shrink,
- coex_dm->cur_rf_rx_lpf_shrink);
-
- if (coex_dm->pre_rf_rx_lpf_shrink ==
- coex_dm->cur_rf_rx_lpf_shrink)
- return;
- }
- halbtc8723b2ant_set_sw_rf_rx_lpf_corner(btcoexist,
- coex_dm->cur_rf_rx_lpf_shrink);
-
- coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink;
-}
-
-static void halbtc8723b2ant_set_sw_penalty_txrate_adaptive(
- struct btc_coexist *btcoexist,
- bool low_penalty_ra)
-{
- u8 h2c_parameter[6] ={0};
-
- h2c_parameter[0] = 0x6; /* opCode, 0x6= Retry_Penalty*/
-
- if (low_penalty_ra) {
- h2c_parameter[1] |= BIT0;
- /*normal rate except MCS7/6/5, OFDM54/48/36*/
- h2c_parameter[2] = 0x00;
- h2c_parameter[3] = 0xf7; /*MCS7 or OFDM54*/
- h2c_parameter[4] = 0xf8; /*MCS6 or OFDM48*/
- h2c_parameter[5] = 0xf9; /*MCS5 or OFDM36*/
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], set WiFi Low-Penalty Retry: %s",
- (low_penalty_ra? "ON!!":"OFF!!"));
-
- btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
-}
-
-static void halbtc8723b2ant_low_penalty_ra(struct btc_coexist *btcoexist,
- bool force_exec, bool low_penalty_ra)
-{
- /*return; */
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s turn LowPenaltyRA = %s\n",
- (force_exec? "force to":""), (low_penalty_ra? "ON":"OFF"));
- coex_dm->cur_low_penalty_ra = low_penalty_ra;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreLowPenaltyRa=%d, "
- "bCurLowPenaltyRa=%d\n",
- coex_dm->pre_low_penalty_ra,
- coex_dm->cur_low_penalty_ra);
-
- if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
- return;
- }
- halbtc8723b2ant_set_sw_penalty_txrate_adaptive(btcoexist,
- coex_dm->cur_low_penalty_ra);
-
- coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
-}
-
-static void halbtc8723b2ant_set_dac_swing_reg(struct btc_coexist *btcoexist,
- u32 level)
-{
- u8 val = (u8) level;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Write SwDacSwing = 0x%x\n", level);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val);
-}
-
-static void halbtc8723b2ant_set_sw_fulltime_dac_swing(
- struct btc_coexist *btcoexist,
- bool sw_dac_swing_on,
- u32 sw_dac_swing_lvl)
-{
- if(sw_dac_swing_on)
- halbtc8723b2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl);
- else
- halbtc8723b2ant_set_dac_swing_reg(btcoexist, 0x18);
-}
-
-
-static void halbtc8723b2ant_dac_swing(struct btc_coexist *btcoexist,
- bool force_exec, bool dac_swing_on,
- u32 dac_swing_lvl)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s turn DacSwing=%s, dac_swing_lvl=0x%x\n",
- (force_exec? "force to":""),
- (dac_swing_on? "ON":"OFF"), dac_swing_lvl);
- coex_dm->cur_dac_swing_on = dac_swing_on;
- coex_dm->cur_dac_swing_lvl = dac_swing_lvl;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x,"
- " bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n",
- coex_dm->pre_dac_swing_on, coex_dm->pre_dac_swing_lvl,
- coex_dm->cur_dac_swing_on,
- coex_dm->cur_dac_swing_lvl);
-
- if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) &&
- (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl))
- return;
- }
- mdelay(30);
- halbtc8723b2ant_set_sw_fulltime_dac_swing(btcoexist, dac_swing_on,
- dac_swing_lvl);
-
- coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on;
- coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl;
-}
-
-#if 0
-static void halbtc8723b2ant_set_adc_backoff(struct btc_coexist *btcoexist,
- bool adc_backoff)
-{
- if (adc_backoff) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], BB BackOff Level On!\n");
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc05, 0x30, 0x3);
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], BB BackOff Level Off!\n");
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc05, 0x30, 0x1);
- }
-}
-
-static void halbtc8723b2ant_adc_backoff(struct btc_coexist *btcoexist,
- bool force_exec, bool adc_backoff)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s turn AdcBackOff = %s\n",
- (force_exec? "force to":""), (adc_backoff? "ON":"OFF"));
- coex_dm->cur_adc_back_off = adc_backoff;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n",
- coex_dm->pre_adc_back_off,
- coex_dm->cur_adc_back_off);
-
- if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off)
- return;
- }
- halbtc8723b2ant_set_adc_backoff(btcoexist, coex_dm->cur_adc_back_off);
-
- coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off;
-}
-#endif
-
-static void halbtc8723b2ant_set_agc_table(struct btc_coexist *btcoexist,
- bool agc_table_en)
-{
- u8 rssi_adjust_val = 0;
-
- /* BB AGC Gain Table */
- if (agc_table_en) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], BB Agc Table On!\n");
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6e1A0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6d1B0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6c1C0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6b1D0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6a1E0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x691F0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x68200001);
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], BB Agc Table Off!\n");
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa61E0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa51F0001);
- btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa4200001);
- }
-
-
- /* RF Gain */
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000);
- if (agc_table_en) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Agc Table On!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b,
- 0xfffff, 0x38fff);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b,
- 0xfffff, 0x38ffe);
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Agc Table Off!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b,
- 0xfffff, 0x380c3);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b,
- 0xfffff, 0x28ce6);
- }
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xed, 0xfffff, 0x1);
-
- if (agc_table_en) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Agc Table On!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40,
- 0xfffff, 0x38fff);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40,
- 0xfffff, 0x38ffe);
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], Agc Table Off!\n");
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40,
- 0xfffff, 0x380c3);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40,
- 0xfffff, 0x28ce6);
- }
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xed, 0xfffff, 0x0);
-
- /* set rssiAdjustVal for wifi module. */
- if (agc_table_en)
- rssi_adjust_val = 8;
- btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
- &rssi_adjust_val);
-}
-
-static void halbtc8723b2ant_agc_table(struct btc_coexist *btcoexist,
- bool force_exec, bool agc_table_en)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s %s Agc Table\n",
- (force_exec? "force to":""),
- (agc_table_en? "Enable":"Disable"));
- coex_dm->cur_agc_table_en = agc_table_en;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n",
- coex_dm->pre_agc_table_en, coex_dm->cur_agc_table_en);
-
- if (coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en)
- return;
- }
- halbtc8723b2ant_set_agc_table(btcoexist, agc_table_en);
-
- coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en;
-}
-
-static void halbtc8723b2ant_set_coex_table(struct btc_coexist *btcoexist,
- u32 val0x6c0, u32 val0x6c4,
- u32 val0x6c8, u8 val0x6cc)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0);
- btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4);
- btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8);
- btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC,
- "[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc);
- btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
-}
-
-static void halbtc8723b2ant_coex_table(struct btc_coexist *btcoexist,
- bool force_exec, u32 val0x6c0,
- u32 val0x6c4, u32 val0x6c8,
- u8 val0x6cc)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW,
- "[BTCoex], %s write Coex Table 0x6c0=0x%x,"
- " 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n",
- (force_exec? "force to":""), val0x6c0,
- val0x6c4, val0x6c8, val0x6cc);
- coex_dm->cur_val0x6c0 = val0x6c0;
- coex_dm->cur_val0x6c4 = val0x6c4;
- coex_dm->cur_val0x6c8 = val0x6c8;
- coex_dm->cur_val0x6cc = val0x6cc;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], preVal0x6c0=0x%x, "
- "preVal0x6c4=0x%x, preVal0x6c8=0x%x, "
- "preVal0x6cc=0x%x !!\n",
- coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4,
- coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL,
- "[BTCoex], curVal0x6c0=0x%x, "
- "curVal0x6c4=0x%x, curVal0x6c8=0x%x, "
- "curVal0x6cc=0x%x !!\n",
- coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4,
- coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc);
-
- if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) &&
- (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) &&
- (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) &&
- (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc))
- return;
- }
- halbtc8723b2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4,
- val0x6c8, val0x6cc);
-
- coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0;
- coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4;
- coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8;
- coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc;
-}
-
-static void halbtc8723b2ant_coex_table_with_type(struct btc_coexist *btcoexist,
- bool force_exec, u8 type)
-{
- switch (type) {
- case 0:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x55555555, 0xffff, 0x3);
- break;
- case 1:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55555555,
- 0x5afa5afa, 0xffff, 0x3);
- break;
- case 2:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
- 0x5a5a5a5a, 0xffff, 0x3);
- break;
- case 3:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa,
- 0xaaaaaaaa, 0xffff, 0x3);
- break;
- case 4:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0xffffffff,
- 0xffffffff, 0xffff, 0x3);
- break;
- case 5:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x5fff5fff,
- 0x5fff5fff, 0xffff, 0x3);
- break;
- case 6:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
- 0x5a5a5a5a, 0xffff, 0x3);
- break;
- case 7:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
- 0x5afa5afa, 0xffff, 0x3);
- break;
- case 8:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x5aea5aea,
- 0x5aea5aea, 0xffff, 0x3);
- break;
- case 9:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
- 0x5aea5aea, 0xffff, 0x3);
- break;
- case 10:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
- 0x5aff5aff, 0xffff, 0x3);
- break;
- case 11:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
- 0x5a5f5a5f, 0xffff, 0x3);
- break;
- case 12:
- halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff,
- 0x5f5f5f5f, 0xffff, 0x3);
- break;
- default:
- break;
- }
-}
-
-static void halbtc8723b2ant_set_fw_ignore_wlan_act(
- struct btc_coexist *btcoexist,
- bool enable)
-{
- u8 h2c_parameter[1] ={0};
-
- if (enable)
- h2c_parameter[0] |= BIT0;/* function enable*/
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], set FW for BT Ignore Wlan_Act, "
- "FW write 0x63=0x%x\n", h2c_parameter[0]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
-}
-
-static void halbtc8723b2ant_ignore_wlan_act(struct btc_coexist *btcoexist,
- bool force_exec, bool enable)
-{
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s turn Ignore WlanAct %s\n",
- (force_exec? "force to":""), (enable? "ON":"OFF"));
- coex_dm->cur_ignore_wlan_act = enable;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPreIgnoreWlanAct = %d, "
- "bCurIgnoreWlanAct = %d!!\n",
- coex_dm->pre_ignore_wlan_act,
- coex_dm->cur_ignore_wlan_act);
-
- if (coex_dm->pre_ignore_wlan_act ==
- coex_dm->cur_ignore_wlan_act)
- return;
- }
- halbtc8723b2ant_set_fw_ignore_wlan_act(btcoexist, enable);
-
- coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
-}
-
-static void halbtc8723b2ant_set_fw_ps_tdma(struct btc_coexist *btcoexist,
- u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5)
-{
- u8 h2c_parameter[5] ={0};
-
- h2c_parameter[0] = byte1;
- h2c_parameter[1] = byte2;
- h2c_parameter[2] = byte3;
- h2c_parameter[3] = byte4;
- h2c_parameter[4] = byte5;
-
- coex_dm->ps_tdma_para[0] = byte1;
- coex_dm->ps_tdma_para[1] = byte2;
- coex_dm->ps_tdma_para[2] = byte3;
- coex_dm->ps_tdma_para[3] = byte4;
- coex_dm->ps_tdma_para[4] = byte5;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n",
- h2c_parameter[0],
- h2c_parameter[1] << 24 | h2c_parameter[2] << 16 |
- h2c_parameter[3] << 8 | h2c_parameter[4]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
-}
-
-static void halbtc8723b2ant_sw_mechanism1(struct btc_coexist *btcoexist,
- bool shrink_rx_lpf, bool low_penalty_ra,
- bool limited_dig, bool bt_lna_constrain)
-{
- /*
- u32 wifi_bw;
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if(BTC_WIFI_BW_HT40 != wifi_bw) //only shrink RF Rx LPF for HT40
- {
- if (shrink_rx_lpf)
- shrink_rx_lpf = false;
- }
- */
-
- halbtc8723b2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf);
- halbtc8723b2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
-}
-
-static void halbtc8723b2ant_sw_mechanism2(struct btc_coexist *btcoexist,
- bool agc_table_shift, bool adc_backoff,
- bool sw_dac_swing, u32 dac_swing_lvl)
-{
- halbtc8723b2ant_agc_table(btcoexist, NORMAL_EXEC, agc_table_shift);
- /*halbtc8723b2ant_adc_backoff(btcoexist, NORMAL_EXEC, adc_backoff);*/
- halbtc8723b2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing,
- dac_swing_lvl);
-}
-
-static void halbtc8723b2ant_set_ant_path(struct btc_coexist *btcoexist,
- u8 antpos_type, bool init_hwcfg,
- bool wifi_off)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- u32 fw_ver = 0, u32tmp=0;
- bool pg_ext_switch = false;
- bool use_ext_switch = false;
- u8 h2c_parameter[2] ={0};
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_EXT_SWITCH, &pg_ext_switch);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
-
- if ((fw_ver<0xc0000) || pg_ext_switch)
- use_ext_switch = true;
-
- if (init_hwcfg) {
- /* 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT */
- u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u32tmp &= ~BIT23;
- u32tmp |= BIT24;
- btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp);
-
- btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x944, 0x3, 0x3);
- btcoexist->btc_write_1byte(btcoexist, 0x930, 0x77);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x1);
-
- /* Force GNT_BT to low */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
-
- if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
- /* tell firmware "no antenna inverse" */
- h2c_parameter[0] = 0;
- h2c_parameter[1] = 1; /* ext switch type */
- btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
- h2c_parameter);
- } else {
- /* tell firmware "antenna inverse" */
- h2c_parameter[0] = 1;
- h2c_parameter[1] = 1; /* ext switch type */
- btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
- h2c_parameter);
- }
- }
-
- /* ext switch setting */
- if (use_ext_switch) {
- /* fixed internal switch S1->WiFi, S0->BT */
- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
- switch (antpos_type) {
- case BTC_ANT_WIFI_AT_MAIN:
- /* ext switch main at wifi */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c,
- 0x3, 0x1);
- break;
- case BTC_ANT_WIFI_AT_AUX:
- /* ext switch aux at wifi */
- btcoexist->btc_write_1byte_bitmask(btcoexist,
- 0x92c, 0x3, 0x2);
- break;
- }
- } else { /* internal switch */
- /* fixed ext switch */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, 0x3, 0x1);
- switch (antpos_type) {
- case BTC_ANT_WIFI_AT_MAIN:
- /* fixed internal switch S1->WiFi, S0->BT */
- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0);
- break;
- case BTC_ANT_WIFI_AT_AUX:
- /* fixed internal switch S0->WiFi, S1->BT */
- btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280);
- break;
- }
- }
-}
-
-
-static void halbtc8723b2ant_ps_tdma(struct btc_coexist *btcoexist,
- bool force_exec,
- bool turn_on, u8 type)
-{
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], %s turn %s PS TDMA, type=%d\n",
- (force_exec? "force to":""), (turn_on? "ON":"OFF"), type);
- coex_dm->cur_ps_tdma_on = turn_on;
- coex_dm->cur_ps_tdma = type;
-
- if (!force_exec) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n",
- coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n",
- coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma);
-
- if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
- (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
- return;
- }
- if (turn_on) {
- switch (type) {
- case 1:
- default:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe1, 0x90);
- break;
- case 2:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
- 0x12, 0xe1, 0x90);
- break;
- case 3:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
- 0x3, 0xf1, 0x90);
- break;
- case 4:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x10,
- 0x03, 0xf1, 0x90);
- break;
- case 5:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0x60, 0x90);
- break;
- case 6:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
- 0x12, 0x60, 0x90);
- break;
- case 7:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1c,
- 0x3, 0x70, 0x90);
- break;
- case 8:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x10,
- 0x3, 0x70, 0x90);
- break;
- case 9:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe1, 0x90);
- break;
- case 10:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
- 0x12, 0xe1, 0x90);
- break;
- case 11:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
- 0xa, 0xe1, 0x90);
- break;
- case 12:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5,
- 0x5, 0xe1, 0x90);
- break;
- case 13:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0x60, 0x90);
- break;
- case 14:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x12,
- 0x12, 0x60, 0x90);
- break;
- case 15:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
- 0xa, 0x60, 0x90);
- break;
- case 16:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5,
- 0x5, 0x60, 0x90);
- break;
- case 17:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x2f,
- 0x2f, 0x60, 0x90);
- break;
- case 18:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x5,
- 0x5, 0xe1, 0x90);
- break;
- case 19:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
- 0x25, 0xe1, 0x90);
- break;
- case 20:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
- 0x25, 0x60, 0x90);
- break;
- case 21:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15,
- 0x03, 0x70, 0x90);
- break;
- case 71:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x1a,
- 0x1a, 0xe1, 0x90);
- break;
- }
- } else {
- /* disable PS tdma */
- switch (type) {
- case 0:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
- 0x40, 0x0);
- break;
- case 1:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
- 0x48, 0x0);
- break;
- default:
- halbtc8723b2ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
- 0x40, 0x0);
- break;
- }
- }
-
- /* update pre state */
- coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
- coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
-}
-
-static void halbtc8723b2ant_coex_alloff(struct btc_coexist *btcoexist)
-{
- /* fw all off */
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- /* sw all off */
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
-
- /* hw all off */
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
-}
-
-static void halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist)
-{
- /* force to reset coex mechanism*/
-
- halbtc8723b2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false);
-
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
-}
-
-static void halbtc8723b2ant_action_bt_inquiry(struct btc_coexist *btcoexist)
-{
- bool wifi_connected = false;
- bool low_pwr_disable = true;
-
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
-
- if (wifi_connected) {
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
- } else {
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
- }
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18);
-
- coex_dm->need_recover_0x948 = true;
- coex_dm->backup_0x948 = btcoexist->btc_read_2byte(btcoexist, 0x948);
-
- halbtc8723b2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_AUX,
- false, false);
-}
-
-static bool halbtc8723b2ant_is_common_action(struct btc_coexist *btcoexist)
-{
- bool bCommon = false, wifi_connected = false;
- bool wifi_busy = false;
- bool bt_hs_on = false, low_pwr_disable = false;
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
-
- if (!wifi_connected) {
- low_pwr_disable = false;
- btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi non-connected idle!!\n");
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
- 0x0);
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false,
- false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false,
- 0x18);
-
- bCommon = true;
- } else {
- if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE ==
- coex_dm->bt_status) {
- low_pwr_disable = false;
- btcoexist->btc_set(btcoexist,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi connected + "
- "BT non connected-idle!!\n");
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
- 0xfffff, 0x0);
- halbtc8723b2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 0);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
- 1);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
- 0xb);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC,
- false);
-
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- bCommon = true;
- } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE ==
- coex_dm->bt_status) {
- low_pwr_disable = true;
- btcoexist->btc_set(btcoexist,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- if(bt_hs_on)
- return false;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi connected + "
- "BT connected-idle!!\n");
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
- 0xfffff, 0x0);
- halbtc8723b2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 0);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false,
- 1);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
- 0xb);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC,
- false);
-
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
-
- bCommon = true;
- } else {
- low_pwr_disable = true;
- btcoexist->btc_set(btcoexist,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- &low_pwr_disable);
-
- if (wifi_busy) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi Connected-Busy + "
- "BT Busy!!\n");
- bCommon = false;
- } else {
- if(bt_hs_on)
- return false;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Wifi Connected-Idle + "
- "BT Busy!!\n");
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A,
- 0x1, 0xfffff, 0x0);
- halbtc8723b2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC,
- 7);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC,
- true, 21);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist,
- NORMAL_EXEC,
- 0xb);
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist,
- NORMAL_EXEC,
- true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist,
- NORMAL_EXEC,
- false);
- halbtc8723b2ant_sw_mechanism1(btcoexist, false,
- false, false,
- false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false,
- false, false,
- 0x18);
- bCommon = true;
- }
- }
- }
-
- return bCommon;
-}
-
-static void halbtc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist,
- bool sco_hid, bool tx_pause,
- u8 max_interval)
-{
- static s32 up, dn, m, n, wait_count;
- /*0: no change, +1: increase WiFi duration, -1: decrease WiFi duration*/
- s32 result;
- u8 retryCount=0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW,
- "[BTCoex], TdmaDurationAdjust()\n");
-
- if (!coex_dm->auto_tdma_adjust) {
- coex_dm->auto_tdma_adjust = true;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], first run TdmaDurationAdjust()!!\n");
- if (sco_hid) {
- if (tx_pause) {
- if (max_interval == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 13);
- coex_dm->ps_tdma_du_adj_type = 13;
- }else if (max_interval == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (max_interval == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- }
- } else {
- if(max_interval == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (max_interval == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (max_interval == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- }
- }
- } else {
- if (tx_pause) {
- if (max_interval == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type = 5;
- } else if (max_interval == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (max_interval == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- }
- } else {
- if (max_interval == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type = 1;
- } else if (max_interval == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (max_interval == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- }
- }
- }
-
- up = 0;
- dn = 0;
- m = 1;
- n= 3;
- result = 0;
- wait_count = 0;
- } else {
- /*acquire the BT TRx retry count from BT_Info byte2*/
- retryCount = coex_sta->bt_retry_cnt;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], retryCount = %d\n", retryCount);
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], up=%d, dn=%d, m=%d, n=%d, wait_count=%d\n",
- up, dn, m, n, wait_count);
- result = 0;
- wait_count++;
- /* no retry in the last 2-second duration*/
- if (retryCount == 0) {
- up++;
- dn--;
-
- if (dn <= 0)
- dn = 0;
-
- if (up >= n) {
- wait_count = 0;
- n = 3;
- up = 0;
- dn = 0;
- result = 1;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], Increase wifi "
- "duration!!\n");
- }/* <=3 retry in the last 2-second duration*/
- } else if (retryCount <= 3) {
- up--;
- dn++;
-
- if (up <= 0)
- up = 0;
-
- if (dn == 2) {
- if (wait_count <= 2)
- m++;
- else
- m = 1;
-
- if (m >= 20)
- m = 20;
-
- n = 3 * m;
- up = 0;
- dn = 0;
- wait_count = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], Decrease wifi duration "
- "for retryCounter<3!!\n");
- }
- } else {
- if (wait_count == 1)
- m++;
- else
- m = 1;
-
- if (m >= 20)
- m = 20;
-
- n = 3 * m;
- up = 0;
- dn = 0;
- wait_count = 0;
- result = -1;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], Decrease wifi duration "
- "for retryCounter>3!!\n");
- }
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], max Interval = %d\n", max_interval);
- if (max_interval == 1) {
- if (tx_pause) {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 1\n");
-
- if (coex_dm->cur_ps_tdma == 71) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type = 5;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type = 5;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 4) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type = 8;
- }
-
- if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 13);
- coex_dm->ps_tdma_du_adj_type = 13;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type = 16;
- }
-
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type =
- 8;
- } else if (coex_dm->cur_ps_tdma == 13) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if(coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if(coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type =
- 16;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 8) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if(coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 5);
- coex_dm->ps_tdma_du_adj_type =
- 5;
- } else if(coex_dm->cur_ps_tdma == 16) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if(coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if(coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 13);
- coex_dm->ps_tdma_du_adj_type =
- 13;
- }
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 0\n");
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 71);
- coex_dm->ps_tdma_du_adj_type = 71;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 8) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type = 4;
- }
-
- if (coex_dm->cur_ps_tdma == 13) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type = 9;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if(coex_dm->cur_ps_tdma == 16) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type = 12;
- }
-
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 71) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type =
- 1;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if(coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type =
- 4;
- } else if(coex_dm->cur_ps_tdma == 9) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type =
- 12;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 4) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 1);
- coex_dm->ps_tdma_du_adj_type =
- 1;
- } else if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 71);
- coex_dm->ps_tdma_du_adj_type =
- 71;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 9);
- coex_dm->ps_tdma_du_adj_type =
- 9;
- }
- }
- }
- } else if(max_interval == 2) {
- if (tx_pause) {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 1\n");
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type = 6;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 4) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type = 8;
- }
- if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type = 14;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type = 16;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type =
- 8;
- } else if (coex_dm->cur_ps_tdma == 13) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type =
- 16;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 8) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 6);
- coex_dm->ps_tdma_du_adj_type =
- 6;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 14);
- coex_dm->ps_tdma_du_adj_type =
- 14;
- }
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 0\n");
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type = 2;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 8) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type = 4;
- }
- if (coex_dm->cur_ps_tdma == 13) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (coex_dm->cur_ps_tdma == 14){
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type = 10;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type = 12;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type =
- 4;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type =
- 12;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 4) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 2);
- coex_dm->ps_tdma_du_adj_type =
- 2;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 10);
- coex_dm->ps_tdma_du_adj_type =
- 10;
- }
- }
- }
- } else if (max_interval == 3) {
- if (tx_pause) {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 1\n");
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type = 7;
- } else if (coex_dm->cur_ps_tdma == 4) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type = 8;
- }
- if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type = 15;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type = 16;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 8);
- coex_dm->ps_tdma_du_adj_type =
- 8;
- } else if (coex_dm->cur_ps_tdma == 13) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 16);
- coex_dm->ps_tdma_du_adj_type =
- 16;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 8) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 7);
- coex_dm->ps_tdma_du_adj_type =
- 7;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 15);
- coex_dm->ps_tdma_du_adj_type =
- 15;
- }
- }
- } else {
- BTC_PRINT(BTC_MSG_ALGORITHM,
- ALGO_TRACE_FW_DETAIL,
- "[BTCoex], TxPause = 0\n");
- if (coex_dm->cur_ps_tdma == 5) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 6) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 7) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type = 3;
- } else if (coex_dm->cur_ps_tdma == 8) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type = 4;
- }
- if (coex_dm->cur_ps_tdma == 13) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 14) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 15) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type = 11;
- } else if (coex_dm->cur_ps_tdma == 16) {
- halbtc8723b2ant_ps_tdma(btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type = 12;
- }
- if (result == -1) {
- if (coex_dm->cur_ps_tdma == 1) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 4);
- coex_dm->ps_tdma_du_adj_type =
- 4;
- } else if (coex_dm->cur_ps_tdma == 9) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 12);
- coex_dm->ps_tdma_du_adj_type =
- 12;
- }
- } else if (result == 1) {
- if (coex_dm->cur_ps_tdma == 4) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 3) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 2) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 3);
- coex_dm->ps_tdma_du_adj_type =
- 3;
- } else if (coex_dm->cur_ps_tdma == 12) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 11) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- } else if (coex_dm->cur_ps_tdma == 10) {
- halbtc8723b2ant_ps_tdma(
- btcoexist,
- NORMAL_EXEC,
- true, 11);
- coex_dm->ps_tdma_du_adj_type =
- 11;
- }
- }
- }
- }
- }
-
- /*if current PsTdma not match with the recorded one (when scan, dhcp..),
- *then we have to adjust it back to the previous record one.*/
- if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) {
- bool scan = false, link = false, roam = false;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], PsTdma type dismatch!!!, "
- "curPsTdma=%d, recordPsTdma=%d\n",
- coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
-
- if (!scan && !link && !roam)
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true,
- coex_dm->ps_tdma_du_adj_type);
- else
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL,
- "[BTCoex], roaming/link/scan is under"
- " progress, will adjust next time!!!\n");
- }
-}
-
-/* SCO only or SCO+PAN(HS) */
-static void halbtc8723b2ant_action_sco(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- /*for SCO quality at 11b/g mode*/
- if (BTC_WIFI_BW_LEGACY == wifi_bw)
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
- else /*for SCO quality & wifi performance balance at 11n mode*/
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 8);
-
- /*for voice quality */
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- true, 0x4);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- true, 0x4);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- true, 0x4);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- true, 0x4);
- }
- }
-}
-
-static void halbtc8723b2ant_action_hid(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (BTC_WIFI_BW_LEGACY == wifi_bw) /*/for HID at 11b/g mode*/
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
- else /*for HID quality & wifi performance balance at 11n mode*/
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 9);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9);
- else
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/*A2DP only / PAN(EDR) only/ A2DP+PAN(HS)*/
-static void halbtc8723b2ant_action_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state;
- u32 wifi_bw;
- u8 ap_num = 0;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- wifi_rssi_state1 = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 1, 2, 40, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
-
- /* define the office environment */
- /* driver don't know AP num in Linux, so we will never enter this if */
- if (ap_num >= 10 && BTC_RSSI_HIGH(wifi_rssi_state1)) {
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
- 0x0);
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- true, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- true, 0x18);
- }
- return;
- }
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- halbtc8723b2ant_tdma_duration_adjust(btcoexist,false, false, 1);
- else
- halbtc8723b2ant_tdma_duration_adjust(btcoexist,false, true, 1);
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
-
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, true, 2);
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist,
- BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false,0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 10);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1);
- else
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
-
- /* sw mechanism */
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/*PAN(HS) only*/
-static void halbtc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH) )
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
-
- halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/*PAN(EDR)+A2DP*/
-static void halbtc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_coex_table_with_type(btcoexist,NORMAL_EXEC, 12);
- if (BTC_WIFI_BW_HT40 == wifi_bw)
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, false,
- true, 3);
- else
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, false,
- false, 3);
- } else {
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, true, 3);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, false,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
- 3);
- halbtc8723b2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 11);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
- 0xfffff, 0x780);
- } else {
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC,
- 6);
- halbtc8723b2ant_coex_table_with_type(btcoexist,
- NORMAL_EXEC, 7);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1,
- 0xfffff, 0x0);
- }
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, false, 2);
- } else {
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
- halbtc8723b2ant_coex_table_with_type(btcoexist,NORMAL_EXEC, 11);
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff,
- 0x0);
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, true, 2);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)){
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-/* HID+A2DP+PAN(EDR) */
-static void halbtc8723b2ant_action_hid_a2dp_pan_edr(
- struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- if (BTC_WIFI_BW_HT40 == wifi_bw)
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true,
- true, 2);
- else
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true,
- false, 3);
- } else {
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, true, 3);
- }
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist)
-{
- u8 wifi_rssi_state, bt_rssi_state;
- u32 wifi_bw;
-
- wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist,
- 0, 2, 15, 0);
- bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0);
-
- btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0);
-
- halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6);
-
- if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist))
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true);
- else
- halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
-
- halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
-
- if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH))
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, false, 2);
- else
- halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, true, 2);
-
- /* sw mechanism */
- if (BTC_WIFI_BW_HT40 == wifi_bw) {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, true, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- } else {
- if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
- (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, true, false,
- false, 0x18);
- } else {
- halbtc8723b2ant_sw_mechanism1(btcoexist, false, true,
- false, false);
- halbtc8723b2ant_sw_mechanism2(btcoexist, false, false,
- false, 0x18);
- }
- }
-}
-
-static void halbtc8723b2ant_run_coexist_mechanism(
- struct btc_coexist *btcoexist)
-{
- u8 algorithm = 0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], RunCoexistMechanism()===>\n");
-
- if (btcoexist->manual_control) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], RunCoexistMechanism(), "
- "return for Manual CTRL <===\n");
- return;
- }
-
- if (coex_sta->under_ips) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], wifi is under IPS !!!\n");
- return;
- }
-
- algorithm = halbtc8723b2ant_action_algorithm(btcoexist);
- if (coex_sta->c2h_bt_inquiry_page &&
- (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT is under inquiry/page scan !!\n");
- halbtc8723b2ant_action_bt_inquiry(btcoexist);
- return;
- } else {
- if (coex_dm->need_recover_0x948) {
- coex_dm->need_recover_0x948 = false;
- btcoexist->btc_write_2byte(btcoexist, 0x948,
- coex_dm->backup_0x948);
- }
- }
-
- coex_dm->cur_algorithm = algorithm;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Algorithm = %d \n",
- coex_dm->cur_algorithm);
-
- if (halbtc8723b2ant_is_common_action(btcoexist)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant common.\n");
- coex_dm->auto_tdma_adjust = false;
- } else {
- if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], preAlgorithm=%d, "
- "curAlgorithm=%d\n", coex_dm->pre_algorithm,
- coex_dm->cur_algorithm);
- coex_dm->auto_tdma_adjust = false;
- }
- switch (coex_dm->cur_algorithm) {
- case BT_8723B_2ANT_COEX_ALGO_SCO:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, algorithm = SCO.\n");
- halbtc8723b2ant_action_sco(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, algorithm = HID.\n");
- halbtc8723b2ant_action_hid(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = A2DP.\n");
- halbtc8723b2ant_action_a2dp(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = A2DP+PAN(HS).\n");
- halbtc8723b2ant_action_a2dp_pan_hs(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = PAN(EDR).\n");
- halbtc8723b2ant_action_pan_edr(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_PANHS:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = HS mode.\n");
- halbtc8723b2ant_action_pan_hs(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = PAN+A2DP.\n");
- halbtc8723b2ant_action_pan_edr_a2dp(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = PAN(EDR)+HID.\n");
- halbtc8723b2ant_action_pan_edr_hid(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = HID+A2DP+PAN.\n");
- halbtc8723b2ant_action_hid_a2dp_pan_edr(btcoexist);
- break;
- case BT_8723B_2ANT_COEX_ALGO_HID_A2DP:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = HID+A2DP.\n");
- halbtc8723b2ant_action_hid_a2dp(btcoexist);
- break;
- default:
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], Action 2-Ant, "
- "algorithm = coexist All Off!!\n");
- halbtc8723b2ant_coex_alloff(btcoexist);
- break;
- }
- coex_dm->pre_algorithm = coex_dm->cur_algorithm;
- }
-}
-
-static void halbtc8723b2ant_wifioff_hwcfg(struct btc_coexist *btcoexist)
-{
- /* set wlan_act to low */
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4);
- /* Force GNT_BT to High */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3);
- /* BT select s0/s1 is controlled by BT */
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0);
-}
-
-/*********************************************************************
- * work around function start with wa_halbtc8723b2ant_
- *********************************************************************/
-/*********************************************************************
- * extern function start with EXhalbtc8723b2ant_
- *********************************************************************/
-void ex_halbtc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist)
-{
- u8 u8tmp = 0;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], 2Ant Init HW Config!!\n");
- coex_dm->bt_rf0x1e_backup =
- btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff);
-
- /* 0x790[5:0]=0x5 */
- u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
- u8tmp &= 0xc0;
- u8tmp |= 0x5;
- btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp);
-
-
- /*Antenna config */
- halbtc8723b2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN,
- true, false);
-
-
-
-
- /* PTA parameter */
- halbtc8723b2ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
-
- /* Enable counter statistics */
- /*0x76e[3] =1, WLAN_Act control by PTA*/
- btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
- btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3);
- btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
-}
-
-void ex_halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], Coex Mechanism Init!!\n");
- halbtc8723b2ant_init_coex_dm(btcoexist);
-}
-
-void ex_halbtc8723b2ant_display_coex_info(struct btc_coexist *btcoexist)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
- struct btc_bt_link_info* bt_link_info = &btcoexist->bt_link_info;
- u8 *cli_buf = btcoexist->cli_buf;
- u8 u8tmp[4], i, bt_info_ext, ps_tdma_case=0;
- u32 u32tmp[4];
- bool roam = false, scan = false;
- bool link = false, wifi_under_5g = false;
- bool bt_hs_on = false, wifi_busy = false;
- s32 wifi_rssi = 0, bt_hs_rssi = 0;
- u32 wifi_bw, wifi_traffic_dir, fa_ofdm, fa_cck;
- u8 wifi_dot11_chnl, wifi_hs_chnl;
- u32 fw_ver = 0, bt_patch_ver = 0;
- u8 ap_num = 0;
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ============[BT Coexist info]============");
- CL_PRINTF(cli_buf);
-
- if (btcoexist->manual_control) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ==========[Under Manual Control]============");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n ==========================================");
- CL_PRINTF(cli_buf);
- }
-
- if (!board_info->bt_exist) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!");
- CL_PRINTF(cli_buf);
- return;
- }
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
- "Ant PG number/ Ant mechanism:",
- board_info->pg_ant_num, board_info->btdm_ant_num);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d",
- "BT stack/ hci ext ver",
- ((stack_info->profile_notified)? "Yes":"No"),
- stack_info->hci_version);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)",
- "CoexVer/ fw_ver/ PatchVer",
- glcoex_ver_date_8723b_2ant, glcoex_ver_8723b_2ant,
- fw_ver, bt_patch_ver, bt_patch_ver);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL,
- &wifi_dot11_chnl);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)",
- "Dot11 channel / HsChnl(HsMode)",
- wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ",
- "H2C Wifi inform bt chnl Info", coex_dm->wifi_chnl_info[0],
- coex_dm->wifi_chnl_info[1], coex_dm->wifi_chnl_info[2]);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
- btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
- btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d",
- "Wifi rssi/ HS rssi/ AP#", wifi_rssi, bt_hs_rssi, ap_num);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
- "Wifi link/ roam/ scan", link, roam, scan);
- CL_PRINTF(cli_buf);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
- &wifi_traffic_dir);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ",
- "Wifi status", (wifi_under_5g? "5G":"2.4G"),
- ((BTC_WIFI_BW_LEGACY == wifi_bw)? "Legacy":
- (((BTC_WIFI_BW_HT40 == wifi_bw)? "HT40":"HT20"))),
- ((!wifi_busy)? "idle":
- ((BTC_WIFI_TRAFFIC_TX ==wifi_traffic_dir)?\
- "uplink":"downlink")));
- CL_PRINTF(cli_buf);
-
-
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d",
- "SCO/HID/PAN/A2DP",
- bt_link_info->sco_exist, bt_link_info->hid_exist,
- bt_link_info->pan_exist, bt_link_info->a2dp_exist);
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO);
-
- bt_info_ext = coex_sta->bt_info_ext;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s",
- "BT Info A2DP rate",
- (bt_info_ext&BIT0)? "Basic rate":"EDR rate");
- CL_PRINTF(cli_buf);
-
- for (i=0; i<BT_INFO_SRC_8723B_2ANT_MAX; i++) {
- if (coex_sta->bt_info_c2h_cnt[i]) {
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %02x %02x %02x "
- "%02x %02x %02x %02x(%d)",
- glbt_info_src_8723b_2ant[i], \
- coex_sta->bt_info_c2h[i][0],
- coex_sta->bt_info_c2h[i][1],
- coex_sta->bt_info_c2h[i][2],
- coex_sta->bt_info_c2h[i][3],
- coex_sta->bt_info_c2h[i][4],
- coex_sta->bt_info_c2h[i][5],
- coex_sta->bt_info_c2h[i][6],
- coex_sta->bt_info_c2h_cnt[i]);
- CL_PRINTF(cli_buf);
- }
- }
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s",
- "PS state, IPS/LPS",
- ((coex_sta->under_ips? "IPS ON":"IPS OFF")),
- ((coex_sta->under_lps? "LPS ON":"LPS OFF")));
- CL_PRINTF(cli_buf);
- btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD);
-
- /* Sw mechanism */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s", "============[Sw mechanism]============");
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ",
- "SM1[ShRf/ LpRA/ LimDig]", coex_dm->cur_rf_rx_lpf_shrink,
- coex_dm->cur_low_penalty_ra, coex_dm->limited_dig);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ",
- "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]",
- coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off,
- coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl);
- CL_PRINTF(cli_buf);
-
- /* Fw mechanism */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Fw mechanism]============");
- CL_PRINTF(cli_buf);
-
- ps_tdma_case = coex_dm->cur_ps_tdma;
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)",
- "PS TDMA", coex_dm->ps_tdma_para[0],
- coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2],
- coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4],
- ps_tdma_case, coex_dm->auto_tdma_adjust);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ",
- "DecBtPwr/ IgnWlanAct", coex_dm->cur_dec_bt_pwr,
- coex_dm->cur_ignore_wlan_act);
- CL_PRINTF(cli_buf);
-
- /* Hw setting */
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s",
- "============[Hw setting]============");
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x",
- "RF-A, 0x1e initVal", coex_dm->bt_rf0x1e_backup);
- CL_PRINTF(cli_buf);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x880);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0x778/0x880[29:25]", u8tmp[0],
- (u32tmp[0]&0x3e000000) >> 25);
- CL_PRINTF(cli_buf);
-
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x948);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x67);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x765);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0x948/ 0x67[5] / 0x765",
- u32tmp[0], ((u8tmp[0]&0x20)>> 5), u8tmp[1]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x92c);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x930);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x944);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]",
- u32tmp[0]&0x3, u32tmp[1]&0xff, u32tmp[2]&0x3);
- CL_PRINTF(cli_buf);
-
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x39);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40);
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
- u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0x64);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
- "0x38[11]/0x40/0x4c[24:23]/0x64[0]",
- ((u8tmp[0] & 0x8)>>3), u8tmp[1],
- ((u32tmp[0]&0x01800000)>>23), u8tmp[2]&0x1);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x",
- "0xc50(dig)/0x49c(null-drop)", u32tmp[0]&0xff, u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8);
- u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0);
-
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b);
- u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
-
- fa_ofdm = ((u32tmp[0]&0xffff0000) >> 16) +
- ((u32tmp[1]&0xffff0000) >> 16) +
- (u32tmp[1] & 0xffff) +
- (u32tmp[2] & 0xffff) +
- ((u32tmp[3]&0xffff0000) >> 16) +
- (u32tmp[3] & 0xffff) ;
- fa_cck = (u8tmp[0] << 8) + u8tmp[1];
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x",
- "OFDM-CCA/OFDM-FA/CCK-FA", \
- u32tmp[0]&0xffff, fa_ofdm, fa_cck);
- CL_PRINTF(cli_buf);
-
- u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
- u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
- u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
- u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE,
- "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
- "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
- u32tmp[0], u32tmp[1], u32tmp[2], u8tmp[0]);
- CL_PRINTF(cli_buf);
-
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "0x770(high-pri rx/tx)",
- coex_sta->high_priority_rx, coex_sta->high_priority_tx);
- CL_PRINTF(cli_buf);
- CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d",
- "0x774(low-pri rx/tx)", coex_sta->low_priority_rx,
- coex_sta->low_priority_tx);
- CL_PRINTF(cli_buf);
-#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 1)
- halbtc8723b2ant_monitor_bt_ctr(btcoexist);
-#endif
- btcoexist->btc_disp_dbg_msg(btcoexist,
- BTC_DBG_DISP_COEX_STATISTICS);
-}
-
-
-void ex_halbtc8723b2ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_IPS_ENTER == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], IPS ENTER notify\n");
- coex_sta->under_ips = true;
- halbtc8723b2ant_wifioff_hwcfg(btcoexist);
- halbtc8723b2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
- halbtc8723b2ant_coex_alloff(btcoexist);
- } else if (BTC_IPS_LEAVE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], IPS LEAVE notify\n");
- coex_sta->under_ips = false;
- ex_halbtc8723b2ant_init_hwconfig(btcoexist);
- halbtc8723b2ant_init_coex_dm(btcoexist);
- halbtc8723b2ant_query_bt_info(btcoexist);
- }
-}
-
-void ex_halbtc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_LPS_ENABLE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], LPS ENABLE notify\n");
- coex_sta->under_lps = true;
- } else if (BTC_LPS_DISABLE == type) {
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], LPS DISABLE notify\n");
- coex_sta->under_lps = false;
- }
-}
-
-void ex_halbtc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_SCAN_START == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], SCAN START notify\n");
- else if (BTC_SCAN_FINISH == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], SCAN FINISH notify\n");
-}
-
-void ex_halbtc8723b2ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
-{
- if (BTC_ASSOCIATE_START == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], CONNECT START notify\n");
- else if (BTC_ASSOCIATE_FINISH == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], CONNECT FINISH notify\n");
-}
-
-void ex_halbtc8723b2ant_media_status_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- u8 h2c_parameter[3] ={0};
- u32 wifi_bw;
- u8 wifi_central_chnl;
-
- if (BTC_MEDIA_CONNECT == type)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], MEDIA connect notify\n");
- else
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], MEDIA disconnect notify\n");
-
- /* only 2.4G we need to inform bt the chnl mask */
- btcoexist->btc_get(btcoexist,
- BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifi_central_chnl);
- if ((BTC_MEDIA_CONNECT == type) &&
- (wifi_central_chnl <= 14)) {
- h2c_parameter[0] = 0x1;
- h2c_parameter[1] = wifi_central_chnl;
- btcoexist->btc_get(btcoexist,
- BTC_GET_U4_WIFI_BW, &wifi_bw);
- if (BTC_WIFI_BW_HT40 == wifi_bw)
- h2c_parameter[2] = 0x30;
- else
- h2c_parameter[2] = 0x20;
- }
-
- coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
- coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
- coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC,
- "[BTCoex], FW write 0x66=0x%x\n",
- h2c_parameter[0] << 16 | h2c_parameter[1] << 8 |
- h2c_parameter[2]);
-
- btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
-}
-
-void ex_halbtc8723b2ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type)
-{
- if (type == BTC_PACKET_DHCP)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], DHCP Packet notify\n");
-}
-
-void ex_halbtc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmpbuf, u8 length)
-{
- u8 btInfo = 0;
- u8 i, rsp_source = 0;
- bool bt_busy = false, limited_dig = false;
- bool wifi_connected = false;
-
- coex_sta->c2h_bt_info_req_sent = false;
-
- rsp_source = tmpbuf[0]&0xf;
- if(rsp_source >= BT_INFO_SRC_8723B_2ANT_MAX)
- rsp_source = BT_INFO_SRC_8723B_2ANT_WIFI_FW;
- coex_sta->bt_info_c2h_cnt[rsp_source]++;
-
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "[BTCoex], Bt info[%d], length=%d, hex data=[",
- rsp_source, length);
- for (i = 0; i < length; i++) {
- coex_sta->bt_info_c2h[rsp_source][i] = tmpbuf[i];
- if (i == 1)
- btInfo = tmpbuf[i];
- if (i == length-1)
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "0x%02x]\n", tmpbuf[i]);
- else
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY,
- "0x%02x, ", tmpbuf[i]);
- }
-
- if (btcoexist->manual_control) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), "
- "return for Manual CTRL<===\n");
- return;
- }
-
- if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rsp_source) {
- coex_sta->bt_retry_cnt = /* [3:0]*/
- coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
-
- coex_sta->bt_rssi =
- coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;
-
- coex_sta->bt_info_ext =
- coex_sta->bt_info_c2h[rsp_source][4];
-
- /* Here we need to resend some wifi info to BT
- because bt is reset and loss of the info.*/
- if ((coex_sta->bt_info_ext & BIT1)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT ext info bit1 check,"
- " send wifi BW&Chnl to BT!!\n");
- btcoexist->btc_get(btcoexist,BTC_GET_BL_WIFI_CONNECTED,
- &wifi_connected);
- if (wifi_connected)
- ex_halbtc8723b2ant_media_status_notify(
- btcoexist,
- BTC_MEDIA_CONNECT);
- else
- ex_halbtc8723b2ant_media_status_notify(
- btcoexist,
- BTC_MEDIA_DISCONNECT);
- }
-
- if ((coex_sta->bt_info_ext & BIT3)) {
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BT ext info bit3 check, "
- "set BT NOT to ignore Wlan active!!\n");
- halbtc8723b2ant_ignore_wlan_act(btcoexist, FORCE_EXEC,
- false);
- } else {
- /* BT already NOT ignore Wlan active, do nothing here.*/
- }
-#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 0)
- if ((coex_sta->bt_info_ext & BIT4)) {
- /* BT auto report already enabled, do nothing*/
- } else {
- halbtc8723b2ant_bt_auto_report(btcoexist, FORCE_EXEC,
- true);
- }
-#endif
- }
-
- /* check BIT2 first ==> check if bt is under inquiry or page scan*/
- if (btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE)
- coex_sta->c2h_bt_inquiry_page = true;
- else
- coex_sta->c2h_bt_inquiry_page = false;
-
- /* set link exist status*/
- if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) {
- coex_sta->bt_link_exist = false;
- coex_sta->pan_exist = false;
- coex_sta->a2dp_exist = false;
- coex_sta->hid_exist = false;
- coex_sta->sco_exist = false;
- } else {// connection exists
- coex_sta->bt_link_exist = true;
- if (btInfo & BT_INFO_8723B_2ANT_B_FTP)
- coex_sta->pan_exist = true;
- else
- coex_sta->pan_exist = false;
- if (btInfo & BT_INFO_8723B_2ANT_B_A2DP)
- coex_sta->a2dp_exist = true;
- else
- coex_sta->a2dp_exist = false;
- if (btInfo & BT_INFO_8723B_2ANT_B_HID)
- coex_sta->hid_exist = true;
- else
- coex_sta->hid_exist = false;
- if (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO)
- coex_sta->sco_exist = true;
- else
- coex_sta->sco_exist = false;
- }
-
- halbtc8723b2ant_update_bt_link_info(btcoexist);
-
- if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) {
- coex_dm->bt_status = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), "
- "BT Non-Connected idle!!!\n");
- /* connection exists but no busy */
- } else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) {
- coex_dm->bt_status = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
- } else if ((btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO) ||
- (btInfo & BT_INFO_8723B_2ANT_B_SCO_BUSY)) {
- coex_dm->bt_status =
- BT_8723B_2ANT_BT_STATUS_SCO_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
- } else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) {
- coex_dm->bt_status =
- BT_8723B_2ANT_BT_STATUS_ACL_BUSY;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
- } else {
- coex_dm->bt_status = BT_8723B_2ANT_BT_STATUS_MAX;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], BtInfoNotify(), "
- "BT Non-Defined state!!!\n");
- }
-
- if ((BT_8723B_2ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
- (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
- (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) {
- bt_busy = true;
- limited_dig = true;
- } else {
- bt_busy = false;
- limited_dig = false;
- }
-
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
-
- coex_dm->limited_dig = limited_dig;
- btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig);
-
- halbtc8723b2ant_run_coexist_mechanism(btcoexist);
-}
-
-void ex_halbtc8723b2ant_halt_notify(struct btc_coexist *btcoexist)
-{
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n");
-
- halbtc8723b2ant_wifioff_hwcfg(btcoexist);
- halbtc8723b2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
- ex_halbtc8723b2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
-}
-
-void ex_halbtc8723b2ant_periodical(struct btc_coexist *btcoexist)
-{
- struct btc_board_info *board_info = &btcoexist->board_info;
- struct btc_stack_info *stack_info = &btcoexist->stack_info;
- static u8 dis_ver_info_cnt = 0;
- u32 fw_ver = 0, bt_patch_ver = 0;
-
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "[BTCoex], =========================="
- "Periodical===========================\n");
-
- if (dis_ver_info_cnt <= 5) {
- dis_ver_info_cnt += 1;
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], ****************************"
- "************************************\n");
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], Ant PG Num/ Ant Mech/ "
- "Ant Pos = %d/ %d/ %d\n", board_info->pg_ant_num,
- board_info->btdm_ant_num, board_info->btdm_ant_pos);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], BT stack/ hci ext ver = %s / %d\n",
- ((stack_info->profile_notified)? "Yes":"No"),
- stack_info->hci_version);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER,
- &bt_patch_ver);
- btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], CoexVer/ fw_ver/ PatchVer = "
- "%d_%x/ 0x%x/ 0x%x(%d)\n",
- glcoex_ver_date_8723b_2ant, glcoex_ver_8723b_2ant,
- fw_ver, bt_patch_ver, bt_patch_ver);
- BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT,
- "[BTCoex], *****************************"
- "***********************************\n");
- }
-
-#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 0)
- halbtc8723b2ant_query_bt_info(btcoexist);
- halbtc8723b2ant_monitor_bt_ctr(btcoexist);
- halbtc8723b2ant_monitor_bt_enable_disable(btcoexist);
-#else
- if (halbtc8723b2ant_is_wifi_status_changed(btcoexist) ||
- coex_dm->auto_tdma_adjust)
- halbtc8723b2ant_run_coexist_mechanism(btcoexist);
-#endif
-}
-
-
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.h b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.h
deleted file mode 100644
index fa3784aa70cd..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/************************************************************************
- * The following is for 8723B 2Ant BT Co-exist definition
- ************************************************************************/
-#define BT_AUTO_REPORT_ONLY_8723B_2ANT 1
-
-
-#define BT_INFO_8723B_2ANT_B_FTP BIT7
-#define BT_INFO_8723B_2ANT_B_A2DP BIT6
-#define BT_INFO_8723B_2ANT_B_HID BIT5
-#define BT_INFO_8723B_2ANT_B_SCO_BUSY BIT4
-#define BT_INFO_8723B_2ANT_B_ACL_BUSY BIT3
-#define BT_INFO_8723B_2ANT_B_INQ_PAGE BIT2
-#define BT_INFO_8723B_2ANT_B_SCO_ESCO BIT1
-#define BT_INFO_8723B_2ANT_B_CONNECTION BIT0
-
-#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT 2
-
-typedef enum _BT_INFO_SRC_8723B_2ANT{
- BT_INFO_SRC_8723B_2ANT_WIFI_FW = 0x0,
- BT_INFO_SRC_8723B_2ANT_BT_RSP = 0x1,
- BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2,
- BT_INFO_SRC_8723B_2ANT_MAX
-}BT_INFO_SRC_8723B_2ANT,*PBT_INFO_SRC_8723B_2ANT;
-
-typedef enum _BT_8723B_2ANT_BT_STATUS{
- BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0,
- BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1,
- BT_8723B_2ANT_BT_STATUS_INQ_PAGE = 0x2,
- BT_8723B_2ANT_BT_STATUS_ACL_BUSY = 0x3,
- BT_8723B_2ANT_BT_STATUS_SCO_BUSY = 0x4,
- BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5,
- BT_8723B_2ANT_BT_STATUS_MAX
-}BT_8723B_2ANT_BT_STATUS,*PBT_8723B_2ANT_BT_STATUS;
-
-typedef enum _BT_8723B_2ANT_COEX_ALGO{
- BT_8723B_2ANT_COEX_ALGO_UNDEFINED = 0x0,
- BT_8723B_2ANT_COEX_ALGO_SCO = 0x1,
- BT_8723B_2ANT_COEX_ALGO_HID = 0x2,
- BT_8723B_2ANT_COEX_ALGO_A2DP = 0x3,
- BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS = 0x4,
- BT_8723B_2ANT_COEX_ALGO_PANEDR = 0x5,
- BT_8723B_2ANT_COEX_ALGO_PANHS = 0x6,
- BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7,
- BT_8723B_2ANT_COEX_ALGO_PANEDR_HID = 0x8,
- BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9,
- BT_8723B_2ANT_COEX_ALGO_HID_A2DP = 0xa,
- BT_8723B_2ANT_COEX_ALGO_MAX = 0xb,
-}BT_8723B_2ANT_COEX_ALGO,*PBT_8723B_2ANT_COEX_ALGO;
-
-struct coex_dm_8723b_2ant{
- /* fw mechanism */
- bool pre_dec_bt_pwr;
- bool cur_dec_bt_pwr;
- u8 pre_fw_dac_swing_lvl;
- u8 cur_fw_dac_swing_lvl;
- bool cur_ignore_wlan_act;
- bool pre_ignore_wlan_act;
- u8 pre_ps_tdma;
- u8 cur_ps_tdma;
- u8 ps_tdma_para[5];
- u8 ps_tdma_du_adj_type;
- bool reset_tdma_adjust;
- bool auto_tdma_adjust;
- bool pre_ps_tdma_on;
- bool cur_ps_tdma_on;
- bool pre_bt_auto_report;
- bool cur_bt_auto_report;
-
- /* sw mechanism */
- bool pre_rf_rx_lpf_shrink;
- bool cur_rf_rx_lpf_shrink;
- u32 bt_rf0x1e_backup;
- bool pre_low_penalty_ra;
- bool cur_low_penalty_ra;
- bool pre_dac_swing_on;
- u32 pre_dac_swing_lvl;
- bool cur_dac_swing_on;
- u32 cur_dac_swing_lvl;
- bool pre_adc_back_off;
- bool cur_adc_back_off;
- bool pre_agc_table_en;
- bool cur_agc_table_en;
- u32 pre_val0x6c0;
- u32 cur_val0x6c0;
- u32 pre_val0x6c4;
- u32 cur_val0x6c4;
- u32 pre_val0x6c8;
- u32 cur_val0x6c8;
- u8 pre_val0x6cc;
- u8 cur_val0x6cc;
- bool limited_dig;
-
- /* algorithm related */
- u8 pre_algorithm;
- u8 cur_algorithm;
- u8 bt_status;
- u8 wifi_chnl_info[3];
-
- bool need_recover_0x948;
- u16 backup_0x948;
-};
-
-struct coex_sta_8723b_2ant{
- bool bt_link_exist;
- bool sco_exist;
- bool a2dp_exist;
- bool hid_exist;
- bool pan_exist;
-
- bool under_lps;
- bool under_ips;
- u32 high_priority_tx;
- u32 high_priority_rx;
- u32 low_priority_tx;
- u32 low_priority_rx;
- u8 bt_rssi;
- u8 pre_bt_rssi_state;
- u8 pre_wifi_rssi_state[4];
- bool c2h_bt_info_req_sent;
- u8 bt_info_c2h[BT_INFO_SRC_8723B_2ANT_MAX][10];
- u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_2ANT_MAX];
- bool c2h_bt_inquiry_page;
- u8 bt_retry_cnt;
- u8 bt_info_ext;
-};
-
-/*********************************************************************
- * The following is interface which will notify coex module.
- *********************************************************************/
-void ex_halbtc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist);
-void ex_halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist);
-void ex_halbtc8723b2ant_ips_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b2ant_connect_notify(struct btc_coexist *btcoexist, u8 type);
-void ex_halbtc8723b2ant_media_status_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8723b2ant_special_packet_notify(struct btc_coexist *btcoexist,
- u8 type);
-void ex_halbtc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmpbuf, u8 length);
-void ex_halbtc8723b2ant_halt_notify(struct btc_coexist *btcoexist);
-void ex_halbtc8723b2ant_periodical(struct btc_coexist * btcoexist);
-void ex_halbtc8723b2ant_display_coex_info(struct btc_coexist *btcoexist);
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c
deleted file mode 100644
index 01f5a74028a0..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c
+++ /dev/null
@@ -1,1130 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
- ******************************************************************************/
-
-#include "halbt_precomp.h"
-
-/*#if(BT_30_SUPPORT == 1)*/
-#if 1
-/***********************************************
- * Global variables
- ***********************************************/
-static const char *const bt_profile_string[] = {
- "NONE",
- "A2DP",
- "PAN",
- "HID",
- "SCO",
-};
-
-static const char *const bt_spec_string[] = {
- "1.0b",
- "1.1",
- "1.2",
- "2.0+EDR",
- "2.1+EDR",
- "3.0+HS",
- "4.0",
-};
-
-static const char *const bt_link_role_string[] = {
- "Master",
- "Slave",
-};
-
-static const char *const h2c_state_string[] = {
- "successful",
- "h2c busy",
- "rf off",
- "fw not read",
-};
-
-static const char *const io_state_string[] = {
- "IO_STATUS_SUCCESS",
- "IO_STATUS_FAIL_CANNOT_IO",
- "IO_STATUS_FAIL_RF_OFF",
- "IO_STATUS_FAIL_FW_READ_CLEAR_TIMEOUT",
- "IO_STATUS_FAIL_WAIT_IO_EVENT_TIMEOUT",
- "IO_STATUS_INVALID_LEN",
- "IO_STATUS_IO_IDLE_QUEUE_EMPTY",
- "IO_STATUS_IO_INSERT_WAIT_QUEUE_FAIL",
- "IO_STATUS_UNKNOWN_FAIL",
- "IO_STATUS_WRONG_LEVEL",
- "IO_STATUS_H2C_STOPPED",
-};
-
-struct btc_coexist gl_bt_coexist;
-
-u32 btc_dbg_type[BTC_MSG_MAX];
-static u8 btc_dbg_buf[100];
-
-/***************************************************
- * Debug related function
- ***************************************************/
-static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist)
-{
- if (!btcoexist->binded || NULL == btcoexist->adapter)
- return false;
-
- return true;
-}
-
-static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
-{
-
- if (rtlpriv->link_info.b_busytraffic)
- return true;
- else
- return false;
-}
-
-
-static void halbtc_dbg_init(void)
-{
- u8 i;
-
- for (i = 0; i < BTC_MSG_MAX; i++)
- btc_dbg_type[i] = 0;
-
- btc_dbg_type[BTC_MSG_INTERFACE] = \
-// INTF_INIT |
-// INTF_NOTIFY |
- 0;
-
- btc_dbg_type[BTC_MSG_ALGORITHM] = \
-// ALGO_BT_RSSI_STATE |
-// ALGO_WIFI_RSSI_STATE |
-// ALGO_BT_MONITOR |
-// ALGO_TRACE |
-// ALGO_TRACE_FW |
-// ALGO_TRACE_FW_DETAIL |
-// ALGO_TRACE_FW_EXEC |
-// ALGO_TRACE_SW |
-// ALGO_TRACE_SW_DETAIL |
-// ALGO_TRACE_SW_EXEC |
- 0;
-}
-
-static bool halbtc_is_bt40(struct rtl_priv *adapter)
-{
- struct rtl_priv *rtlpriv = adapter;
- struct rtl_phy *rtlphy = &(rtlpriv->phy);
- bool is_ht40 = true;
- enum ht_channel_width bw = rtlphy->current_chan_bw;
-
-
- if (bw == HT_CHANNEL_WIDTH_20)
- is_ht40 = false;
- else if (bw == HT_CHANNEL_WIDTH_20_40)
- is_ht40 = true;
-
- return is_ht40;
-}
-
-static bool halbtc_legacy(struct rtl_priv *adapter)
-{
- struct rtl_priv *rtlpriv = adapter;
- struct rtl_mac *mac = rtl_mac(rtlpriv);
-
- bool is_legacy = false;
-
- if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_B))
- is_legacy = true;
-
- return is_legacy;
-}
-
-bool halbtc_is_wifi_uplink(struct rtl_priv *adapter)
-{
- struct rtl_priv *rtlpriv = adapter;
-
- if (rtlpriv->link_info.b_tx_busy_traffic)
- return true;
- else
- return false;
-}
-
-static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv =
- (struct rtl_priv *)btcoexist->adapter;
- u32 wifi_bw = BTC_WIFI_BW_HT20;
-
- if (halbtc_is_bt40(rtlpriv)){
- wifi_bw = BTC_WIFI_BW_HT40;
- } else {
- if(halbtc_legacy(rtlpriv))
- wifi_bw = BTC_WIFI_BW_LEGACY;
- else
- wifi_bw = BTC_WIFI_BW_HT20;
- }
- return wifi_bw;
-}
-
-static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_phy *rtlphy = &(rtlpriv->phy);
- u8 chnl = 1;
-
-
- if (rtlphy->current_channel != 0)
- chnl = rtlphy->current_channel;
- BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
- "halbtc_get_wifi_central_chnl:%d\n",chnl);
- return chnl;
-}
-
-static void halbtc_leave_lps(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv;
- struct rtl_ps_ctl *ppsc;
- bool ap_enable = false;
-
- rtlpriv = btcoexist->adapter;
- ppsc = rtl_psc(rtlpriv);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
- &ap_enable);
-
- if (ap_enable) {
- printk("halbtc_leave_lps()<--dont leave lps under AP mode\n");
- return;
- }
-
- btcoexist->bt_info.bt_ctrl_lps = true;
- btcoexist->bt_info.bt_lps_on = false;
-}
-
-static void halbtc_enter_lps(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv;
- struct rtl_ps_ctl *ppsc;
- bool ap_enable = false;
-
- rtlpriv = btcoexist->adapter;
- ppsc = rtl_psc(rtlpriv);
-
- btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
- &ap_enable);
-
- if (ap_enable) {
- printk("halbtc_enter_lps()<--dont enter lps under AP mode\n");
- return;
- }
-
- btcoexist->bt_info.bt_ctrl_lps = true;
- btcoexist->bt_info.bt_lps_on = false;
-}
-
-static void halbtc_normal_lps(struct btc_coexist *btcoexist)
-{
- if (btcoexist->bt_info.bt_ctrl_lps) {
- btcoexist->bt_info.bt_lps_on = false;
- btcoexist->bt_info.bt_ctrl_lps = false;
- }
-
-}
-
-static void halbtc_leave_low_power(void)
-{
-}
-
-static void halbtc_nomal_low_power(void)
-{
-}
-
-static void halbtc_disable_low_power(void)
-{
-}
-
-static void halbtc_aggregation_check(void)
-{
-}
-
-
-static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist)
-{
- return 0;
-}
-
-static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter)
-{
- struct rtl_priv *rtlpriv = adapter;
- s32 undecorated_smoothed_pwdb = 0;
-
- if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
- undecorated_smoothed_pwdb =
- rtlpriv->dm.undecorated_smoothed_pwdb;
- else /* associated entry pwdb */
- undecorated_smoothed_pwdb =
- rtlpriv->dm.undecorated_smoothed_pwdb;
- return undecorated_smoothed_pwdb;
-}
-
-static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_phy *rtlphy = &(rtlpriv->phy);
- struct rtl_mac *mac = rtl_mac(rtlpriv);
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- bool *bool_tmp = (bool*)out_buf;
- int *s32_tmp = (int*)out_buf;
- u32 *u32_tmp = (u32*)out_buf;
- u8 *u8_tmp = (u8*)out_buf;
- bool tmp = false;
-
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return false;
-
-
- switch (get_type){
- case BTC_GET_BL_HS_OPERATION:
- *bool_tmp = false;
- break;
- case BTC_GET_BL_HS_CONNECTING:
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_CONNECTED:
- if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
- tmp = true;
-
- *bool_tmp = tmp;
- break;
- case BTC_GET_BL_WIFI_BUSY:
- if(halbtc_is_wifi_busy(rtlpriv))
- *bool_tmp = true;
- else
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_SCAN:
- if (mac->act_scanning == true)
- *bool_tmp = true;
- else
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_LINK:
- if (mac->link_state == MAC80211_LINKING)
- *bool_tmp = true;
- else
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_ROAM: /*TODO*/
- if (mac->link_state == MAC80211_LINKING)
- *bool_tmp = true;
- else
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_4_WAY_PROGRESS: /*TODO*/
- *bool_tmp = false;
-
- break;
- case BTC_GET_BL_WIFI_UNDER_5G:
- *bool_tmp = false; /*TODO*/
-
- case BTC_GET_BL_WIFI_DHCP: /*TODO*/
- break;
- case BTC_GET_BL_WIFI_SOFTAP_IDLE:
- *bool_tmp = true;
- break;
- case BTC_GET_BL_WIFI_SOFTAP_LINKING:
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_IN_EARLY_SUSPEND:
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
- *bool_tmp = false;
- break;
- case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
- if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm)
- *bool_tmp = false;
- else
- *bool_tmp = true;
- break;
- case BTC_GET_BL_WIFI_UNDER_B_MODE:
- *bool_tmp = false; /*TODO*/
- break;
- case BTC_GET_BL_EXT_SWITCH:
- *bool_tmp = false;
- break;
- case BTC_GET_S4_WIFI_RSSI:
- *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
- break;
- case BTC_GET_S4_HS_RSSI: /*TODO*/
- *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
- break;
- case BTC_GET_U4_WIFI_BW:
- *u32_tmp = halbtc_get_wifi_bw(btcoexist);
- break;
- case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION:
- if (halbtc_is_wifi_uplink(rtlpriv))
- *u32_tmp = BTC_WIFI_TRAFFIC_TX;
- else
- *u32_tmp = BTC_WIFI_TRAFFIC_RX;
- break;
- case BTC_GET_U4_WIFI_FW_VER:
- *u32_tmp = rtlhal->fw_version;
- break;
- case BTC_GET_U4_BT_PATCH_VER:
- *u32_tmp = halbtc_get_bt_patch_version(btcoexist);
- break;
- case BTC_GET_U1_WIFI_DOT11_CHNL:
- *u8_tmp = rtlphy->current_channel;
- break;
- case BTC_GET_U1_WIFI_CENTRAL_CHNL:
- *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist);
- break;
- case BTC_GET_U1_WIFI_HS_CHNL:
- *u8_tmp = 1;/* BT_OperateChnl(rtlpriv); */
- break;
- case BTC_GET_U1_MAC_PHY_MODE:
- *u8_tmp = BTC_MP_UNKNOWN;
- break;
- case BTC_GET_U1_AP_NUM:
- /* driver don't know AP num in Linux,
- * So, the return value here is not right */
- *u8_tmp = 1;/* pDefMgntInfo->NumBssDesc4Query; */
- break;
-
- /************* 1Ant **************/
- case BTC_GET_U1_LPS_MODE:
- *u8_tmp = btcoexist->pwr_mode_val[0];
- break;
-
- default:
- break;
- }
-
- return true;
-}
-
-static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
- bool *bool_tmp = (bool *)in_buf;
- u8 *u8_tmp = (u8 *)in_buf;
- u32 *u32_tmp = (u32 *)in_buf;
-
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return false;
-
- switch (set_type) {
- /* set some bool type variables. */
- case BTC_SET_BL_BT_DISABLE:
- btcoexist->bt_info.bt_disabled = *bool_tmp;
- break;
- case BTC_SET_BL_BT_TRAFFIC_BUSY:
- btcoexist->bt_info.bt_busy = *bool_tmp;
- break;
- case BTC_SET_BL_BT_LIMITED_DIG:
- btcoexist->bt_info.limited_dig = *bool_tmp;
- break;
- case BTC_SET_BL_FORCE_TO_ROAM:
- btcoexist->bt_info.force_to_roam = *bool_tmp;
- break;
- case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
- btcoexist->bt_info.reject_agg_pkt = *bool_tmp;
- break;
- case BTC_SET_BL_BT_CTRL_AGG_SIZE:
- btcoexist->bt_info.b_bt_ctrl_buf_size = *bool_tmp;
- break;
- case BTC_SET_BL_INC_SCAN_DEV_NUM:
- btcoexist->bt_info.increase_scan_dev_num = *bool_tmp;
- break;
- /* set some u1Byte type variables. */
- case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
- btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp;
- break;
- case BTC_SET_U1_AGG_BUF_SIZE:
- btcoexist->bt_info.agg_buf_size = *u8_tmp;
- break;
- /* the following are some action which will be triggered */
- case BTC_SET_ACT_GET_BT_RSSI:
- /*BTHCI_SendGetBtRssiEvent(rtlpriv);*/
- break;
- case BTC_SET_ACT_AGGREGATE_CTRL:
- halbtc_aggregation_check();
- break;
-
- /* 1Ant */
- case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
- btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp;
- break;
- case BTC_SET_UI_SCAN_SIG_COMPENSATION:
- /* rtlpriv->mlmepriv.scan_compensation = *u8_tmp; */
- break;
- case BTC_SET_U1_1ANT_LPS:
- btcoexist->bt_info.lps_1ant = *u8_tmp;
- break;
- case BTC_SET_U1_1ANT_RPWM:
- btcoexist->bt_info.rpwm_1ant = *u8_tmp;
- break;
- /* the following are some action which will be triggered */
- case BTC_SET_ACT_LEAVE_LPS:
- halbtc_leave_lps(btcoexist);
- break;
- case BTC_SET_ACT_ENTER_LPS:
- halbtc_enter_lps(btcoexist);
- break;
- case BTC_SET_ACT_NORMAL_LPS:
- halbtc_normal_lps(btcoexist);
- break;
- case BTC_SET_ACT_DISABLE_LOW_POWER:
- halbtc_disable_low_power();
- break;
- case BTC_SET_ACT_UPDATE_ra_mask:
- btcoexist->bt_info.ra_mask = *u32_tmp;
- break;
- case BTC_SET_ACT_SEND_MIMO_PS:
- break;
- case BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT:
- btcoexist->bt_info.force_exec_pwr_cmd_cnt++;
- break;
- case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/
- break;
- case BTC_SET_ACT_CTRL_BT_COEX:
- break;
- default:
- break;
- }
-
- return true;
-}
-
-static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist)
-{
-}
-
-static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist)
-{
-}
-
-static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist)
-{
-}
-
-static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist)
-{
-}
-
-/************************************************************
- * IO related function
- ************************************************************/
-static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- return rtl_read_byte(rtlpriv, reg_addr);
-}
-
-
-static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- return rtl_read_word(rtlpriv, reg_addr);
-}
-
-
-static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- return rtl_read_dword(rtlpriv, reg_addr);
-}
-
-
-static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u8 data)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- rtl_write_byte(rtlpriv, reg_addr, data);
-}
-
-static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr,
- u8 bit_mask, u8 data)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- u8 original_value, bit_shift = 0;
- u8 i;
-
- if (bit_mask != MASKDWORD) {/*if not "double word" write*/
- original_value = rtl_read_byte(rtlpriv, reg_addr);
- for (i=0; i<=7; i++) {
- if((bit_mask>>i)&0x1)
- break;
- }
- bit_shift = i;
- data = (original_value & (~bit_mask)) |
- ((data << bit_shift) & bit_mask);
- }
- rtl_write_byte(rtlpriv, reg_addr, data);
-}
-
-
-static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- rtl_write_word(rtlpriv, reg_addr, data);
-}
-
-
-static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data)
-{
- struct btc_coexist *btcoexist =
- (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- rtl_write_dword(rtlpriv, reg_addr, data);
-}
-
-static void halbtc_set_bbreg(void *bt_context, u32 reg_addr,
- u32 bit_mask, u32 data)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data);
-}
-
-
-static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- return rtl_get_bbreg(rtlpriv->mac80211.hw,reg_addr, bit_mask);
-}
-
-
-static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr,
- u32 bit_mask, u32 data)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data);
-}
-
-
-static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path,
- u32 reg_addr, u32 bit_mask)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask);
-}
-
-
-static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id,
- u32 cmd_len, u8 *cmd_buf)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- struct rtl_priv *rtlpriv = btcoexist->adapter;
-
- rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id,
- cmd_len, cmd_buf);
-}
-
-static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type)
-{
- struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context;
- switch (disp_type) {
- case BTC_DBG_DISP_COEX_STATISTICS:
- halbtc_display_coex_statistics(btcoexist);
- break;
- case BTC_DBG_DISP_BT_LINK_INFO:
- halbtc_display_bt_link_info(btcoexist);
- break;
- case BTC_DBG_DISP_BT_FW_VER:
- halbtc_display_bt_fw_info(btcoexist);
- break;
- case BTC_DBG_DISP_FW_PWR_MODE_CMD:
- halbtc_display_fw_pwr_mode_cmd(btcoexist);
- break;
- default:
- break;
- }
-}
-
-/*****************************************************************
- * Extern functions called by other module
- *****************************************************************/
-bool exhalbtc_initlize_variables(struct rtl_priv *adapter)
-{
- struct btc_coexist *btcoexist = &gl_bt_coexist;
-
- btcoexist->statistics.cnt_bind++;
-
- halbtc_dbg_init();
-
- if (btcoexist->binded)
- return false;
- else
- btcoexist->binded = true;
-
- btcoexist->chip_interface = BTC_INTF_UNKNOWN;
-
- if (NULL == btcoexist->adapter)
- btcoexist->adapter = adapter;
-
- btcoexist->stack_info.profile_notified = false;
-
- btcoexist->btc_read_1byte = halbtc_read_1byte;
- btcoexist->btc_write_1byte = halbtc_write_1byte;
- btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte;
- btcoexist->btc_read_2byte = halbtc_read_2byte;
- btcoexist->btc_write_2byte = halbtc_write_2byte;
- btcoexist->btc_read_4byte = halbtc_read_4byte;
- btcoexist->btc_write_4byte = halbtc_write_4byte;
-
- btcoexist->btc_set_bb_reg = halbtc_set_bbreg;
- btcoexist->btc_get_bb_reg = halbtc_get_bbreg;
-
- btcoexist->btc_set_rf_reg = halbtc_set_rfreg;
- btcoexist->btc_get_rf_reg = halbtc_get_rfreg;
-
- btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd;
- btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg;
-
- btcoexist->btc_get = halbtc_get;
- btcoexist->btc_set = halbtc_set;
-
- btcoexist->cli_buf = &btc_dbg_buf[0];
-
- btcoexist->bt_info.b_bt_ctrl_buf_size = false;
- btcoexist->bt_info.agg_buf_size = 5;
-
- btcoexist->bt_info.increase_scan_dev_num = false;
- return true;
-}
-
-void exhalbtc_init_hw_config(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- btcoexist->statistics.cnt_init_hw_config++;
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_init_hwconfig(btcoexist);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_init_hwconfig(btcoexist);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_init_hwconfig(btcoexist);
- }
-
-}
-
-void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- btcoexist->statistics.cnt_init_coex_dm++;
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_init_coex_dm(btcoexist);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_init_coex_dm(btcoexist);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_init_coex_dm(btcoexist);
- }
-
- btcoexist->initilized = true;
-}
-
-void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- u8 ips_type;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_ips_notify++;
- if (btcoexist->manual_control)
- return;
-
- if (ERFOFF == type)
- ips_type = BTC_IPS_ENTER;
- else
- ips_type = BTC_IPS_LEAVE;
-
- halbtc_leave_low_power();
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_ips_notify(btcoexist, ips_type);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_ips_notify(btcoexist, ips_type);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_ips_notify(btcoexist, ips_type);
- }
-
- halbtc_nomal_low_power();
-}
-
-void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- u8 lps_type;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_lps_notify++;
- if (btcoexist->manual_control)
- return;
-
- if (EACTIVE == type)
- lps_type = BTC_LPS_DISABLE;
- else
- lps_type = BTC_LPS_ENABLE;
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_lps_notify(btcoexist, lps_type);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_lps_notify(btcoexist, lps_type);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_lps_notify(btcoexist, lps_type);
- }
-}
-
-void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- u8 scan_type;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_scan_notify++;
- if (btcoexist->manual_control)
- return;
-
- if (type)
- scan_type = BTC_SCAN_START;
- else
- scan_type = BTC_SCAN_FINISH;
-
- halbtc_leave_low_power();
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_scan_notify(btcoexist, scan_type);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_scan_notify(btcoexist, scan_type);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_scan_notify(btcoexist, scan_type);
- }
-
- halbtc_nomal_low_power();
-}
-
-void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- u8 asso_type;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_connect_notify++;
- if (btcoexist->manual_control)
- return;
-
- if (action)
- asso_type = BTC_ASSOCIATE_START;
- else
- asso_type = BTC_ASSOCIATE_FINISH;
-
- halbtc_leave_low_power();
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_connect_notify(btcoexist, asso_type);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_connect_notify(btcoexist, asso_type);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_connect_notify(btcoexist, asso_type);
- }
-
- halbtc_nomal_low_power();
-}
-
-void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
- enum rt_media_status media_status)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- u8 status;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_media_status_notify++;
- if (btcoexist->manual_control)
- return;
-
- if (RT_MEDIA_CONNECT == media_status)
- status = BTC_MEDIA_CONNECT;
- else
- status = BTC_MEDIA_DISCONNECT;
-
- halbtc_leave_low_power();
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_media_status_notify(btcoexist, status);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_media_status_notify(btcoexist, status);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_media_status_notify(btcoexist, status);
- }
-
- halbtc_nomal_low_power();
-}
-
-void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type)
-{
- u8 packet_type;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_special_packet_notify++;
- if (btcoexist->manual_control)
- return;
-
- /*if(PACKET_DHCP == pkt_type)*/
- packet_type = BTC_PACKET_DHCP;
- /*else if(PACKET_EAPOL == pkt_type)
- packet_type = BTC_PACKET_EAPOL;
- else
- packet_type = BTC_PACKET_UNKNOWN;*/
-
- halbtc_leave_low_power();
-
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_special_packet_notify(btcoexist,
- packet_type);
- else if (btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_special_packet_notify(btcoexist,
- packet_type);
-
- halbtc_nomal_low_power();
-}
-
-void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist,
- u8 *tmp_buf, u8 length)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_bt_info_notify++;
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_bt_info_notify(btcoexist, tmp_buf, length);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_bt_info_notify(btcoexist, tmp_buf, length);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- // ex_halbtc8192e2ant_bt_info_notify(btcoexist, tmp_buf, length);
- }
-}
-
-void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type)
-{
- u8 stack_op_type;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_stack_operation_notify++;
- if (btcoexist->manual_control)
- return;
-
- stack_op_type = BTC_STACK_OP_NONE;
-}
-
-void exhalbtc_halt_notify(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_halt_notify(btcoexist);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_halt_notify(btcoexist);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_halt_notify(btcoexist);
- }
-}
-
-void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
-{
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-}
-
-void exhalbtc_periodical(struct btc_coexist *btcoexist)
-{
- struct rtl_priv *rtlpriv = btcoexist->adapter;
- struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_periodical++;
-
- halbtc_leave_low_power();
-
- if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) {
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_periodical(btcoexist);
- else if(btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_periodical(btcoexist);
- } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) {
- ex_halbtc8192e2ant_periodical(btcoexist);
- }
-
- halbtc_nomal_low_power();
-}
-
-void exhalbtc_dbg_control(struct btc_coexist *btcoexist,
- u8 code, u8 len, u8 *data)
-{
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
- btcoexist->statistics.cnt_dbg_ctrl++;
-}
-
-void exhalbtc_stack_update_profile_info(void)
-{
-}
-
-void exhalbtc_update_min_bt_rssi(char bt_rssi)
-{
- struct btc_coexist *btcoexist = &gl_bt_coexist;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- btcoexist->stack_info.min_bt_rssi = bt_rssi;
-}
-
-
-void exhalbtc_set_hci_version(u16 hci_version)
-{
- struct btc_coexist *btcoexist = &gl_bt_coexist;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- btcoexist->stack_info.hci_version = hci_version;
-}
-
-void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version)
-{
- struct btc_coexist *btcoexist = &gl_bt_coexist;
-
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- btcoexist->bt_info.bt_real_fw_ver = bt_patch_version;
- btcoexist->bt_info.bt_hci_ver = bt_hci_version;
-}
-
-void exhalbtc_set_bt_exist(bool bt_exist)
-{
- gl_bt_coexist.board_info.bt_exist = bt_exist;
-}
-
-void exhalbtc_set_chip_type(u8 chip_type)
-{
- switch (chip_type) {
- default:
- case BT_2WIRE:
- case BT_ISSC_3WIRE:
- case BT_ACCEL:
- case BT_RTL8756:
- gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
- break;
- case BT_CSR_BC4:
- gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
- break;
- case BT_CSR_BC8:
- gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
- break;
- case BT_RTL8723A:
- gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
- break;
- case BT_RTL8821A:
- gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
- break;
- case BT_RTL8723B:
- gl_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
- break;
- }
-}
-
-void exhalbtc_set_ant_num(u8 type, u8 ant_num)
-{
- if (BT_COEX_ANT_TYPE_PG == type) {
- gl_bt_coexist.board_info.pg_ant_num = ant_num;
- gl_bt_coexist.board_info.btdm_ant_num = ant_num;
- } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
- gl_bt_coexist.board_info.btdm_ant_num = ant_num;
- }
-}
-
-void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist)
-{
- if (!halbtc_is_bt_coexist_available(btcoexist))
- return;
-
- if (btcoexist->board_info.btdm_ant_num == 2)
- ex_halbtc8723b2ant_display_coex_info(btcoexist);
- else if (btcoexist->board_info.btdm_ant_num == 1)
- ex_halbtc8723b1ant_display_coex_info(btcoexist);
-}
-
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.h b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.h
deleted file mode 100644
index fd233cc85a5b..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.h
+++ /dev/null
@@ -1,549 +0,0 @@
-#ifndef __HALBTC_OUT_SRC_H__
-#define __HALBTC_OUT_SRC_H__
-
-#include "../wifi.h"
-
-#define NORMAL_EXEC false
-#define FORCE_EXEC true
-
-#define BTC_RF_A RF90_PATH_A
-#define BTC_RF_B RF90_PATH_B
-#define BTC_RF_C RF90_PATH_C
-#define BTC_RF_D RF90_PATH_D
-
-#define BTC_SMSP SINGLEMAC_SINGLEPHY
-#define BTC_DMDP DUALMAC_DUALPHY
-#define BTC_DMSP DUALMAC_SINGLEPHY
-#define BTC_MP_UNKNOWN 0xff
-
-#define IN
-#define OUT
-
-#define BT_TMP_BUF_SIZE 100
-
-#define BT_COEX_ANT_TYPE_PG 0
-#define BT_COEX_ANT_TYPE_ANTDIV 1
-#define BT_COEX_ANT_TYPE_DETECTED 2
-
-#define BTC_MIMO_PS_STATIC 0
-#define BTC_MIMO_PS_DYNAMIC 1
-
-#define BTC_RATE_DISABLE 0
-#define BTC_RATE_ENABLE 1
-
-/* single Antenna definition */
-#define BTC_ANT_PATH_WIFI 0
-#define BTC_ANT_PATH_BT 1
-#define BTC_ANT_PATH_PTA 2
-/* dual Antenna definition */
-#define BTC_ANT_WIFI_AT_MAIN 0
-#define BTC_ANT_WIFI_AT_AUX 1
-/* coupler Antenna definition */
-#define BTC_ANT_WIFI_AT_CPL_MAIN 0
-#define BTC_ANT_WIFI_AT_CPL_AUX 1
-
-enum btc_chip_interface{
- BTC_INTF_UNKNOWN = 0,
- BTC_INTF_PCI = 1,
- BTC_INTF_USB = 2,
- BTC_INTF_SDIO = 3,
- BTC_INTF_GSPI = 4,
- BTC_INTF_MAX
-};
-
-enum btc_chip_type{
- BTC_CHIP_UNDEF = 0,
- BTC_CHIP_CSR_BC4 = 1,
- BTC_CHIP_CSR_BC8 = 2,
- BTC_CHIP_RTL8723A = 3,
- BTC_CHIP_RTL8821 = 4,
- BTC_CHIP_RTL8723B = 5,
- BTC_CHIP_MAX
-};
-
-enum btc_msg_type{
- BTC_MSG_INTERFACE = 0x0,
- BTC_MSG_ALGORITHM = 0x1,
- BTC_MSG_MAX
-};
-
-extern u32 btc_dbg_type[];
-
-/* following is for BTC_MSG_INTERFACE */
-#define INTF_INIT BIT0
-#define INTF_NOTIFY BIT2
-
-/* following is for BTC_ALGORITHM */
-#define ALGO_BT_RSSI_STATE BIT0
-#define ALGO_WIFI_RSSI_STATE BIT1
-#define ALGO_BT_MONITOR BIT2
-#define ALGO_TRACE BIT3
-#define ALGO_TRACE_FW BIT4
-#define ALGO_TRACE_FW_DETAIL BIT5
-#define ALGO_TRACE_FW_EXEC BIT6
-#define ALGO_TRACE_SW BIT7
-#define ALGO_TRACE_SW_DETAIL BIT8
-#define ALGO_TRACE_SW_EXEC BIT9
-
-
-
-#define CL_SPRINTF snprintf
-#define CL_PRINTF(buf) printk("%s", buf)
-
-#define BTC_PRINT(dbgtype, dbgflag, printstr, ...) \
- do { \
- if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) {\
- printk(printstr, ##__VA_ARGS__); \
- } \
- } while(0)
-
-#define BTC_PRINT_F(dbgtype, dbgflag, printstr, ...) \
- do { \
- if (unlikely(btc_dbg_type[dbgtype] & dbgflag)) {\
- printk(KERN_DEBUG "%s: ", __func__); \
- printk(printstr, ##__VA_ARGS__); \
- } \
- } while(0)
-
-#define BTC_PRINT_ADDR(dbgtype, dbgflag, printstr, _ptr) \
- do { \
- if(unlikely(btc_dbg_type[dbgtype] & dbgflag)) { \
- int __i; \
- u8* __ptr = (u8*)_Ptr; \
- printk printstr; \
- for( __i = 0; __i < 6; __i++ ) \
- printk("%02X%s", __ptr[__i], (__i==5)?"":"-");\
- printk(KERN_DEBUG "\n"); \
- }\
- } while(0)
-
-#define BTC_PRINT_DATA(dbgtype, dbgflag, _titlestring, _hexdata, _hexdatalen) \
- do { \
- if(unlikely(btc_dbg_type[dbgtype] & dbgflag) ) { \
- int __i; \
- u8 *__ptr = (u8*)_hexdata; \
- printk(_titlestring); \
- for( __i = 0; __i < (int)_hexdatalen; __i++ ) { \
- printk("%02X%s", __ptr[__i], (((__i + 1) % 4) \
- == 0)?" ":" ");\
- if (((__i + 1) % 16) == 0) \
- printk("\n"); \
- } \
- printk(KERN_DEBUG "\n"); \
- } \
- } while(0)
-
-
-#define BTC_RSSI_HIGH(_rssi_) \
- ((_rssi_==BTC_RSSI_STATE_HIGH || _rssi_==BTC_RSSI_STATE_STAY_HIGH) ? \
- true : false)
-
-#define BTC_RSSI_MEDIUM(_rssi_) \
- ((_rssi_==BTC_RSSI_STATE_MEDIUM || _rssi_==BTC_RSSI_STATE_STAY_MEDIUM) \
- ? true : false)
-
-#define BTC_RSSI_LOW(_rssi_) \
- ((_rssi_==BTC_RSSI_STATE_LOW || _rssi_==BTC_RSSI_STATE_STAY_LOW) ? \
- true : false)
-
-
-enum btc_power_save_type {
- BTC_PS_WIFI_NATIVE = 0,
- BTC_PS_LPS_ON = 1,
- BTC_PS_LPS_OFF = 2,
- BTC_PS_LPS_MAX
-};
-
-struct btc_board_info {
- /* The following is some board information */
- u8 bt_chip_type;
- u8 pg_ant_num; /* pg ant number */
- u8 btdm_ant_num; /* ant number for btdm */
- u8 btdm_ant_pos;
- bool bt_exist;
-};
-
-enum btc_dbg_opcode{
- BTC_DBG_SET_COEX_NORMAL = 0x0,
- BTC_DBG_SET_COEX_WIFI_ONLY = 0x1,
- BTC_DBG_SET_COEX_BT_ONLY = 0x2,
- BTC_DBG_MAX
-};
-
-enum btc_rssi_state{
- BTC_RSSI_STATE_HIGH = 0x0,
- BTC_RSSI_STATE_MEDIUM = 0x1,
- BTC_RSSI_STATE_LOW = 0x2,
- BTC_RSSI_STATE_STAY_HIGH = 0x3,
- BTC_RSSI_STATE_STAY_MEDIUM = 0x4,
- BTC_RSSI_STATE_STAY_LOW = 0x5,
- BTC_RSSI_MAX
-};
-
-enum btc_wifi_role{
- BTC_ROLE_STATION = 0x0,
- BTC_ROLE_AP = 0x1,
- BTC_ROLE_IBSS = 0x2,
- BTC_ROLE_HS_MODE = 0x3,
- BTC_ROLE_MAX
-};
-
-enum btc_wifi_bw_mode{
- BTC_WIFI_BW_LEGACY = 0x0,
- BTC_WIFI_BW_HT20 = 0x1,
- BTC_WIFI_BW_HT40 = 0x2,
- BTC_WIFI_BW_MAX
-};
-
-enum btc_wifi_traffic_dir{
- BTC_WIFI_TRAFFIC_TX = 0x0,
- BTC_WIFI_TRAFFIC_RX = 0x1,
- BTC_WIFI_TRAFFIC_MAX
-};
-
-enum btc_wifi_pnp{
- BTC_WIFI_PNP_WAKE_UP = 0x0,
- BTC_WIFI_PNP_SLEEP = 0x1,
- BTC_WIFI_PNP_MAX
-};
-
-
-enum btc_get_type{
- /* type bool */
- BTC_GET_BL_HS_OPERATION,
- BTC_GET_BL_HS_CONNECTING,
- BTC_GET_BL_WIFI_CONNECTED,
- BTC_GET_BL_WIFI_BUSY,
- BTC_GET_BL_WIFI_SCAN,
- BTC_GET_BL_WIFI_LINK,
- BTC_GET_BL_WIFI_DHCP,
- BTC_GET_BL_WIFI_SOFTAP_IDLE,
- BTC_GET_BL_WIFI_SOFTAP_LINKING,
- BTC_GET_BL_WIFI_IN_EARLY_SUSPEND,
- BTC_GET_BL_WIFI_ROAM,
- BTC_GET_BL_WIFI_4_WAY_PROGRESS,
- BTC_GET_BL_WIFI_UNDER_5G,
- BTC_GET_BL_WIFI_AP_MODE_ENABLE,
- BTC_GET_BL_WIFI_ENABLE_ENCRYPTION,
- BTC_GET_BL_WIFI_UNDER_B_MODE,
- BTC_GET_BL_EXT_SWITCH,
-
- /* type s4Byte */
- BTC_GET_S4_WIFI_RSSI,
- BTC_GET_S4_HS_RSSI,
-
- /* type u32 */
- BTC_GET_U4_WIFI_BW,
- BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
- BTC_GET_U4_WIFI_FW_VER,
- BTC_GET_U4_BT_PATCH_VER,
-
- /* type u1Byte */
- BTC_GET_U1_WIFI_DOT11_CHNL,
- BTC_GET_U1_WIFI_CENTRAL_CHNL,
- BTC_GET_U1_WIFI_HS_CHNL,
- BTC_GET_U1_MAC_PHY_MODE,
- BTC_GET_U1_AP_NUM,
-
- /* for 1Ant */
- BTC_GET_U1_LPS_MODE,
- BTC_GET_BL_BT_SCO_BUSY,
-
- /* for test mode */
- BTC_GET_DRIVER_TEST_CFG,
-#if 0
- BTC_GET_U1_LPS,
- BTC_GET_U1_RPWM,
-#endif
- BTC_GET_MAX
-};
-
-
-enum btc_set_type{
- /* type bool */
- BTC_SET_BL_BT_DISABLE,
- BTC_SET_BL_BT_TRAFFIC_BUSY,
- BTC_SET_BL_BT_LIMITED_DIG,
- BTC_SET_BL_FORCE_TO_ROAM,
- BTC_SET_BL_TO_REJ_AP_AGG_PKT,
- BTC_SET_BL_BT_CTRL_AGG_SIZE,
- BTC_SET_BL_INC_SCAN_DEV_NUM,
-
- /* type u1Byte */
- BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON,
- BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE,
- BTC_SET_UI_SCAN_SIG_COMPENSATION,
- BTC_SET_U1_AGG_BUF_SIZE,
-
- /* type trigger some action */
- BTC_SET_ACT_GET_BT_RSSI,
- BTC_SET_ACT_AGGREGATE_CTRL,
-
- /********* for 1Ant **********/
- /* type bool */
- BTC_SET_BL_BT_SCO_BUSY,
- /* type u1Byte */
- BTC_SET_U1_1ANT_LPS,
- BTC_SET_U1_1ANT_RPWM,
- /* type trigger some action */
- BTC_SET_ACT_LEAVE_LPS,
- BTC_SET_ACT_ENTER_LPS,
- BTC_SET_ACT_NORMAL_LPS,
- BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT,
- BTC_SET_ACT_DISABLE_LOW_POWER,
- BTC_SET_ACT_UPDATE_ra_mask,
- BTC_SET_ACT_SEND_MIMO_PS,
- /* BT Coex related */
- BTC_SET_ACT_CTRL_BT_INFO,
- BTC_SET_ACT_CTRL_BT_COEX,
- /***************************/
- BTC_SET_MAX
-};
-
-enum btc_dbg_disp_type{
- BTC_DBG_DISP_COEX_STATISTICS = 0x0,
- BTC_DBG_DISP_BT_LINK_INFO = 0x1,
- BTC_DBG_DISP_BT_FW_VER = 0x2,
- BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x3,
- BTC_DBG_DISP_MAX
-};
-
-enum btc_notify_type_ips{
- BTC_IPS_LEAVE = 0x0,
- BTC_IPS_ENTER = 0x1,
- BTC_IPS_MAX
-};
-
-enum btc_notify_type_lps{
- BTC_LPS_DISABLE = 0x0,
- BTC_LPS_ENABLE = 0x1,
- BTC_LPS_MAX
-};
-
-enum btc_notify_type_scan{
- BTC_SCAN_FINISH = 0x0,
- BTC_SCAN_START = 0x1,
- BTC_SCAN_MAX
-};
-
-enum btc_notify_type_associate{
- BTC_ASSOCIATE_FINISH = 0x0,
- BTC_ASSOCIATE_START = 0x1,
- BTC_ASSOCIATE_MAX
-};
-
-enum btc_notify_type_media_status{
- BTC_MEDIA_DISCONNECT = 0x0,
- BTC_MEDIA_CONNECT = 0x1,
- BTC_MEDIA_MAX
-};
-
-enum btc_notify_type_special_packet{
- BTC_PACKET_UNKNOWN = 0x0,
- BTC_PACKET_DHCP = 0x1,
- BTC_PACKET_ARP = 0x2,
- BTC_PACKET_EAPOL = 0x3,
- BTC_PACKET_MAX
-};
-
-enum btc_notify_type_stack_operation{
- BTC_STACK_OP_NONE = 0x0,
- BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1,
- BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2,
- BTC_STACK_OP_MAX
-};
-
-
-typedef u8 (*bfp_btc_r1)(void *btc_context, u32 reg_addr);
-
-typedef u16 (*bfp_btc_r2)(void *btc_context, u32 reg_addr);
-
-typedef u32 (*bfp_btc_r4)(void *btc_context, u32 reg_addr);
-
-typedef void (*bfp_btc_w1)(void *btc_context, u32 reg_addr, u8 data);
-
-typedef void (*bfp_btc_w1_bit_mak)(void *btc_context, u32 reg_addr,
- u8 bit_mask, u8 data1b);
-
-typedef void (*bfp_btc_w2)(void *btc_context, u32 reg_addr, u16 data);
-
-typedef void (*bfp_btc_w4)(void *btc_context, u32 reg_addr, u32 data);
-
-typedef void (*bfp_btc_wr_1byte_bit_mask)(void *btc_context, u32 reg_addr,
- u8 bit_mask, u8 data);
-
-typedef void (*bfp_btc_set_bb_reg)(void *btc_context, u32 reg_addr,
- u32 bit_mask, u32 data);
-
-typedef u32 (*bfp_btc_get_bb_reg)(void *btc_context, u32 reg_addr,
- u32 bit_mask);
-
-typedef void (*bfp_btc_set_rf_reg)(void *btc_context, u8 rf_path, u32 reg_addr,
- u32 bit_mask, u32 data);
-
-typedef u32 (*bfp_btc_get_rf_reg)(void *btc_context, u8 rf_path,
- u32 reg_addr, u32 bit_mask);
-
-typedef void (*bfp_btc_fill_h2c)(void *btc_context, u8 element_id,
- u32 cmd_len, u8 *cmd_buffer);
-
-typedef bool (*bfp_btc_get)(void *btcoexist, u8 get_type, void *out_buf);
-
-typedef bool (*bfp_btc_set)(void *btcoexist, u8 set_type, void *in_buf);
-
-typedef void (*bfp_btc_disp_dbg_msg)(void *btcoexist, u8 disp_type);
-
-struct btc_bt_info {
- bool bt_disabled;
- u8 rssi_adjust_for_agc_table_on;
- u8 rssi_adjust_for_1ant_coex_type;
- bool bt_busy;
- u8 agg_buf_size;
- bool limited_dig;
- bool reject_agg_pkt;
- bool b_bt_ctrl_buf_size;
- bool increase_scan_dev_num;
- u16 bt_hci_ver;
- u16 bt_real_fw_ver;
- u8 bt_fw_ver;
-
- /* the following is for 1Ant solution */
- bool bt_ctrl_lps;
- bool bt_pwr_save_mode;
- bool bt_lps_on;
- bool force_to_roam;
- u8 force_exec_pwr_cmd_cnt;
- u8 lps_1ant;
- u8 rpwm_1ant;
- u32 ra_mask;
-};
-
-struct btc_stack_info {
- bool profile_notified;
- u16 hci_version; /* stack hci version */
- u8 num_of_link;
- bool bt_link_exist;
- bool sco_exist;
- bool acl_exist;
- bool a2dp_exist;
- bool hid_exist;
- u8 num_of_hid;
- bool pan_exist;
- bool unknown_acl_exist;
- char min_bt_rssi;
-};
-
-struct btc_statistics {
- u32 cnt_bind;
- u32 cnt_init_hw_config;
- u32 cnt_init_coex_dm;
- u32 cnt_ips_notify;
- u32 cnt_lps_notify;
- u32 cnt_scan_notify;
- u32 cnt_connect_notify;
- u32 cnt_media_status_notify;
- u32 cnt_special_packet_notify;
- u32 cnt_bt_info_notify;
- u32 cnt_periodical;
- u32 cnt_stack_operation_notify;
- u32 cnt_dbg_ctrl;
-};
-
-struct btc_bt_link_info {
- bool bt_link_exist;
- bool sco_exist;
- bool sco_only;
- bool a2dp_exist;
- bool a2dp_only;
- bool hid_exist;
- bool hid_only;
- bool pan_exist;
- bool pan_only;
-};
-
-enum btc_antenna_pos {
- BTC_ANTENNA_AT_MAIN_PORT = 0x1,
- BTC_ANTENNA_AT_AUX_PORT = 0x2,
-};
-
-struct btc_coexist {
- /* make sure only one adapter can bind the data context */
- bool binded;
- /* default adapter */
- void *adapter;
- struct btc_board_info board_info;
- /* some bt info referenced by non-bt module */
- struct btc_bt_info bt_info;
- struct btc_stack_info stack_info;
- enum btc_chip_interface chip_interface;
- struct btc_bt_link_info bt_link_info;
-
- bool initilized;
- bool stop_coex_dm;
- bool manual_control;
- u8 *cli_buf;
- struct btc_statistics statistics;
- u8 pwr_mode_val[10];
-
- /* function pointers
- * io related */
- bfp_btc_r1 btc_read_1byte;
- bfp_btc_w1 btc_write_1byte;
- bfp_btc_w1_bit_mak btc_write_1byte_bitmask;
- bfp_btc_r2 btc_read_2byte;
- bfp_btc_w2 btc_write_2byte;
- bfp_btc_r4 btc_read_4byte;
- bfp_btc_w4 btc_write_4byte;
-
- bfp_btc_set_bb_reg btc_set_bb_reg;
- bfp_btc_get_bb_reg btc_get_bb_reg;
-
-
- bfp_btc_set_rf_reg btc_set_rf_reg;
- bfp_btc_get_rf_reg btc_get_rf_reg;
-
-
- bfp_btc_fill_h2c btc_fill_h2c;
-
- bfp_btc_disp_dbg_msg btc_disp_dbg_msg;
-
- bfp_btc_get btc_get;
- bfp_btc_set btc_set;
-};
-
-bool halbtc_is_wifi_uplink(struct rtl_priv *adapter);
-
-
-extern struct btc_coexist gl_bt_coexist;
-
-bool exhalbtc_initlize_variables(struct rtl_priv* adapter);
-void exhalbtc_init_hw_config(struct btc_coexist *btcoexist);
-void exhalbtc_init_coex_dm(struct btc_coexist *btcoexist);
-void exhalbtc_ips_notify(struct btc_coexist *btcoexist, u8 type);
-void exhalbtc_lps_notify(struct btc_coexist *btcoexist, u8 type);
-void exhalbtc_scan_notify(struct btc_coexist *btcoexist, u8 type);
-void exhalbtc_connect_notify(struct btc_coexist *btcoexist, u8 action);
-void exhalbtc_mediastatus_notify(struct btc_coexist *btcoexist,
- enum rt_media_status media_status);
-void exhalbtc_special_packet_notify(struct btc_coexist *btcoexist, u8 pkt_type);
-void exhalbtc_bt_info_notify(struct btc_coexist *btcoexist, u8 *tmp_buf,
- u8 length);
-void exhalbtc_stack_operation_notify(struct btc_coexist *btcoexist, u8 type);
-void exhalbtc_halt_notify(struct btc_coexist *btcoexist);
-void exhalbtc_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state);
-void exhalbtc_periodical(struct btc_coexist *btcoexist);
-void exhalbtc_dbg_control(struct btc_coexist *btcoexist, u8 code, u8 len,
- u8 *data);
-void exhalbtc_stack_update_profile_info(void);
-void exhalbtc_set_hci_version(u16 hci_version);
-void exhalbtc_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version);
-void exhalbtc_update_min_bt_rssi(char bt_rssi);
-void exhalbtc_set_bt_exist(bool bt_exist);
-void exhalbtc_set_chip_type(u8 chip_type);
-void exhalbtc_set_ant_num(u8 type, u8 ant_num);
-void exhalbtc_display_bt_coex_info(struct btc_coexist *btcoexist);
-void exhalbtc_signal_compensation(struct btc_coexist *btcoexist,
- u8 *rssi_wifi, u8 *rssi_bt);
-void exhalbtc_lps_leave(struct btc_coexist *btcoexist);
-void exhalbtc_low_wifi_traffic_notify(struct btc_coexist *btcoexist);
-#endif
diff --git a/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c b/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c
deleted file mode 100644
index 6be0acafba5d..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2009-2010 Realtek Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
- * Hsinchu 300, Taiwan.
- *
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- *****************************************************************************/
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-
-#include "rtl_btc.h"
-#include "halbt_precomp.h"
-
-static struct rtl_btc_ops rtl_btc_operation = {
- .btc_init_variables = rtl_btc_init_variables,
- .btc_init_hal_vars = rtl_btc_init_hal_vars,
- .btc_init_hw_config = rtl_btc_init_hw_config,
- .btc_ips_notify = rtl_btc_ips_notify,
- .btc_scan_notify = rtl_btc_scan_notify,
- .btc_connect_notify = rtl_btc_connect_notify,
- .btc_mediastatus_notify = rtl_btc_mediastatus_notify,
- .btc_periodical = rtl_btc_periodical,
- .btc_halt_notify = rtl_btc_halt_notify,
- .btc_btinfo_notify = rtl_btc_btinfo_notify,
- .btc_is_limited_dig = rtl_btc_is_limited_dig,
- .btc_is_disable_edca_turbo = rtl_btc_is_disable_edca_turbo,
- .btc_is_bt_disabled = rtl_btc_is_bt_disabled,
-};
-
-
-void rtl_btc_init_variables(struct rtl_priv *rtlpriv)
-{
-
- exhalbtc_initlize_variables(rtlpriv);
-}
-
-void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv)
-{
- u8 ant_num;
- u8 bt_exist;
- u8 bt_type;
- ant_num = rtl_get_hwpg_ant_num(rtlpriv);
- RT_TRACE(COMP_INIT, DBG_DMESG, ("%s, antNum is %d\n", __func__, ant_num));
-
- bt_exist = rtl_get_hwpg_bt_exist(rtlpriv);
- RT_TRACE(COMP_INIT, DBG_DMESG, ("%s, bt_exist is %d\n", __func__, bt_exist));
- exhalbtc_set_bt_exist(bt_exist);
-
- bt_type = rtl_get_hwpg_bt_type(rtlpriv);
- RT_TRACE(COMP_INIT, DBG_DMESG, ("%s, bt_type is %d\n", __func__, bt_type));
- exhalbtc_set_chip_type(bt_type);
-
- exhalbtc_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num);
-
-}
-
-
-void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv)
-{
- exhalbtc_init_hw_config(&gl_bt_coexist);
- exhalbtc_init_coex_dm(&gl_bt_coexist);
-}
-
-
-void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type)
-{
- exhalbtc_ips_notify(&gl_bt_coexist, type);
-}
-
-
-void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype)
-{
- exhalbtc_scan_notify(&gl_bt_coexist, scantype);
-}
-
-
-void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action)
-{
- exhalbtc_connect_notify(&gl_bt_coexist, action);
-}
-
-
-void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv, enum rt_media_status mstatus)
-{
- exhalbtc_mediastatus_notify(&gl_bt_coexist, mstatus);
-}
-
-void rtl_btc_periodical(struct rtl_priv *rtlpriv)
-{
-// rtl_bt_dm_monitor();
- exhalbtc_periodical(&gl_bt_coexist);
-}
-
-void rtl_btc_halt_notify(void)
-{
- exhalbtc_halt_notify(&gl_bt_coexist);
-}
-
-void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 * tmp_buf, u8 length)
-{
- exhalbtc_bt_info_notify(&gl_bt_coexist, tmp_buf, length);
-}
-
-bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv)
-{
- return gl_bt_coexist.bt_info.limited_dig;
-}
-
-bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv)
-{
- bool bt_change_edca = false;
- u32 cur_edca_val;
- u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b;
- u32 edca_hs;
- u32 edca_addr = 0x504;
-
- cur_edca_val = rtl_read_dword(rtlpriv, edca_addr);
- if (halbtc_is_wifi_uplink(rtlpriv)){
- if (cur_edca_val != edca_bt_hs_uplink){
- edca_hs = edca_bt_hs_uplink;
- bt_change_edca = true;
- }
- }else{
- if (cur_edca_val != edca_bt_hs_downlink){
- edca_hs = edca_bt_hs_downlink;
- bt_change_edca = true;
- }
- }
-
- if(bt_change_edca)
- rtl_write_dword(rtlpriv, edca_addr, edca_hs);
-
- return true;
-}
-
-bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv)
-{
- if (gl_bt_coexist.bt_info.bt_disabled)
- return true;
- else
- return false;
-}
-
-struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
-{
- return &rtl_btc_operation;
-}
-//EXPORT_SYMBOL(rtl_btc_get_ops_pointer);
-
-u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv)
-{
- u8 num;
-
- if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2)
- num = 2;
- else
- num = 1;
-
- return num;
-}
-
-#if 0
-enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw)
-{
- struct rtl_priv *rtlpriv = rtl_priv(hw);
- struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
- enum rt_media_status m_status = RT_MEDIA_DISCONNECT;
-
- u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0;
-
- if(bibss || rtlpriv->mac80211.link_state >= MAC80211_LINKED) {
- m_status = RT_MEDIA_CONNECT;
- }
-
- return m_status;
-}
-#endif
-
-u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv)
-{
- return rtlpriv->btcoexist.btc_info.btcoexist;
-}
-
-u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv)
-{
- return rtlpriv->btcoexist.btc_info.bt_type;
-}
-
-
-#if 0
-
-MODULE_AUTHOR("Page He <page_he@realsil.com.cn>");
-MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
-MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
-
-static int __init rtl_btcoexist_module_init(void)
-{
-
- //printk("%s, rtlpriv->btc_ops.btc_init_variables addr is %p\n", __func__, rtlpriv->btc_ops.btc_init_variables);
-
- return 0;
-}
-
-static void __exit rtl_btcoexist_module_exit(void)
-{
- return;
-}
-
-module_init(rtl_btcoexist_module_init);
-module_exit(rtl_btcoexist_module_exit);
-
-#endif
-
diff --git a/drivers/staging/rtl8821ae/btcoexist/rtl_btc.h b/drivers/staging/rtl8821ae/btcoexist/rtl_btc.h
deleted file mode 100644
index 452fbf1e6d1e..000000000000
--- a/drivers/staging/rtl8821ae/btcoexist/rtl_btc.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2009-2010 Realtek Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
- * Hsinchu 300, Taiwan.
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- *****************************************************************************/
-
-#ifndef __RTL_BTC_H__
-#define __RTL_BTC_H__
-
-#include "halbt_precomp.h"
-
-
-
-void rtl_btc_init_variables(struct rtl_priv *rtlpriv);
-void rtl_btc_init_hal_vars(struct rtl_priv *rtlpriv);
-void rtl_btc_init_hw_config(struct rtl_priv *rtlpriv);
-void rtl_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type);
-void rtl_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype);
-void rtl_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action);
-void rtl_btc_mediastatus_notify(struct rtl_priv *rtlpriv, enum rt_media_status mstatus);
-void rtl_btc_periodical(struct rtl_priv *rtlpriv);
-void rtl_btc_halt_notify(void);
-void rtl_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 * tmpBuf, u8 length);
-bool rtl_btc_is_limited_dig(struct rtl_priv *rtlpriv);
-bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv);
-bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv);
-
-
-//extern struct rtl_btc_ops rtl_btc_operation;
-extern struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
-
-u8 rtl_get_hwpg_ant_num(struct rtl_priv *rtlpriv);
-u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
-u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
-//enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw);
-
-
-
-
-
-
-
-
-#endif