162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/* Copyright(c) 2012  Realtek Corporation.*/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/**************************************************************
562306a36Sopenharmony_ci * Description:
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * This file is for RTL8821A Co-exist mechanism
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * History
1062306a36Sopenharmony_ci * 2012/11/15 Cosa first check in.
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci **************************************************************/
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/**************************************************************
1562306a36Sopenharmony_ci * include files
1662306a36Sopenharmony_ci **************************************************************/
1762306a36Sopenharmony_ci#include "halbt_precomp.h"
1862306a36Sopenharmony_ci/**************************************************************
1962306a36Sopenharmony_ci * Global variables, these are static variables
2062306a36Sopenharmony_ci **************************************************************/
2162306a36Sopenharmony_cistatic struct coex_dm_8821a_1ant glcoex_dm_8821a_1ant;
2262306a36Sopenharmony_cistatic struct coex_dm_8821a_1ant *coex_dm = &glcoex_dm_8821a_1ant;
2362306a36Sopenharmony_cistatic struct coex_sta_8821a_1ant glcoex_sta_8821a_1ant;
2462306a36Sopenharmony_cistatic struct coex_sta_8821a_1ant *coex_sta = &glcoex_sta_8821a_1ant;
2562306a36Sopenharmony_cistatic void btc8821a1ant_act_bt_sco_hid_only_busy(struct btc_coexist *btcoexist,
2662306a36Sopenharmony_ci						  u8 wifi_status);
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cistatic const char *const glbt_info_src_8821a_1ant[] = {
2962306a36Sopenharmony_ci	  "BT Info[wifi fw]",
3062306a36Sopenharmony_ci	  "BT Info[bt rsp]",
3162306a36Sopenharmony_ci	  "BT Info[bt auto report]",
3262306a36Sopenharmony_ci};
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistatic u32 glcoex_ver_date_8821a_1ant = 20130816;
3562306a36Sopenharmony_cistatic u32 glcoex_ver_8821a_1ant = 0x41;
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci/**************************************************************
3862306a36Sopenharmony_ci * local function proto type if needed
3962306a36Sopenharmony_ci *
4062306a36Sopenharmony_ci * local function start with btc8821a1ant_
4162306a36Sopenharmony_ci **************************************************************/
4262306a36Sopenharmony_cistatic u8 btc8821a1ant_bt_rssi_state(struct btc_coexist *btcoexist,
4362306a36Sopenharmony_ci				     u8 level_num, u8 rssi_thresh,
4462306a36Sopenharmony_ci				     u8 rssi_thresh1)
4562306a36Sopenharmony_ci{
4662306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
4762306a36Sopenharmony_ci	long bt_rssi = 0;
4862306a36Sopenharmony_ci	u8 bt_rssi_state = coex_sta->pre_bt_rssi_state;
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci	bt_rssi = coex_sta->bt_rssi;
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci	if (level_num == 2) {
5362306a36Sopenharmony_ci		if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
5462306a36Sopenharmony_ci		    (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
5562306a36Sopenharmony_ci			if (bt_rssi >= (rssi_thresh +
5662306a36Sopenharmony_ci					BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) {
5762306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_HIGH;
5862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
5962306a36Sopenharmony_ci					"[BTCoex], BT Rssi state switch to High\n");
6062306a36Sopenharmony_ci			} else {
6162306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
6262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
6362306a36Sopenharmony_ci					"[BTCoex], BT Rssi state stay at Low\n");
6462306a36Sopenharmony_ci			}
6562306a36Sopenharmony_ci		} else {
6662306a36Sopenharmony_ci			if (bt_rssi < rssi_thresh) {
6762306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_LOW;
6862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
6962306a36Sopenharmony_ci					"[BTCoex], BT Rssi state switch to Low\n");
7062306a36Sopenharmony_ci			} else {
7162306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
7262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
7362306a36Sopenharmony_ci					"[BTCoex], BT Rssi state stay at High\n");
7462306a36Sopenharmony_ci			}
7562306a36Sopenharmony_ci		}
7662306a36Sopenharmony_ci	} else if (level_num == 3) {
7762306a36Sopenharmony_ci		if (rssi_thresh > rssi_thresh1) {
7862306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
7962306a36Sopenharmony_ci				"[BTCoex], BT Rssi thresh error!!\n");
8062306a36Sopenharmony_ci			return coex_sta->pre_bt_rssi_state;
8162306a36Sopenharmony_ci		}
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci		if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) ||
8462306a36Sopenharmony_ci		    (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) {
8562306a36Sopenharmony_ci			if (bt_rssi >= (rssi_thresh +
8662306a36Sopenharmony_ci					BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) {
8762306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
8862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
8962306a36Sopenharmony_ci					"[BTCoex], BT Rssi state switch to Medium\n");
9062306a36Sopenharmony_ci			} else {
9162306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_STAY_LOW;
9262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
9362306a36Sopenharmony_ci					"[BTCoex], BT Rssi state stay at Low\n");
9462306a36Sopenharmony_ci			}
9562306a36Sopenharmony_ci		} else if ((coex_sta->pre_bt_rssi_state ==
9662306a36Sopenharmony_ci			   BTC_RSSI_STATE_MEDIUM) ||
9762306a36Sopenharmony_ci			   (coex_sta->pre_bt_rssi_state ==
9862306a36Sopenharmony_ci			    BTC_RSSI_STATE_STAY_MEDIUM)) {
9962306a36Sopenharmony_ci			if (bt_rssi >= (rssi_thresh1 +
10062306a36Sopenharmony_ci					BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) {
10162306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_HIGH;
10262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
10362306a36Sopenharmony_ci					"[BTCoex], BT Rssi state switch to High\n");
10462306a36Sopenharmony_ci			} else if (bt_rssi < rssi_thresh) {
10562306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_LOW;
10662306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
10762306a36Sopenharmony_ci					"[BTCoex], BT Rssi state switch to Low\n");
10862306a36Sopenharmony_ci			} else {
10962306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
11062306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
11162306a36Sopenharmony_ci					"[BTCoex], BT Rssi state stay at Medium\n");
11262306a36Sopenharmony_ci			}
11362306a36Sopenharmony_ci		} else {
11462306a36Sopenharmony_ci			if (bt_rssi < rssi_thresh1) {
11562306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_MEDIUM;
11662306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
11762306a36Sopenharmony_ci					"[BTCoex], BT Rssi state switch to Medium\n");
11862306a36Sopenharmony_ci			} else {
11962306a36Sopenharmony_ci				bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
12062306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
12162306a36Sopenharmony_ci					"[BTCoex], BT Rssi state stay at High\n");
12262306a36Sopenharmony_ci			}
12362306a36Sopenharmony_ci		}
12462306a36Sopenharmony_ci	}
12562306a36Sopenharmony_ci	coex_sta->pre_bt_rssi_state = bt_rssi_state;
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci	return bt_rssi_state;
12862306a36Sopenharmony_ci}
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_cistatic u8 btc8821a1ant_wifi_rssi_state(struct btc_coexist *btcoexist,
13162306a36Sopenharmony_ci				       u8 index, u8 level_num, u8 rssi_thresh,
13262306a36Sopenharmony_ci				       u8 rssi_thresh1)
13362306a36Sopenharmony_ci{
13462306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
13562306a36Sopenharmony_ci	long	wifi_rssi = 0;
13662306a36Sopenharmony_ci	u8	wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index];
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci	if (level_num == 2) {
14162306a36Sopenharmony_ci		if ((coex_sta->pre_wifi_rssi_state[index] ==
14262306a36Sopenharmony_ci		     BTC_RSSI_STATE_LOW) ||
14362306a36Sopenharmony_ci		    (coex_sta->pre_wifi_rssi_state[index] ==
14462306a36Sopenharmony_ci		     BTC_RSSI_STATE_STAY_LOW)) {
14562306a36Sopenharmony_ci			if (wifi_rssi >= (rssi_thresh +
14662306a36Sopenharmony_ci					BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) {
14762306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_HIGH;
14862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
14962306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state switch to High\n");
15062306a36Sopenharmony_ci			} else {
15162306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
15262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
15362306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state stay at Low\n");
15462306a36Sopenharmony_ci			}
15562306a36Sopenharmony_ci		} else {
15662306a36Sopenharmony_ci			if (wifi_rssi < rssi_thresh) {
15762306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_LOW;
15862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
15962306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state switch to Low\n");
16062306a36Sopenharmony_ci			} else {
16162306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
16262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
16362306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state stay at High\n");
16462306a36Sopenharmony_ci			}
16562306a36Sopenharmony_ci		}
16662306a36Sopenharmony_ci	} else if (level_num == 3) {
16762306a36Sopenharmony_ci		if (rssi_thresh > rssi_thresh1) {
16862306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
16962306a36Sopenharmony_ci				"[BTCoex], wifi RSSI thresh error!!\n");
17062306a36Sopenharmony_ci			return coex_sta->pre_wifi_rssi_state[index];
17162306a36Sopenharmony_ci		}
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci		if ((coex_sta->pre_wifi_rssi_state[index] ==
17462306a36Sopenharmony_ci		     BTC_RSSI_STATE_LOW) ||
17562306a36Sopenharmony_ci		    (coex_sta->pre_wifi_rssi_state[index] ==
17662306a36Sopenharmony_ci		     BTC_RSSI_STATE_STAY_LOW)) {
17762306a36Sopenharmony_ci			if (wifi_rssi >= (rssi_thresh +
17862306a36Sopenharmony_ci					BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) {
17962306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
18062306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
18162306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state switch to Medium\n");
18262306a36Sopenharmony_ci			} else {
18362306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW;
18462306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
18562306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state stay at Low\n");
18662306a36Sopenharmony_ci			}
18762306a36Sopenharmony_ci		} else if ((coex_sta->pre_wifi_rssi_state[index] ==
18862306a36Sopenharmony_ci			BTC_RSSI_STATE_MEDIUM) ||
18962306a36Sopenharmony_ci			(coex_sta->pre_wifi_rssi_state[index] ==
19062306a36Sopenharmony_ci			BTC_RSSI_STATE_STAY_MEDIUM)) {
19162306a36Sopenharmony_ci			if (wifi_rssi >= (rssi_thresh1 +
19262306a36Sopenharmony_ci					BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) {
19362306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_HIGH;
19462306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
19562306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state switch to High\n");
19662306a36Sopenharmony_ci			} else if (wifi_rssi < rssi_thresh) {
19762306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_LOW;
19862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
19962306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state switch to Low\n");
20062306a36Sopenharmony_ci			} else {
20162306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM;
20262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
20362306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state stay at Medium\n");
20462306a36Sopenharmony_ci			}
20562306a36Sopenharmony_ci		} else {
20662306a36Sopenharmony_ci			if (wifi_rssi < rssi_thresh1) {
20762306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_MEDIUM;
20862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
20962306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state switch to Medium\n");
21062306a36Sopenharmony_ci			} else {
21162306a36Sopenharmony_ci				wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH;
21262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
21362306a36Sopenharmony_ci					"[BTCoex], wifi RSSI state stay at High\n");
21462306a36Sopenharmony_ci			}
21562306a36Sopenharmony_ci		}
21662306a36Sopenharmony_ci	}
21762306a36Sopenharmony_ci	coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state;
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci	return wifi_rssi_state;
22062306a36Sopenharmony_ci}
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_cistatic void btc8821a1ant_update_ra_mask(struct btc_coexist *btcoexist,
22362306a36Sopenharmony_ci					bool force_exec, u32 dis_rate_mask)
22462306a36Sopenharmony_ci{
22562306a36Sopenharmony_ci	coex_dm->cur_ra_mask = dis_rate_mask;
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci	if (force_exec ||
22862306a36Sopenharmony_ci	    (coex_dm->pre_ra_mask != coex_dm->cur_ra_mask)) {
22962306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_RAMASK,
23062306a36Sopenharmony_ci				   &coex_dm->cur_ra_mask);
23162306a36Sopenharmony_ci	}
23262306a36Sopenharmony_ci	coex_dm->pre_ra_mask = coex_dm->cur_ra_mask;
23362306a36Sopenharmony_ci}
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_cistatic void btc8821a1ant_auto_rate_fb_retry(struct btc_coexist *btcoexist,
23662306a36Sopenharmony_ci					    bool force_exec, u8 type)
23762306a36Sopenharmony_ci{
23862306a36Sopenharmony_ci	bool wifi_under_b_mode = false;
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci	coex_dm->cur_arfr_type = type;
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci	if (force_exec ||
24362306a36Sopenharmony_ci	    (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) {
24462306a36Sopenharmony_ci		switch (coex_dm->cur_arfr_type) {
24562306a36Sopenharmony_ci		case 0:	/* normal mode */
24662306a36Sopenharmony_ci			btcoexist->btc_write_4byte(btcoexist, 0x430,
24762306a36Sopenharmony_ci						   coex_dm->backup_arfr_cnt1);
24862306a36Sopenharmony_ci			btcoexist->btc_write_4byte(btcoexist, 0x434,
24962306a36Sopenharmony_ci						   coex_dm->backup_arfr_cnt2);
25062306a36Sopenharmony_ci			break;
25162306a36Sopenharmony_ci		case 1:
25262306a36Sopenharmony_ci			btcoexist->btc_get(btcoexist,
25362306a36Sopenharmony_ci					   BTC_GET_BL_WIFI_UNDER_B_MODE,
25462306a36Sopenharmony_ci					   &wifi_under_b_mode);
25562306a36Sopenharmony_ci			if (wifi_under_b_mode) {
25662306a36Sopenharmony_ci				btcoexist->btc_write_4byte(btcoexist, 0x430,
25762306a36Sopenharmony_ci							   0x0);
25862306a36Sopenharmony_ci				btcoexist->btc_write_4byte(btcoexist, 0x434,
25962306a36Sopenharmony_ci							   0x01010101);
26062306a36Sopenharmony_ci			} else {
26162306a36Sopenharmony_ci				btcoexist->btc_write_4byte(btcoexist, 0x430,
26262306a36Sopenharmony_ci							   0x0);
26362306a36Sopenharmony_ci				btcoexist->btc_write_4byte(btcoexist, 0x434,
26462306a36Sopenharmony_ci							   0x04030201);
26562306a36Sopenharmony_ci			}
26662306a36Sopenharmony_ci			break;
26762306a36Sopenharmony_ci		default:
26862306a36Sopenharmony_ci			break;
26962306a36Sopenharmony_ci		}
27062306a36Sopenharmony_ci	}
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci	coex_dm->pre_arfr_type = coex_dm->cur_arfr_type;
27362306a36Sopenharmony_ci}
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_cistatic void btc8821a1ant_retry_limit(struct btc_coexist *btcoexist,
27662306a36Sopenharmony_ci				     bool force_exec, u8 type)
27762306a36Sopenharmony_ci{
27862306a36Sopenharmony_ci	coex_dm->cur_retry_limit_type = type;
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci	if (force_exec ||
28162306a36Sopenharmony_ci	    (coex_dm->pre_retry_limit_type != coex_dm->cur_retry_limit_type)) {
28262306a36Sopenharmony_ci		switch (coex_dm->cur_retry_limit_type) {
28362306a36Sopenharmony_ci		case 0:	/* normal mode */
28462306a36Sopenharmony_ci			btcoexist->btc_write_2byte(btcoexist, 0x42a,
28562306a36Sopenharmony_ci						   coex_dm->backup_retry_limit);
28662306a36Sopenharmony_ci			break;
28762306a36Sopenharmony_ci		case 1:	/* retry limit = 8 */
28862306a36Sopenharmony_ci			btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808);
28962306a36Sopenharmony_ci			break;
29062306a36Sopenharmony_ci		default:
29162306a36Sopenharmony_ci			break;
29262306a36Sopenharmony_ci		}
29362306a36Sopenharmony_ci	}
29462306a36Sopenharmony_ci	coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type;
29562306a36Sopenharmony_ci}
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_cistatic void btc8821a1ant_ampdu_max_time(struct btc_coexist *btcoexist,
29862306a36Sopenharmony_ci					bool force_exec, u8 type)
29962306a36Sopenharmony_ci{
30062306a36Sopenharmony_ci	coex_dm->cur_ampdu_time_type = type;
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci	if (force_exec ||
30362306a36Sopenharmony_ci	    (coex_dm->pre_ampdu_time_type != coex_dm->cur_ampdu_time_type)) {
30462306a36Sopenharmony_ci		switch (coex_dm->cur_ampdu_time_type) {
30562306a36Sopenharmony_ci		case 0:	/* normal mode */
30662306a36Sopenharmony_ci			btcoexist->btc_write_1byte(btcoexist, 0x456,
30762306a36Sopenharmony_ci						   coex_dm->backup_ampdu_max_time);
30862306a36Sopenharmony_ci			break;
30962306a36Sopenharmony_ci		case 1:	/* AMPDU time = 0x38 * 32us */
31062306a36Sopenharmony_ci			btcoexist->btc_write_1byte(btcoexist, 0x456, 0x38);
31162306a36Sopenharmony_ci			break;
31262306a36Sopenharmony_ci		default:
31362306a36Sopenharmony_ci			break;
31462306a36Sopenharmony_ci		}
31562306a36Sopenharmony_ci	}
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci	coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type;
31862306a36Sopenharmony_ci}
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_cistatic void btc8821a1ant_limited_tx(struct btc_coexist *btcoexist,
32162306a36Sopenharmony_ci				    bool force_exec, u8 ra_mask_type,
32262306a36Sopenharmony_ci				    u8 arfr_type, u8 retry_limit_type,
32362306a36Sopenharmony_ci				    u8 ampdu_time_type)
32462306a36Sopenharmony_ci{
32562306a36Sopenharmony_ci	switch (ra_mask_type) {
32662306a36Sopenharmony_ci	case 0:	/* normal mode */
32762306a36Sopenharmony_ci		btc8821a1ant_update_ra_mask(btcoexist, force_exec, 0x0);
32862306a36Sopenharmony_ci		break;
32962306a36Sopenharmony_ci	case 1:	/* disable cck 1/2 */
33062306a36Sopenharmony_ci		btc8821a1ant_update_ra_mask(btcoexist, force_exec,
33162306a36Sopenharmony_ci					    0x00000003);
33262306a36Sopenharmony_ci		break;
33362306a36Sopenharmony_ci	case 2:	/* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */
33462306a36Sopenharmony_ci		btc8821a1ant_update_ra_mask(btcoexist, force_exec,
33562306a36Sopenharmony_ci					    0x0001f1f7);
33662306a36Sopenharmony_ci		break;
33762306a36Sopenharmony_ci	default:
33862306a36Sopenharmony_ci		break;
33962306a36Sopenharmony_ci	}
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci	btc8821a1ant_auto_rate_fb_retry(btcoexist, force_exec, arfr_type);
34262306a36Sopenharmony_ci	btc8821a1ant_retry_limit(btcoexist, force_exec, retry_limit_type);
34362306a36Sopenharmony_ci	btc8821a1ant_ampdu_max_time(btcoexist, force_exec, ampdu_time_type);
34462306a36Sopenharmony_ci}
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_cistatic void btc8821a1ant_limited_rx(struct btc_coexist *btcoexist,
34762306a36Sopenharmony_ci				    bool force_exec, bool rej_ap_agg_pkt,
34862306a36Sopenharmony_ci				    bool bt_ctrl_agg_buf_size, u8 agg_buf_size)
34962306a36Sopenharmony_ci{
35062306a36Sopenharmony_ci	bool reject_rx_agg = rej_ap_agg_pkt;
35162306a36Sopenharmony_ci	bool bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size;
35262306a36Sopenharmony_ci	u8 rx_agg_size = agg_buf_size;
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci	/* Rx Aggregation related setting */
35562306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist,
35662306a36Sopenharmony_ci		 BTC_SET_BL_TO_REJ_AP_AGG_PKT, &reject_rx_agg);
35762306a36Sopenharmony_ci	/* decide BT control aggregation buf size or not */
35862306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE,
35962306a36Sopenharmony_ci			   &bt_ctrl_rx_agg_size);
36062306a36Sopenharmony_ci	/* aggregation buf size, only work when BT control Rx agg size */
36162306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size);
36262306a36Sopenharmony_ci	/* real update aggregation setting */
36362306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL);
36462306a36Sopenharmony_ci}
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_cistatic void btc8821a1ant_monitor_bt_ctr(struct btc_coexist *btcoexist)
36762306a36Sopenharmony_ci{
36862306a36Sopenharmony_ci	u32 reg_hp_tx_rx, reg_lp_tx_rx, u4_tmp;
36962306a36Sopenharmony_ci	u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0;
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci	reg_hp_tx_rx = 0x770;
37262306a36Sopenharmony_ci	reg_lp_tx_rx = 0x774;
37362306a36Sopenharmony_ci
37462306a36Sopenharmony_ci	u4_tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_tx_rx);
37562306a36Sopenharmony_ci	reg_hp_tx = u4_tmp & MASKLWORD;
37662306a36Sopenharmony_ci	reg_hp_rx = (u4_tmp & MASKHWORD) >> 16;
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci	u4_tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_tx_rx);
37962306a36Sopenharmony_ci	reg_lp_tx = u4_tmp & MASKLWORD;
38062306a36Sopenharmony_ci	reg_lp_rx = (u4_tmp & MASKHWORD) >> 16;
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci	coex_sta->high_priority_tx = reg_hp_tx;
38362306a36Sopenharmony_ci	coex_sta->high_priority_rx = reg_hp_rx;
38462306a36Sopenharmony_ci	coex_sta->low_priority_tx = reg_lp_tx;
38562306a36Sopenharmony_ci	coex_sta->low_priority_rx = reg_lp_rx;
38662306a36Sopenharmony_ci
38762306a36Sopenharmony_ci	/* reset counter */
38862306a36Sopenharmony_ci	btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
38962306a36Sopenharmony_ci}
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_cistatic void btc8821a1ant_query_bt_info(struct btc_coexist *btcoexist)
39262306a36Sopenharmony_ci{
39362306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
39462306a36Sopenharmony_ci	u8 h2c_parameter[1] = {0};
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_ci	coex_sta->c2h_bt_info_req_sent = true;
39762306a36Sopenharmony_ci
39862306a36Sopenharmony_ci	h2c_parameter[0] |= BIT0; /* trigger */
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
40162306a36Sopenharmony_ci		"[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n",
40262306a36Sopenharmony_ci		h2c_parameter[0]);
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_ci	btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
40562306a36Sopenharmony_ci}
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_cistatic void btc8821a1ant_update_bt_link_info(struct btc_coexist *btcoexist)
40862306a36Sopenharmony_ci{
40962306a36Sopenharmony_ci	struct btc_bt_link_info	*bt_link_info = &btcoexist->bt_link_info;
41062306a36Sopenharmony_ci	bool bt_hs_on = false;
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci	bt_link_info->bt_link_exist = coex_sta->bt_link_exist;
41562306a36Sopenharmony_ci	bt_link_info->sco_exist = coex_sta->sco_exist;
41662306a36Sopenharmony_ci	bt_link_info->a2dp_exist = coex_sta->a2dp_exist;
41762306a36Sopenharmony_ci	bt_link_info->pan_exist = coex_sta->pan_exist;
41862306a36Sopenharmony_ci	bt_link_info->hid_exist = coex_sta->hid_exist;
41962306a36Sopenharmony_ci
42062306a36Sopenharmony_ci	/* work around for HS mode */
42162306a36Sopenharmony_ci	if (bt_hs_on) {
42262306a36Sopenharmony_ci		bt_link_info->pan_exist = true;
42362306a36Sopenharmony_ci		bt_link_info->bt_link_exist = true;
42462306a36Sopenharmony_ci	}
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_ci	/* check if Sco only */
42762306a36Sopenharmony_ci	if (bt_link_info->sco_exist &&
42862306a36Sopenharmony_ci	    !bt_link_info->a2dp_exist &&
42962306a36Sopenharmony_ci	    !bt_link_info->pan_exist &&
43062306a36Sopenharmony_ci	    !bt_link_info->hid_exist)
43162306a36Sopenharmony_ci		bt_link_info->sco_only = true;
43262306a36Sopenharmony_ci	else
43362306a36Sopenharmony_ci		bt_link_info->sco_only = false;
43462306a36Sopenharmony_ci
43562306a36Sopenharmony_ci	/* check if A2dp only */
43662306a36Sopenharmony_ci	if (!bt_link_info->sco_exist &&
43762306a36Sopenharmony_ci	    bt_link_info->a2dp_exist &&
43862306a36Sopenharmony_ci	    !bt_link_info->pan_exist &&
43962306a36Sopenharmony_ci	    !bt_link_info->hid_exist)
44062306a36Sopenharmony_ci		bt_link_info->a2dp_only = true;
44162306a36Sopenharmony_ci	else
44262306a36Sopenharmony_ci		bt_link_info->a2dp_only = false;
44362306a36Sopenharmony_ci
44462306a36Sopenharmony_ci	/* check if Pan only */
44562306a36Sopenharmony_ci	if (!bt_link_info->sco_exist &&
44662306a36Sopenharmony_ci	    !bt_link_info->a2dp_exist &&
44762306a36Sopenharmony_ci	    bt_link_info->pan_exist &&
44862306a36Sopenharmony_ci	    !bt_link_info->hid_exist)
44962306a36Sopenharmony_ci		bt_link_info->pan_only = true;
45062306a36Sopenharmony_ci	else
45162306a36Sopenharmony_ci		bt_link_info->pan_only = false;
45262306a36Sopenharmony_ci
45362306a36Sopenharmony_ci	/* check if Hid only */
45462306a36Sopenharmony_ci	if (!bt_link_info->sco_exist &&
45562306a36Sopenharmony_ci	    !bt_link_info->a2dp_exist &&
45662306a36Sopenharmony_ci	    !bt_link_info->pan_exist &&
45762306a36Sopenharmony_ci	    bt_link_info->hid_exist)
45862306a36Sopenharmony_ci		bt_link_info->hid_only = true;
45962306a36Sopenharmony_ci	else
46062306a36Sopenharmony_ci		bt_link_info->hid_only = false;
46162306a36Sopenharmony_ci}
46262306a36Sopenharmony_ci
46362306a36Sopenharmony_cistatic u8 btc8821a1ant_action_algorithm(struct btc_coexist *btcoexist)
46462306a36Sopenharmony_ci{
46562306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
46662306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
46762306a36Sopenharmony_ci	bool bt_hs_on = false;
46862306a36Sopenharmony_ci	u8 algorithm = BT_8821A_1ANT_COEX_ALGO_UNDEFINED;
46962306a36Sopenharmony_ci	u8 num_of_diff_profile = 0;
47062306a36Sopenharmony_ci
47162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
47262306a36Sopenharmony_ci
47362306a36Sopenharmony_ci	if (!bt_link_info->bt_link_exist) {
47462306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
47562306a36Sopenharmony_ci			"[BTCoex], No BT link exists!!!\n");
47662306a36Sopenharmony_ci		return algorithm;
47762306a36Sopenharmony_ci	}
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_ci	if (bt_link_info->sco_exist)
48062306a36Sopenharmony_ci		num_of_diff_profile++;
48162306a36Sopenharmony_ci	if (bt_link_info->hid_exist)
48262306a36Sopenharmony_ci		num_of_diff_profile++;
48362306a36Sopenharmony_ci	if (bt_link_info->pan_exist)
48462306a36Sopenharmony_ci		num_of_diff_profile++;
48562306a36Sopenharmony_ci	if (bt_link_info->a2dp_exist)
48662306a36Sopenharmony_ci		num_of_diff_profile++;
48762306a36Sopenharmony_ci
48862306a36Sopenharmony_ci	if (num_of_diff_profile == 1) {
48962306a36Sopenharmony_ci		if (bt_link_info->sco_exist) {
49062306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
49162306a36Sopenharmony_ci				"[BTCoex], BT Profile = SCO only\n");
49262306a36Sopenharmony_ci			algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
49362306a36Sopenharmony_ci		} else {
49462306a36Sopenharmony_ci			if (bt_link_info->hid_exist) {
49562306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
49662306a36Sopenharmony_ci					"[BTCoex], BT Profile = HID only\n");
49762306a36Sopenharmony_ci				algorithm = BT_8821A_1ANT_COEX_ALGO_HID;
49862306a36Sopenharmony_ci			} else if (bt_link_info->a2dp_exist) {
49962306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
50062306a36Sopenharmony_ci					"[BTCoex], BT Profile = A2DP only\n");
50162306a36Sopenharmony_ci				algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP;
50262306a36Sopenharmony_ci			} else if (bt_link_info->pan_exist) {
50362306a36Sopenharmony_ci				if (bt_hs_on) {
50462306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
50562306a36Sopenharmony_ci						DBG_LOUD,
50662306a36Sopenharmony_ci						"[BTCoex], BT Profile = PAN(HS) only\n");
50762306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANHS;
50862306a36Sopenharmony_ci				} else {
50962306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
51062306a36Sopenharmony_ci						DBG_LOUD,
51162306a36Sopenharmony_ci						"[BTCoex], BT Profile = PAN(EDR) only\n");
51262306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR;
51362306a36Sopenharmony_ci				}
51462306a36Sopenharmony_ci			}
51562306a36Sopenharmony_ci		}
51662306a36Sopenharmony_ci	} else if (num_of_diff_profile == 2) {
51762306a36Sopenharmony_ci		if (bt_link_info->sco_exist) {
51862306a36Sopenharmony_ci			if (bt_link_info->hid_exist) {
51962306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
52062306a36Sopenharmony_ci					"[BTCoex], BT Profile = SCO + HID\n");
52162306a36Sopenharmony_ci				algorithm = BT_8821A_1ANT_COEX_ALGO_HID;
52262306a36Sopenharmony_ci			} else if (bt_link_info->a2dp_exist) {
52362306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
52462306a36Sopenharmony_ci					"[BTCoex], BT Profile = SCO + A2DP ==> SCO\n");
52562306a36Sopenharmony_ci				algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
52662306a36Sopenharmony_ci			} else if (bt_link_info->pan_exist) {
52762306a36Sopenharmony_ci				if (bt_hs_on) {
52862306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
52962306a36Sopenharmony_ci						DBG_LOUD,
53062306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + PAN(HS)\n");
53162306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
53262306a36Sopenharmony_ci				} else {
53362306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
53462306a36Sopenharmony_ci						DBG_LOUD,
53562306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + PAN(EDR)\n");
53662306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
53762306a36Sopenharmony_ci				}
53862306a36Sopenharmony_ci			}
53962306a36Sopenharmony_ci		} else {
54062306a36Sopenharmony_ci			if (bt_link_info->hid_exist &&
54162306a36Sopenharmony_ci			    bt_link_info->a2dp_exist) {
54262306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
54362306a36Sopenharmony_ci					"[BTCoex], BT Profile = HID + A2DP\n");
54462306a36Sopenharmony_ci				algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
54562306a36Sopenharmony_ci			} else if (bt_link_info->hid_exist &&
54662306a36Sopenharmony_ci				   bt_link_info->pan_exist) {
54762306a36Sopenharmony_ci				if (bt_hs_on) {
54862306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
54962306a36Sopenharmony_ci						DBG_LOUD,
55062306a36Sopenharmony_ci						"[BTCoex], BT Profile = HID + PAN(HS)\n");
55162306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
55262306a36Sopenharmony_ci				} else {
55362306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
55462306a36Sopenharmony_ci						DBG_LOUD,
55562306a36Sopenharmony_ci						"[BTCoex], BT Profile = HID + PAN(EDR)\n");
55662306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
55762306a36Sopenharmony_ci				}
55862306a36Sopenharmony_ci			} else if (bt_link_info->pan_exist &&
55962306a36Sopenharmony_ci				   bt_link_info->a2dp_exist) {
56062306a36Sopenharmony_ci				if (bt_hs_on) {
56162306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
56262306a36Sopenharmony_ci						DBG_LOUD,
56362306a36Sopenharmony_ci						"[BTCoex], BT Profile = A2DP + PAN(HS)\n");
56462306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS;
56562306a36Sopenharmony_ci				} else {
56662306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
56762306a36Sopenharmony_ci						DBG_LOUD,
56862306a36Sopenharmony_ci						"[BTCoex], BT Profile = A2DP + PAN(EDR)\n");
56962306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP;
57062306a36Sopenharmony_ci				}
57162306a36Sopenharmony_ci			}
57262306a36Sopenharmony_ci		}
57362306a36Sopenharmony_ci	} else if (num_of_diff_profile == 3) {
57462306a36Sopenharmony_ci		if (bt_link_info->sco_exist) {
57562306a36Sopenharmony_ci			if (bt_link_info->hid_exist &&
57662306a36Sopenharmony_ci			    bt_link_info->a2dp_exist) {
57762306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
57862306a36Sopenharmony_ci					"[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n");
57962306a36Sopenharmony_ci				algorithm = BT_8821A_1ANT_COEX_ALGO_HID;
58062306a36Sopenharmony_ci			} else if (bt_link_info->hid_exist &&
58162306a36Sopenharmony_ci				   bt_link_info->pan_exist) {
58262306a36Sopenharmony_ci				if (bt_hs_on) {
58362306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
58462306a36Sopenharmony_ci						DBG_LOUD,
58562306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + HID + PAN(HS)\n");
58662306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
58762306a36Sopenharmony_ci				} else {
58862306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
58962306a36Sopenharmony_ci						DBG_LOUD,
59062306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n");
59162306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
59262306a36Sopenharmony_ci				}
59362306a36Sopenharmony_ci			} else if (bt_link_info->pan_exist &&
59462306a36Sopenharmony_ci				   bt_link_info->a2dp_exist) {
59562306a36Sopenharmony_ci				if (bt_hs_on) {
59662306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
59762306a36Sopenharmony_ci						DBG_LOUD,
59862306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n");
59962306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_SCO;
60062306a36Sopenharmony_ci				} else {
60162306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
60262306a36Sopenharmony_ci						DBG_LOUD,
60362306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n");
60462306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
60562306a36Sopenharmony_ci				}
60662306a36Sopenharmony_ci			}
60762306a36Sopenharmony_ci		} else {
60862306a36Sopenharmony_ci			if (bt_link_info->hid_exist &&
60962306a36Sopenharmony_ci			    bt_link_info->pan_exist &&
61062306a36Sopenharmony_ci			    bt_link_info->a2dp_exist) {
61162306a36Sopenharmony_ci				if (bt_hs_on) {
61262306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
61362306a36Sopenharmony_ci						DBG_LOUD,
61462306a36Sopenharmony_ci						"[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n");
61562306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP;
61662306a36Sopenharmony_ci				} else {
61762306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
61862306a36Sopenharmony_ci						DBG_LOUD,
61962306a36Sopenharmony_ci						"[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n");
62062306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR;
62162306a36Sopenharmony_ci				}
62262306a36Sopenharmony_ci			}
62362306a36Sopenharmony_ci		}
62462306a36Sopenharmony_ci	} else if (num_of_diff_profile >= 3) {
62562306a36Sopenharmony_ci		if (bt_link_info->sco_exist) {
62662306a36Sopenharmony_ci			if (bt_link_info->hid_exist &&
62762306a36Sopenharmony_ci			    bt_link_info->pan_exist &&
62862306a36Sopenharmony_ci			    bt_link_info->a2dp_exist) {
62962306a36Sopenharmony_ci				if (bt_hs_on) {
63062306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
63162306a36Sopenharmony_ci						DBG_LOUD,
63262306a36Sopenharmony_ci						"[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n");
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ci				} else {
63562306a36Sopenharmony_ci					rtl_dbg(rtlpriv, COMP_BT_COEXIST,
63662306a36Sopenharmony_ci						DBG_LOUD,
63762306a36Sopenharmony_ci						"[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n");
63862306a36Sopenharmony_ci					algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID;
63962306a36Sopenharmony_ci				}
64062306a36Sopenharmony_ci			}
64162306a36Sopenharmony_ci		}
64262306a36Sopenharmony_ci	}
64362306a36Sopenharmony_ci	return algorithm;
64462306a36Sopenharmony_ci}
64562306a36Sopenharmony_ci
64662306a36Sopenharmony_cistatic void btc8821a1ant_set_sw_penalty_tx_rate(struct btc_coexist *btcoexist,
64762306a36Sopenharmony_ci						bool low_penalty_ra)
64862306a36Sopenharmony_ci{
64962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
65062306a36Sopenharmony_ci	u8 h2c_parameter[6] = {0};
65162306a36Sopenharmony_ci
65262306a36Sopenharmony_ci	h2c_parameter[0] = 0x6;	/* opCode, 0x6= Retry_Penalty*/
65362306a36Sopenharmony_ci
65462306a36Sopenharmony_ci	if (low_penalty_ra) {
65562306a36Sopenharmony_ci		h2c_parameter[1] |= BIT0;
65662306a36Sopenharmony_ci		/* normal rate except MCS7/6/5, OFDM54/48/36 */
65762306a36Sopenharmony_ci		h2c_parameter[2] = 0x00;
65862306a36Sopenharmony_ci		h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */
65962306a36Sopenharmony_ci		h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */
66062306a36Sopenharmony_ci		h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */
66162306a36Sopenharmony_ci	}
66262306a36Sopenharmony_ci
66362306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
66462306a36Sopenharmony_ci		"[BTCoex], set WiFi Low-Penalty Retry: %s",
66562306a36Sopenharmony_ci		(low_penalty_ra ? "ON!!" : "OFF!!"));
66662306a36Sopenharmony_ci
66762306a36Sopenharmony_ci	btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter);
66862306a36Sopenharmony_ci}
66962306a36Sopenharmony_ci
67062306a36Sopenharmony_cistatic void btc8821a1ant_low_penalty_ra(struct btc_coexist *btcoexist,
67162306a36Sopenharmony_ci					bool force_exec, bool low_penalty_ra)
67262306a36Sopenharmony_ci{
67362306a36Sopenharmony_ci	coex_dm->cur_low_penalty_ra = low_penalty_ra;
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_ci	if (!force_exec) {
67662306a36Sopenharmony_ci		if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra)
67762306a36Sopenharmony_ci			return;
67862306a36Sopenharmony_ci	}
67962306a36Sopenharmony_ci	btc8821a1ant_set_sw_penalty_tx_rate(btcoexist,
68062306a36Sopenharmony_ci					    coex_dm->cur_low_penalty_ra);
68162306a36Sopenharmony_ci
68262306a36Sopenharmony_ci	coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra;
68362306a36Sopenharmony_ci}
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_cistatic void btc8821a1ant_set_coex_table(struct btc_coexist *btcoexist,
68662306a36Sopenharmony_ci					u32 val0x6c0, u32 val0x6c4,
68762306a36Sopenharmony_ci					u32 val0x6c8, u8 val0x6cc)
68862306a36Sopenharmony_ci{
68962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
69062306a36Sopenharmony_ci
69162306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
69262306a36Sopenharmony_ci		"[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0);
69362306a36Sopenharmony_ci	btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0);
69462306a36Sopenharmony_ci
69562306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
69662306a36Sopenharmony_ci		"[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4);
69762306a36Sopenharmony_ci	btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4);
69862306a36Sopenharmony_ci
69962306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
70062306a36Sopenharmony_ci		"[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8);
70162306a36Sopenharmony_ci	btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8);
70262306a36Sopenharmony_ci
70362306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
70462306a36Sopenharmony_ci		"[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc);
70562306a36Sopenharmony_ci	btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc);
70662306a36Sopenharmony_ci}
70762306a36Sopenharmony_ci
70862306a36Sopenharmony_cistatic void btc8821a1ant_coex_table(struct btc_coexist *btcoexist,
70962306a36Sopenharmony_ci				    bool force_exec, u32 val0x6c0, u32 val0x6c4,
71062306a36Sopenharmony_ci				    u32 val0x6c8, u8 val0x6cc)
71162306a36Sopenharmony_ci{
71262306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
71362306a36Sopenharmony_ci
71462306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
71562306a36Sopenharmony_ci		"[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
71662306a36Sopenharmony_ci		(force_exec ? "force to" : ""), val0x6c0, val0x6c4,
71762306a36Sopenharmony_ci		val0x6c8, val0x6cc);
71862306a36Sopenharmony_ci	coex_dm->cur_val_0x6c0 = val0x6c0;
71962306a36Sopenharmony_ci	coex_dm->cur_val_0x6c4 = val0x6c4;
72062306a36Sopenharmony_ci	coex_dm->cur_val_0x6c8 = val0x6c8;
72162306a36Sopenharmony_ci	coex_dm->cur_val_0x6cc = val0x6cc;
72262306a36Sopenharmony_ci
72362306a36Sopenharmony_ci	if (!force_exec) {
72462306a36Sopenharmony_ci		if ((coex_dm->pre_val_0x6c0 == coex_dm->cur_val_0x6c0) &&
72562306a36Sopenharmony_ci		    (coex_dm->pre_val_0x6c4 == coex_dm->cur_val_0x6c4) &&
72662306a36Sopenharmony_ci		    (coex_dm->pre_val_0x6c8 == coex_dm->cur_val_0x6c8) &&
72762306a36Sopenharmony_ci		    (coex_dm->pre_val_0x6cc == coex_dm->cur_val_0x6cc))
72862306a36Sopenharmony_ci			return;
72962306a36Sopenharmony_ci	}
73062306a36Sopenharmony_ci	btc8821a1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4,
73162306a36Sopenharmony_ci				    val0x6c8, val0x6cc);
73262306a36Sopenharmony_ci
73362306a36Sopenharmony_ci	coex_dm->pre_val_0x6c0 = coex_dm->cur_val_0x6c0;
73462306a36Sopenharmony_ci	coex_dm->pre_val_0x6c4 = coex_dm->cur_val_0x6c4;
73562306a36Sopenharmony_ci	coex_dm->pre_val_0x6c8 = coex_dm->cur_val_0x6c8;
73662306a36Sopenharmony_ci	coex_dm->pre_val_0x6cc = coex_dm->cur_val_0x6cc;
73762306a36Sopenharmony_ci}
73862306a36Sopenharmony_ci
73962306a36Sopenharmony_cistatic void btc8821a1ant_coex_table_with_type(struct btc_coexist *btcoexist,
74062306a36Sopenharmony_ci					      bool force_exec, u8 type)
74162306a36Sopenharmony_ci{
74262306a36Sopenharmony_ci	switch (type) {
74362306a36Sopenharmony_ci	case 0:
74462306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
74562306a36Sopenharmony_ci					0x55555555, 0xffffff, 0x3);
74662306a36Sopenharmony_ci		break;
74762306a36Sopenharmony_ci	case 1:
74862306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
74962306a36Sopenharmony_ci					0x5a5a5a5a, 0xffffff, 0x3);
75062306a36Sopenharmony_ci		break;
75162306a36Sopenharmony_ci	case 2:
75262306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
75362306a36Sopenharmony_ci					0x5a5a5a5a, 0xffffff, 0x3);
75462306a36Sopenharmony_ci		break;
75562306a36Sopenharmony_ci	case 3:
75662306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
75762306a36Sopenharmony_ci					0xaaaaaaaa, 0xffffff, 0x3);
75862306a36Sopenharmony_ci		break;
75962306a36Sopenharmony_ci	case 4:
76062306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
76162306a36Sopenharmony_ci					0x5a5a5a5a, 0xffffff, 0x3);
76262306a36Sopenharmony_ci		break;
76362306a36Sopenharmony_ci	case 5:
76462306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
76562306a36Sopenharmony_ci					0xaaaa5a5a, 0xffffff, 0x3);
76662306a36Sopenharmony_ci		break;
76762306a36Sopenharmony_ci	case 6:
76862306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0x55555555,
76962306a36Sopenharmony_ci					0xaaaa5a5a, 0xffffff, 0x3);
77062306a36Sopenharmony_ci		break;
77162306a36Sopenharmony_ci	case 7:
77262306a36Sopenharmony_ci		btc8821a1ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa,
77362306a36Sopenharmony_ci					0xaaaaaaaa, 0xffffff, 0x3);
77462306a36Sopenharmony_ci		break;
77562306a36Sopenharmony_ci	default:
77662306a36Sopenharmony_ci		break;
77762306a36Sopenharmony_ci	}
77862306a36Sopenharmony_ci}
77962306a36Sopenharmony_ci
78062306a36Sopenharmony_cistatic void btc8821a1ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoexist,
78162306a36Sopenharmony_ci						bool enable)
78262306a36Sopenharmony_ci{
78362306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
78462306a36Sopenharmony_ci	u8 h2c_parameter[1] = {0};
78562306a36Sopenharmony_ci
78662306a36Sopenharmony_ci	if (enable)
78762306a36Sopenharmony_ci		h2c_parameter[0] |= BIT0; /* function enable */
78862306a36Sopenharmony_ci
78962306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
79062306a36Sopenharmony_ci		"[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n",
79162306a36Sopenharmony_ci		h2c_parameter[0]);
79262306a36Sopenharmony_ci
79362306a36Sopenharmony_ci	btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter);
79462306a36Sopenharmony_ci}
79562306a36Sopenharmony_ci
79662306a36Sopenharmony_cistatic void btc8821a1ant_ignore_wlan_act(struct btc_coexist *btcoexist,
79762306a36Sopenharmony_ci					 bool force_exec, bool enable)
79862306a36Sopenharmony_ci{
79962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
80062306a36Sopenharmony_ci
80162306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
80262306a36Sopenharmony_ci		"[BTCoex], %s turn Ignore WlanAct %s\n",
80362306a36Sopenharmony_ci		(force_exec ? "force to" : ""), (enable ? "ON" : "OFF"));
80462306a36Sopenharmony_ci	coex_dm->cur_ignore_wlan_act = enable;
80562306a36Sopenharmony_ci
80662306a36Sopenharmony_ci	if (!force_exec) {
80762306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
80862306a36Sopenharmony_ci			"[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n",
80962306a36Sopenharmony_ci			coex_dm->pre_ignore_wlan_act,
81062306a36Sopenharmony_ci			 coex_dm->cur_ignore_wlan_act);
81162306a36Sopenharmony_ci
81262306a36Sopenharmony_ci		if (coex_dm->pre_ignore_wlan_act ==
81362306a36Sopenharmony_ci		    coex_dm->cur_ignore_wlan_act)
81462306a36Sopenharmony_ci			return;
81562306a36Sopenharmony_ci	}
81662306a36Sopenharmony_ci	btc8821a1ant_set_fw_ignore_wlan_act(btcoexist, enable);
81762306a36Sopenharmony_ci
81862306a36Sopenharmony_ci	coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act;
81962306a36Sopenharmony_ci}
82062306a36Sopenharmony_ci
82162306a36Sopenharmony_cistatic void btc8821a1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, u8 byte1,
82262306a36Sopenharmony_ci					u8 byte2, u8 byte3, u8 byte4, u8 byte5)
82362306a36Sopenharmony_ci{
82462306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
82562306a36Sopenharmony_ci	u8 h2c_parameter[5] = {0};
82662306a36Sopenharmony_ci	u8 real_byte1 = byte1, real_byte5 = byte5;
82762306a36Sopenharmony_ci	bool ap_enable = false;
82862306a36Sopenharmony_ci
82962306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
83062306a36Sopenharmony_ci			   &ap_enable);
83162306a36Sopenharmony_ci
83262306a36Sopenharmony_ci	if (ap_enable) {
83362306a36Sopenharmony_ci		if (byte1 & BIT4 && !(byte1 & BIT5)) {
83462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
83562306a36Sopenharmony_ci				"[BTCoex], FW for 1Ant AP mode\n");
83662306a36Sopenharmony_ci			real_byte1 &= ~BIT4;
83762306a36Sopenharmony_ci			real_byte1 |= BIT5;
83862306a36Sopenharmony_ci
83962306a36Sopenharmony_ci			real_byte5 |= BIT5;
84062306a36Sopenharmony_ci			real_byte5 &= ~BIT6;
84162306a36Sopenharmony_ci		}
84262306a36Sopenharmony_ci	}
84362306a36Sopenharmony_ci
84462306a36Sopenharmony_ci	h2c_parameter[0] = real_byte1;
84562306a36Sopenharmony_ci	h2c_parameter[1] = byte2;
84662306a36Sopenharmony_ci	h2c_parameter[2] = byte3;
84762306a36Sopenharmony_ci	h2c_parameter[3] = byte4;
84862306a36Sopenharmony_ci	h2c_parameter[4] = real_byte5;
84962306a36Sopenharmony_ci
85062306a36Sopenharmony_ci	coex_dm->ps_tdma_para[0] = real_byte1;
85162306a36Sopenharmony_ci	coex_dm->ps_tdma_para[1] = byte2;
85262306a36Sopenharmony_ci	coex_dm->ps_tdma_para[2] = byte3;
85362306a36Sopenharmony_ci	coex_dm->ps_tdma_para[3] = byte4;
85462306a36Sopenharmony_ci	coex_dm->ps_tdma_para[4] = real_byte5;
85562306a36Sopenharmony_ci
85662306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
85762306a36Sopenharmony_ci		"[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n",
85862306a36Sopenharmony_ci		h2c_parameter[0],
85962306a36Sopenharmony_ci		h2c_parameter[1] << 24 |
86062306a36Sopenharmony_ci		h2c_parameter[2] << 16 |
86162306a36Sopenharmony_ci		h2c_parameter[3] << 8 |
86262306a36Sopenharmony_ci		h2c_parameter[4]);
86362306a36Sopenharmony_ci	btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter);
86462306a36Sopenharmony_ci}
86562306a36Sopenharmony_ci
86662306a36Sopenharmony_cistatic void btc8821a1ant_set_lps_rpwm(struct btc_coexist *btcoexist,
86762306a36Sopenharmony_ci				      u8 lps_val, u8 rpwm_val)
86862306a36Sopenharmony_ci{
86962306a36Sopenharmony_ci	u8 lps = lps_val;
87062306a36Sopenharmony_ci	u8 rpwm = rpwm_val;
87162306a36Sopenharmony_ci
87262306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps);
87362306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm);
87462306a36Sopenharmony_ci}
87562306a36Sopenharmony_ci
87662306a36Sopenharmony_cistatic void btc8821a1ant_lps_rpwm(struct btc_coexist *btcoexist,
87762306a36Sopenharmony_ci				  bool force_exec, u8 lps_val, u8 rpwm_val)
87862306a36Sopenharmony_ci{
87962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
88062306a36Sopenharmony_ci
88162306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
88262306a36Sopenharmony_ci		"[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n",
88362306a36Sopenharmony_ci		(force_exec ? "force to" : ""), lps_val, rpwm_val);
88462306a36Sopenharmony_ci	coex_dm->cur_lps = lps_val;
88562306a36Sopenharmony_ci	coex_dm->cur_rpwm = rpwm_val;
88662306a36Sopenharmony_ci
88762306a36Sopenharmony_ci	if (!force_exec) {
88862306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
88962306a36Sopenharmony_ci			"[BTCoex], LPS-RxBeaconMode = 0x%x, LPS-RPWM = 0x%x!!\n",
89062306a36Sopenharmony_ci			coex_dm->cur_lps, coex_dm->cur_rpwm);
89162306a36Sopenharmony_ci
89262306a36Sopenharmony_ci		if ((coex_dm->pre_lps == coex_dm->cur_lps) &&
89362306a36Sopenharmony_ci		    (coex_dm->pre_rpwm == coex_dm->cur_rpwm)) {
89462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
89562306a36Sopenharmony_ci				"[BTCoex], LPS-RPWM_Last = 0x%x, LPS-RPWM_Now = 0x%x!!\n",
89662306a36Sopenharmony_ci				coex_dm->pre_rpwm, coex_dm->cur_rpwm);
89762306a36Sopenharmony_ci
89862306a36Sopenharmony_ci			return;
89962306a36Sopenharmony_ci		}
90062306a36Sopenharmony_ci	}
90162306a36Sopenharmony_ci	btc8821a1ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val);
90262306a36Sopenharmony_ci
90362306a36Sopenharmony_ci	coex_dm->pre_lps = coex_dm->cur_lps;
90462306a36Sopenharmony_ci	coex_dm->pre_rpwm = coex_dm->cur_rpwm;
90562306a36Sopenharmony_ci}
90662306a36Sopenharmony_ci
90762306a36Sopenharmony_cistatic void btc8821a1ant_sw_mechanism(struct btc_coexist *btcoexist,
90862306a36Sopenharmony_ci				      bool low_penalty_ra)
90962306a36Sopenharmony_ci{
91062306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
91162306a36Sopenharmony_ci
91262306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
91362306a36Sopenharmony_ci		"[BTCoex], SM[LpRA] = %d\n", low_penalty_ra);
91462306a36Sopenharmony_ci
91562306a36Sopenharmony_ci	btc8821a1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra);
91662306a36Sopenharmony_ci}
91762306a36Sopenharmony_ci
91862306a36Sopenharmony_cistatic void btc8821a1ant_set_ant_path(struct btc_coexist *btcoexist,
91962306a36Sopenharmony_ci				      u8 ant_pos_type, bool init_hw_cfg,
92062306a36Sopenharmony_ci				      bool wifi_off)
92162306a36Sopenharmony_ci{
92262306a36Sopenharmony_ci	struct btc_board_info *board_info = &btcoexist->board_info;
92362306a36Sopenharmony_ci	u32 u4_tmp = 0;
92462306a36Sopenharmony_ci	u8 h2c_parameter[2] = {0};
92562306a36Sopenharmony_ci
92662306a36Sopenharmony_ci	if (init_hw_cfg) {
92762306a36Sopenharmony_ci		/* 0x4c[23] = 0, 0x4c[24] = 1  Antenna control by WL/BT */
92862306a36Sopenharmony_ci		u4_tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
92962306a36Sopenharmony_ci		u4_tmp &= ~BIT23;
93062306a36Sopenharmony_ci		u4_tmp |= BIT24;
93162306a36Sopenharmony_ci		btcoexist->btc_write_4byte(btcoexist, 0x4c, u4_tmp);
93262306a36Sopenharmony_ci
93362306a36Sopenharmony_ci		btcoexist->btc_write_1byte_bitmask(btcoexist, 0x975, 0x3, 0x3);
93462306a36Sopenharmony_ci		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77);
93562306a36Sopenharmony_ci
93662306a36Sopenharmony_ci		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) {
93762306a36Sopenharmony_ci			/* tell firmware "antenna inverse"
93862306a36Sopenharmony_ci			 * WRONG firmware antenna control code, need fw to fix
93962306a36Sopenharmony_ci			 */
94062306a36Sopenharmony_ci			h2c_parameter[0] = 1;
94162306a36Sopenharmony_ci			h2c_parameter[1] = 1;
94262306a36Sopenharmony_ci			btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
94362306a36Sopenharmony_ci						h2c_parameter);
94462306a36Sopenharmony_ci		} else {
94562306a36Sopenharmony_ci			/* tell firmware "no antenna inverse"
94662306a36Sopenharmony_ci			 * WRONG firmware antenna control code, need fw to fix
94762306a36Sopenharmony_ci			 */
94862306a36Sopenharmony_ci			h2c_parameter[0] = 0;
94962306a36Sopenharmony_ci			h2c_parameter[1] = 1;
95062306a36Sopenharmony_ci			btcoexist->btc_fill_h2c(btcoexist, 0x65, 2,
95162306a36Sopenharmony_ci						h2c_parameter);
95262306a36Sopenharmony_ci		}
95362306a36Sopenharmony_ci	} else if (wifi_off) {
95462306a36Sopenharmony_ci		/* 0x4c[24:23] = 00, Set Antenna control
95562306a36Sopenharmony_ci		 * by BT_RFE_CTRL BT Vendor 0xac = 0xf002
95662306a36Sopenharmony_ci		 */
95762306a36Sopenharmony_ci		u4_tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c);
95862306a36Sopenharmony_ci		u4_tmp &= ~BIT23;
95962306a36Sopenharmony_ci		u4_tmp &= ~BIT24;
96062306a36Sopenharmony_ci		btcoexist->btc_write_4byte(btcoexist, 0x4c, u4_tmp);
96162306a36Sopenharmony_ci
96262306a36Sopenharmony_ci		/* 0x765 = 0x18 */
96362306a36Sopenharmony_ci		btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3);
96462306a36Sopenharmony_ci	} else {
96562306a36Sopenharmony_ci		/* 0x765 = 0x0 */
96662306a36Sopenharmony_ci		btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0);
96762306a36Sopenharmony_ci	}
96862306a36Sopenharmony_ci
96962306a36Sopenharmony_ci	/* ext switch setting */
97062306a36Sopenharmony_ci	switch (ant_pos_type) {
97162306a36Sopenharmony_ci	case BTC_ANT_PATH_WIFI:
97262306a36Sopenharmony_ci		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77);
97362306a36Sopenharmony_ci		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
97462306a36Sopenharmony_ci			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
97562306a36Sopenharmony_ci							   0x30, 0x1);
97662306a36Sopenharmony_ci		else
97762306a36Sopenharmony_ci			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
97862306a36Sopenharmony_ci							   0x30, 0x2);
97962306a36Sopenharmony_ci		break;
98062306a36Sopenharmony_ci	case BTC_ANT_PATH_BT:
98162306a36Sopenharmony_ci		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77);
98262306a36Sopenharmony_ci		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
98362306a36Sopenharmony_ci			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
98462306a36Sopenharmony_ci							   0x30, 0x2);
98562306a36Sopenharmony_ci		else
98662306a36Sopenharmony_ci			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
98762306a36Sopenharmony_ci							   0x30, 0x1);
98862306a36Sopenharmony_ci		break;
98962306a36Sopenharmony_ci	default:
99062306a36Sopenharmony_ci	case BTC_ANT_PATH_PTA:
99162306a36Sopenharmony_ci		btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x66);
99262306a36Sopenharmony_ci		if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT)
99362306a36Sopenharmony_ci			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
99462306a36Sopenharmony_ci							   0x30, 0x1);
99562306a36Sopenharmony_ci		else
99662306a36Sopenharmony_ci			btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7,
99762306a36Sopenharmony_ci							   0x30, 0x2);
99862306a36Sopenharmony_ci		break;
99962306a36Sopenharmony_ci	}
100062306a36Sopenharmony_ci}
100162306a36Sopenharmony_ci
100262306a36Sopenharmony_cistatic void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
100362306a36Sopenharmony_ci				 bool force_exec, bool turn_on, u8 type)
100462306a36Sopenharmony_ci{
100562306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
100662306a36Sopenharmony_ci	u8 rssi_adjust_val = 0;
100762306a36Sopenharmony_ci
100862306a36Sopenharmony_ci	coex_dm->cur_ps_tdma_on = turn_on;
100962306a36Sopenharmony_ci	coex_dm->cur_ps_tdma = type;
101062306a36Sopenharmony_ci
101162306a36Sopenharmony_ci	if (!force_exec) {
101262306a36Sopenharmony_ci		if (coex_dm->cur_ps_tdma_on) {
101362306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
101462306a36Sopenharmony_ci				"[BTCoex], ********** TDMA(on, %d) **********\n",
101562306a36Sopenharmony_ci				coex_dm->cur_ps_tdma);
101662306a36Sopenharmony_ci		} else {
101762306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
101862306a36Sopenharmony_ci				"[BTCoex], ********** TDMA(off, %d) **********\n",
101962306a36Sopenharmony_ci				coex_dm->cur_ps_tdma);
102062306a36Sopenharmony_ci		}
102162306a36Sopenharmony_ci		if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) &&
102262306a36Sopenharmony_ci		    (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma))
102362306a36Sopenharmony_ci			return;
102462306a36Sopenharmony_ci	}
102562306a36Sopenharmony_ci	if (turn_on) {
102662306a36Sopenharmony_ci		switch (type) {
102762306a36Sopenharmony_ci		default:
102862306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1a,
102962306a36Sopenharmony_ci						    0x1a, 0x0, 0x50);
103062306a36Sopenharmony_ci			break;
103162306a36Sopenharmony_ci		case 1:
103262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x3a,
103362306a36Sopenharmony_ci						    0x03, 0x10, 0x50);
103462306a36Sopenharmony_ci			rssi_adjust_val = 11;
103562306a36Sopenharmony_ci			break;
103662306a36Sopenharmony_ci		case 2:
103762306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x2b,
103862306a36Sopenharmony_ci						    0x03, 0x10, 0x50);
103962306a36Sopenharmony_ci			rssi_adjust_val = 14;
104062306a36Sopenharmony_ci			break;
104162306a36Sopenharmony_ci		case 3:
104262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1d,
104362306a36Sopenharmony_ci						    0x1d, 0x0, 0x10);
104462306a36Sopenharmony_ci			break;
104562306a36Sopenharmony_ci		case 4:
104662306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15,
104762306a36Sopenharmony_ci						    0x3, 0x14, 0x0);
104862306a36Sopenharmony_ci			rssi_adjust_val = 17;
104962306a36Sopenharmony_ci			break;
105062306a36Sopenharmony_ci		case 5:
105162306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15,
105262306a36Sopenharmony_ci						    0x3, 0x11, 0x10);
105362306a36Sopenharmony_ci			break;
105462306a36Sopenharmony_ci		case 6:
105562306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x20,
105662306a36Sopenharmony_ci						    0x3, 0x11, 0x13);
105762306a36Sopenharmony_ci			break;
105862306a36Sopenharmony_ci		case 7:
105962306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xc,
106062306a36Sopenharmony_ci						    0x5, 0x0, 0x0);
106162306a36Sopenharmony_ci			break;
106262306a36Sopenharmony_ci		case 8:
106362306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25,
106462306a36Sopenharmony_ci						    0x3, 0x10, 0x0);
106562306a36Sopenharmony_ci			break;
106662306a36Sopenharmony_ci		case 9:
106762306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21,
106862306a36Sopenharmony_ci						    0x3, 0x10, 0x50);
106962306a36Sopenharmony_ci			rssi_adjust_val = 18;
107062306a36Sopenharmony_ci			break;
107162306a36Sopenharmony_ci		case 10:
107262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
107362306a36Sopenharmony_ci						    0xa, 0x0, 0x40);
107462306a36Sopenharmony_ci			break;
107562306a36Sopenharmony_ci		case 11:
107662306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15,
107762306a36Sopenharmony_ci						    0x03, 0x10, 0x50);
107862306a36Sopenharmony_ci			rssi_adjust_val = 20;
107962306a36Sopenharmony_ci			break;
108062306a36Sopenharmony_ci		case 12:
108162306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x0a,
108262306a36Sopenharmony_ci						    0x0a, 0x0, 0x50);
108362306a36Sopenharmony_ci			break;
108462306a36Sopenharmony_ci		case 13:
108562306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x12,
108662306a36Sopenharmony_ci						    0x12, 0x0, 0x50);
108762306a36Sopenharmony_ci			break;
108862306a36Sopenharmony_ci		case 14:
108962306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1e,
109062306a36Sopenharmony_ci						    0x3, 0x10, 0x14);
109162306a36Sopenharmony_ci			break;
109262306a36Sopenharmony_ci		case 15:
109362306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
109462306a36Sopenharmony_ci						    0x3, 0x8, 0x0);
109562306a36Sopenharmony_ci			break;
109662306a36Sopenharmony_ci		case 16:
109762306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15,
109862306a36Sopenharmony_ci						    0x3, 0x10, 0x0);
109962306a36Sopenharmony_ci			rssi_adjust_val = 18;
110062306a36Sopenharmony_ci			break;
110162306a36Sopenharmony_ci		case 18:
110262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25,
110362306a36Sopenharmony_ci						    0x3, 0x10, 0x0);
110462306a36Sopenharmony_ci			rssi_adjust_val = 14;
110562306a36Sopenharmony_ci			break;
110662306a36Sopenharmony_ci		case 20:
110762306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x35,
110862306a36Sopenharmony_ci						    0x03, 0x11, 0x10);
110962306a36Sopenharmony_ci			break;
111062306a36Sopenharmony_ci		case 21:
111162306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25,
111262306a36Sopenharmony_ci						    0x03, 0x11, 0x11);
111362306a36Sopenharmony_ci			break;
111462306a36Sopenharmony_ci		case 22:
111562306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25,
111662306a36Sopenharmony_ci						    0x03, 0x11, 0x10);
111762306a36Sopenharmony_ci			break;
111862306a36Sopenharmony_ci		case 23:
111962306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
112062306a36Sopenharmony_ci						    0x3, 0x31, 0x18);
112162306a36Sopenharmony_ci			rssi_adjust_val = 22;
112262306a36Sopenharmony_ci			break;
112362306a36Sopenharmony_ci		case 24:
112462306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15,
112562306a36Sopenharmony_ci						    0x3, 0x31, 0x18);
112662306a36Sopenharmony_ci			rssi_adjust_val = 22;
112762306a36Sopenharmony_ci			break;
112862306a36Sopenharmony_ci		case 25:
112962306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
113062306a36Sopenharmony_ci						    0x3, 0x31, 0x18);
113162306a36Sopenharmony_ci			rssi_adjust_val = 22;
113262306a36Sopenharmony_ci			break;
113362306a36Sopenharmony_ci		case 26:
113462306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa,
113562306a36Sopenharmony_ci						    0x3, 0x31, 0x18);
113662306a36Sopenharmony_ci			rssi_adjust_val = 22;
113762306a36Sopenharmony_ci			break;
113862306a36Sopenharmony_ci		case 27:
113962306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25,
114062306a36Sopenharmony_ci						    0x3, 0x31, 0x98);
114162306a36Sopenharmony_ci			rssi_adjust_val = 22;
114262306a36Sopenharmony_ci			break;
114362306a36Sopenharmony_ci		case 28:
114462306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x69, 0x25,
114562306a36Sopenharmony_ci						    0x3, 0x31, 0x0);
114662306a36Sopenharmony_ci			break;
114762306a36Sopenharmony_ci		case 29:
114862306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xab, 0x1a,
114962306a36Sopenharmony_ci						    0x1a, 0x1, 0x10);
115062306a36Sopenharmony_ci			break;
115162306a36Sopenharmony_ci		case 30:
115262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x30,
115362306a36Sopenharmony_ci						    0x3, 0x10, 0x10);
115462306a36Sopenharmony_ci			break;
115562306a36Sopenharmony_ci		case 31:
115662306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x1a,
115762306a36Sopenharmony_ci						    0x1a, 0, 0x58);
115862306a36Sopenharmony_ci			break;
115962306a36Sopenharmony_ci		case 32:
116062306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x35,
116162306a36Sopenharmony_ci						    0x3, 0x11, 0x11);
116262306a36Sopenharmony_ci			break;
116362306a36Sopenharmony_ci		case 33:
116462306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x25,
116562306a36Sopenharmony_ci						    0x3, 0x30, 0x90);
116662306a36Sopenharmony_ci			break;
116762306a36Sopenharmony_ci		case 34:
116862306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x53, 0x1a,
116962306a36Sopenharmony_ci						    0x1a, 0x0, 0x10);
117062306a36Sopenharmony_ci			break;
117162306a36Sopenharmony_ci		case 35:
117262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x63, 0x1a,
117362306a36Sopenharmony_ci						    0x1a, 0x0, 0x10);
117462306a36Sopenharmony_ci			break;
117562306a36Sopenharmony_ci		case 36:
117662306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12,
117762306a36Sopenharmony_ci						    0x3, 0x14, 0x50);
117862306a36Sopenharmony_ci			break;
117962306a36Sopenharmony_ci		case 40:
118062306a36Sopenharmony_ci			/* SoftAP only with no sta associated, BT disable, TDMA
118162306a36Sopenharmony_ci			 * mode for power saving
118262306a36Sopenharmony_ci			 *
118362306a36Sopenharmony_ci			 * here softap mode screen off will cost 70-80mA for
118462306a36Sopenharmony_ci			 * phone
118562306a36Sopenharmony_ci			 */
118662306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x23, 0x18,
118762306a36Sopenharmony_ci						    0x00, 0x10, 0x24);
118862306a36Sopenharmony_ci			break;
118962306a36Sopenharmony_ci		case 41:
119062306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15,
119162306a36Sopenharmony_ci						    0x3, 0x11, 0x11);
119262306a36Sopenharmony_ci			break;
119362306a36Sopenharmony_ci		case 42:
119462306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x20,
119562306a36Sopenharmony_ci						    0x3, 0x11, 0x11);
119662306a36Sopenharmony_ci			break;
119762306a36Sopenharmony_ci		case 43:
119862306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x30,
119962306a36Sopenharmony_ci						    0x3, 0x10, 0x11);
120062306a36Sopenharmony_ci			break;
120162306a36Sopenharmony_ci		}
120262306a36Sopenharmony_ci	} else {
120362306a36Sopenharmony_ci		/* disable PS tdma */
120462306a36Sopenharmony_ci		switch (type) {
120562306a36Sopenharmony_ci		case 8:
120662306a36Sopenharmony_ci			/* PTA Control */
120762306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x8, 0x0, 0x0,
120862306a36Sopenharmony_ci						    0x0, 0x0);
120962306a36Sopenharmony_ci			btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA,
121062306a36Sopenharmony_ci						  false, false);
121162306a36Sopenharmony_ci			break;
121262306a36Sopenharmony_ci		case 0:
121362306a36Sopenharmony_ci		default:
121462306a36Sopenharmony_ci			/* Software control, Antenna at BT side */
121562306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
121662306a36Sopenharmony_ci						    0x0, 0x0);
121762306a36Sopenharmony_ci			btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT,
121862306a36Sopenharmony_ci						  false, false);
121962306a36Sopenharmony_ci			break;
122062306a36Sopenharmony_ci		case 9:
122162306a36Sopenharmony_ci			/* Software control, Antenna at WiFi side */
122262306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
122362306a36Sopenharmony_ci						    0x0, 0x0);
122462306a36Sopenharmony_ci			btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_WIFI,
122562306a36Sopenharmony_ci						  false, false);
122662306a36Sopenharmony_ci			break;
122762306a36Sopenharmony_ci		case 10:
122862306a36Sopenharmony_ci			/* under 5G */
122962306a36Sopenharmony_ci			btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0,
123062306a36Sopenharmony_ci						    0x8, 0x0);
123162306a36Sopenharmony_ci			btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT,
123262306a36Sopenharmony_ci						  false, false);
123362306a36Sopenharmony_ci			break;
123462306a36Sopenharmony_ci		}
123562306a36Sopenharmony_ci	}
123662306a36Sopenharmony_ci	rssi_adjust_val = 0;
123762306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist,
123862306a36Sopenharmony_ci		 BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssi_adjust_val);
123962306a36Sopenharmony_ci
124062306a36Sopenharmony_ci	/* update pre state */
124162306a36Sopenharmony_ci	coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on;
124262306a36Sopenharmony_ci	coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma;
124362306a36Sopenharmony_ci}
124462306a36Sopenharmony_ci
124562306a36Sopenharmony_cistatic bool btc8821a1ant_is_common_action(struct btc_coexist *btcoexist)
124662306a36Sopenharmony_ci{
124762306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
124862306a36Sopenharmony_ci	bool common = false, wifi_connected = false, wifi_busy = false;
124962306a36Sopenharmony_ci
125062306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
125162306a36Sopenharmony_ci			   &wifi_connected);
125262306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
125362306a36Sopenharmony_ci
125462306a36Sopenharmony_ci	if (!wifi_connected &&
125562306a36Sopenharmony_ci	    BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
125662306a36Sopenharmony_ci	    coex_dm->bt_status) {
125762306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
125862306a36Sopenharmony_ci			"[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n");
125962306a36Sopenharmony_ci		btc8821a1ant_sw_mechanism(btcoexist, false);
126062306a36Sopenharmony_ci
126162306a36Sopenharmony_ci		common = true;
126262306a36Sopenharmony_ci	} else if (wifi_connected &&
126362306a36Sopenharmony_ci		   (BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
126462306a36Sopenharmony_ci		    coex_dm->bt_status)) {
126562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
126662306a36Sopenharmony_ci			"[BTCoex], Wifi connected + BT non connected-idle!!\n");
126762306a36Sopenharmony_ci		btc8821a1ant_sw_mechanism(btcoexist, false);
126862306a36Sopenharmony_ci
126962306a36Sopenharmony_ci		common = true;
127062306a36Sopenharmony_ci	} else if (!wifi_connected &&
127162306a36Sopenharmony_ci		   (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE ==
127262306a36Sopenharmony_ci		    coex_dm->bt_status)) {
127362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
127462306a36Sopenharmony_ci			"[BTCoex], Wifi non connected-idle + BT connected-idle!!\n");
127562306a36Sopenharmony_ci		btc8821a1ant_sw_mechanism(btcoexist, false);
127662306a36Sopenharmony_ci
127762306a36Sopenharmony_ci		common = true;
127862306a36Sopenharmony_ci	} else if (wifi_connected &&
127962306a36Sopenharmony_ci		   (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE ==
128062306a36Sopenharmony_ci		    coex_dm->bt_status)) {
128162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
128262306a36Sopenharmony_ci			"[BTCoex], Wifi connected + BT connected-idle!!\n");
128362306a36Sopenharmony_ci		btc8821a1ant_sw_mechanism(btcoexist, false);
128462306a36Sopenharmony_ci
128562306a36Sopenharmony_ci		common = true;
128662306a36Sopenharmony_ci	} else if (!wifi_connected &&
128762306a36Sopenharmony_ci		   (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE !=
128862306a36Sopenharmony_ci		    coex_dm->bt_status)) {
128962306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
129062306a36Sopenharmony_ci			"[BTCoex], Wifi non connected-idle + BT Busy!!\n");
129162306a36Sopenharmony_ci		btc8821a1ant_sw_mechanism(btcoexist, false);
129262306a36Sopenharmony_ci
129362306a36Sopenharmony_ci		common = true;
129462306a36Sopenharmony_ci	} else {
129562306a36Sopenharmony_ci		if (wifi_busy) {
129662306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
129762306a36Sopenharmony_ci				"[BTCoex], Wifi Connected-Busy + BT Busy!!\n");
129862306a36Sopenharmony_ci		} else {
129962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
130062306a36Sopenharmony_ci				"[BTCoex], Wifi Connected-Idle + BT Busy!!\n");
130162306a36Sopenharmony_ci		}
130262306a36Sopenharmony_ci
130362306a36Sopenharmony_ci		common = false;
130462306a36Sopenharmony_ci	}
130562306a36Sopenharmony_ci
130662306a36Sopenharmony_ci	return common;
130762306a36Sopenharmony_ci}
130862306a36Sopenharmony_ci
130962306a36Sopenharmony_cistatic void btc8821a1ant_ps_tdma_check_for_pwr_save(struct btc_coexist *btcoex,
131062306a36Sopenharmony_ci						    bool new_ps_state)
131162306a36Sopenharmony_ci{
131262306a36Sopenharmony_ci	u8 lps_mode = 0x0;
131362306a36Sopenharmony_ci
131462306a36Sopenharmony_ci	btcoex->btc_get(btcoex, BTC_GET_U1_LPS_MODE, &lps_mode);
131562306a36Sopenharmony_ci
131662306a36Sopenharmony_ci	if (lps_mode) {
131762306a36Sopenharmony_ci		/* already under LPS state */
131862306a36Sopenharmony_ci		if (new_ps_state) {
131962306a36Sopenharmony_ci			/* keep state under LPS, do nothing */
132062306a36Sopenharmony_ci		} else {
132162306a36Sopenharmony_ci			/* will leave LPS state, turn off psTdma first */
132262306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoex, NORMAL_EXEC, false, 0);
132362306a36Sopenharmony_ci		}
132462306a36Sopenharmony_ci	} else {
132562306a36Sopenharmony_ci		/* NO PS state*/
132662306a36Sopenharmony_ci		if (new_ps_state) {
132762306a36Sopenharmony_ci			/* will enter LPS state, turn off psTdma first */
132862306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoex, NORMAL_EXEC, false, 0);
132962306a36Sopenharmony_ci		} else {
133062306a36Sopenharmony_ci			/* keep state under NO PS state, do nothing */
133162306a36Sopenharmony_ci		}
133262306a36Sopenharmony_ci	}
133362306a36Sopenharmony_ci}
133462306a36Sopenharmony_ci
133562306a36Sopenharmony_cistatic void btc8821a1ant_power_save_state(struct btc_coexist *btcoexist,
133662306a36Sopenharmony_ci					  u8 ps_type, u8 lps_val, u8 rpwm_val)
133762306a36Sopenharmony_ci{
133862306a36Sopenharmony_ci	bool low_pwr_disable = false;
133962306a36Sopenharmony_ci
134062306a36Sopenharmony_ci	switch (ps_type) {
134162306a36Sopenharmony_ci	case BTC_PS_WIFI_NATIVE:
134262306a36Sopenharmony_ci		/* recover to original 32k low power setting */
134362306a36Sopenharmony_ci		low_pwr_disable = false;
134462306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
134562306a36Sopenharmony_ci				   &low_pwr_disable);
134662306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL);
134762306a36Sopenharmony_ci		break;
134862306a36Sopenharmony_ci	case BTC_PS_LPS_ON:
134962306a36Sopenharmony_ci		btc8821a1ant_ps_tdma_check_for_pwr_save(btcoexist,
135062306a36Sopenharmony_ci							true);
135162306a36Sopenharmony_ci		btc8821a1ant_lps_rpwm(btcoexist, NORMAL_EXEC, lps_val,
135262306a36Sopenharmony_ci				      rpwm_val);
135362306a36Sopenharmony_ci		/* when coex force to enter LPS, do not enter 32k low power */
135462306a36Sopenharmony_ci		low_pwr_disable = true;
135562306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER,
135662306a36Sopenharmony_ci				   &low_pwr_disable);
135762306a36Sopenharmony_ci		/* power save must executed before psTdma */
135862306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL);
135962306a36Sopenharmony_ci		break;
136062306a36Sopenharmony_ci	case BTC_PS_LPS_OFF:
136162306a36Sopenharmony_ci		btc8821a1ant_ps_tdma_check_for_pwr_save(btcoexist, false);
136262306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL);
136362306a36Sopenharmony_ci		break;
136462306a36Sopenharmony_ci	default:
136562306a36Sopenharmony_ci		break;
136662306a36Sopenharmony_ci	}
136762306a36Sopenharmony_ci}
136862306a36Sopenharmony_ci
136962306a36Sopenharmony_cistatic void btc8821a1ant_coex_under_5g(struct btc_coexist *btcoexist)
137062306a36Sopenharmony_ci{
137162306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
137262306a36Sopenharmony_ci				      0x0, 0x0);
137362306a36Sopenharmony_ci	btc8821a1ant_ignore_wlan_act(btcoexist, NORMAL_EXEC, true);
137462306a36Sopenharmony_ci
137562306a36Sopenharmony_ci	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 10);
137662306a36Sopenharmony_ci
137762306a36Sopenharmony_ci	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
137862306a36Sopenharmony_ci
137962306a36Sopenharmony_ci	btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
138062306a36Sopenharmony_ci
138162306a36Sopenharmony_ci	btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 5);
138262306a36Sopenharmony_ci}
138362306a36Sopenharmony_ci
138462306a36Sopenharmony_ci/***********************************************
138562306a36Sopenharmony_ci *
138662306a36Sopenharmony_ci *	Software Coex Mechanism start
138762306a36Sopenharmony_ci *
138862306a36Sopenharmony_ci ***********************************************/
138962306a36Sopenharmony_ci
139062306a36Sopenharmony_ci/* SCO only or SCO+PAN(HS) */
139162306a36Sopenharmony_cistatic void btc8821a1ant_action_sco(struct btc_coexist *btcoexist)
139262306a36Sopenharmony_ci{
139362306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, true);
139462306a36Sopenharmony_ci}
139562306a36Sopenharmony_ci
139662306a36Sopenharmony_cistatic void btc8821a1ant_action_hid(struct btc_coexist *btcoexist)
139762306a36Sopenharmony_ci{
139862306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, true);
139962306a36Sopenharmony_ci}
140062306a36Sopenharmony_ci
140162306a36Sopenharmony_ci/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
140262306a36Sopenharmony_cistatic void btc8821a1ant_action_a2dp(struct btc_coexist *btcoexist)
140362306a36Sopenharmony_ci{
140462306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, false);
140562306a36Sopenharmony_ci}
140662306a36Sopenharmony_ci
140762306a36Sopenharmony_cistatic void btc8821a1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist)
140862306a36Sopenharmony_ci{
140962306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, false);
141062306a36Sopenharmony_ci}
141162306a36Sopenharmony_ci
141262306a36Sopenharmony_cistatic void btc8821a1ant_action_pan_edr(struct btc_coexist *btcoexist)
141362306a36Sopenharmony_ci{
141462306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, false);
141562306a36Sopenharmony_ci}
141662306a36Sopenharmony_ci
141762306a36Sopenharmony_ci/* PAN(HS) only */
141862306a36Sopenharmony_cistatic void btc8821a1ant_action_pan_hs(struct btc_coexist *btcoexist)
141962306a36Sopenharmony_ci{
142062306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, false);
142162306a36Sopenharmony_ci}
142262306a36Sopenharmony_ci
142362306a36Sopenharmony_ci/* PAN(EDR)+A2DP */
142462306a36Sopenharmony_cistatic void btc8821a1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist)
142562306a36Sopenharmony_ci{
142662306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, false);
142762306a36Sopenharmony_ci}
142862306a36Sopenharmony_ci
142962306a36Sopenharmony_cistatic void btc8821a1ant_action_pan_edr_hid(struct btc_coexist *btcoexist)
143062306a36Sopenharmony_ci{
143162306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, true);
143262306a36Sopenharmony_ci}
143362306a36Sopenharmony_ci
143462306a36Sopenharmony_ci/* HID+A2DP+PAN(EDR) */
143562306a36Sopenharmony_cistatic void btc8821a1ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist)
143662306a36Sopenharmony_ci{
143762306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, true);
143862306a36Sopenharmony_ci}
143962306a36Sopenharmony_ci
144062306a36Sopenharmony_cistatic void btc8821a1ant_action_hid_a2dp(struct btc_coexist *btcoexist)
144162306a36Sopenharmony_ci{
144262306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, true);
144362306a36Sopenharmony_ci}
144462306a36Sopenharmony_ci
144562306a36Sopenharmony_ci/***********************************************
144662306a36Sopenharmony_ci *
144762306a36Sopenharmony_ci *	Non-Software Coex Mechanism start
144862306a36Sopenharmony_ci *
144962306a36Sopenharmony_ci ***********************************************/
145062306a36Sopenharmony_cistatic
145162306a36Sopenharmony_civoid btc8821a1ant_action_wifi_multi_port(struct btc_coexist *btcoexist)
145262306a36Sopenharmony_ci{
145362306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
145462306a36Sopenharmony_ci
145562306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
145662306a36Sopenharmony_ci	/* tdma and coex table */
145762306a36Sopenharmony_ci	if (coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_ACL_BUSY) {
145862306a36Sopenharmony_ci		if (bt_link_info->a2dp_exist) {
145962306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
146062306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
146162306a36Sopenharmony_ci							  NORMAL_EXEC, 1);
146262306a36Sopenharmony_ci		} else if (bt_link_info->a2dp_exist &&
146362306a36Sopenharmony_ci			   bt_link_info->pan_exist) {
146462306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
146562306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
146662306a36Sopenharmony_ci							  NORMAL_EXEC, 4);
146762306a36Sopenharmony_ci		} else {
146862306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
146962306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
147062306a36Sopenharmony_ci							  NORMAL_EXEC, 4);
147162306a36Sopenharmony_ci		}
147262306a36Sopenharmony_ci	} else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
147362306a36Sopenharmony_ci		   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
147462306a36Sopenharmony_ci		    coex_dm->bt_status)) {
147562306a36Sopenharmony_ci		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
147662306a36Sopenharmony_ci				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
147762306a36Sopenharmony_ci	} else {
147862306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
147962306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
148062306a36Sopenharmony_ci	}
148162306a36Sopenharmony_ci}
148262306a36Sopenharmony_ci
148362306a36Sopenharmony_cistatic
148462306a36Sopenharmony_civoid btc8821a1ant_action_wifi_not_connected_asso_auth(
148562306a36Sopenharmony_ci					struct btc_coexist *btcoexist)
148662306a36Sopenharmony_ci{
148762306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
148862306a36Sopenharmony_ci
148962306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0,
149062306a36Sopenharmony_ci				      0x0);
149162306a36Sopenharmony_ci
149262306a36Sopenharmony_ci	/* tdma and coex table */
149362306a36Sopenharmony_ci	if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist)) {
149462306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
149562306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
149662306a36Sopenharmony_ci	} else if ((bt_link_info->a2dp_exist) || (bt_link_info->pan_exist)) {
149762306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
149862306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
149962306a36Sopenharmony_ci	} else {
150062306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
150162306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
150262306a36Sopenharmony_ci	}
150362306a36Sopenharmony_ci}
150462306a36Sopenharmony_ci
150562306a36Sopenharmony_ci
150662306a36Sopenharmony_cistatic void btc8821a1ant_action_hs(struct btc_coexist *btcoexist)
150762306a36Sopenharmony_ci{
150862306a36Sopenharmony_ci	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
150962306a36Sopenharmony_ci	btc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2);
151062306a36Sopenharmony_ci}
151162306a36Sopenharmony_ci
151262306a36Sopenharmony_cistatic void btc8821a1ant_action_bt_inquiry(struct btc_coexist *btcoexist)
151362306a36Sopenharmony_ci{
151462306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
151562306a36Sopenharmony_ci	bool wifi_connected = false;
151662306a36Sopenharmony_ci	bool ap_enable = false;
151762306a36Sopenharmony_ci	bool wifi_busy = false, bt_busy = false;
151862306a36Sopenharmony_ci
151962306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
152062306a36Sopenharmony_ci			   &wifi_connected);
152162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
152262306a36Sopenharmony_ci			   &ap_enable);
152362306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
152462306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
152562306a36Sopenharmony_ci
152662306a36Sopenharmony_ci	if (!wifi_connected && !coex_sta->wifi_is_high_pri_task) {
152762306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist,
152862306a36Sopenharmony_ci					      BTC_PS_WIFI_NATIVE, 0x0, 0x0);
152962306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
153062306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
153162306a36Sopenharmony_ci	} else if ((bt_link_info->sco_exist) || (bt_link_info->a2dp_exist) ||
153262306a36Sopenharmony_ci		   (bt_link_info->hid_only)) {
153362306a36Sopenharmony_ci		/* SCO/HID-only busy */
153462306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist,
153562306a36Sopenharmony_ci					      BTC_PS_WIFI_NATIVE, 0x0, 0x0);
153662306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
153762306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
153862306a36Sopenharmony_ci	} else if ((bt_link_info->a2dp_exist) && (bt_link_info->hid_exist)) {
153962306a36Sopenharmony_ci		/* A2DP+HID busy */
154062306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
154162306a36Sopenharmony_ci					      0x0, 0x0);
154262306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
154362306a36Sopenharmony_ci
154462306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
154562306a36Sopenharmony_ci	} else if ((bt_link_info->pan_exist) || (wifi_busy)) {
154662306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
154762306a36Sopenharmony_ci					      0x0, 0x0);
154862306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
154962306a36Sopenharmony_ci
155062306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
155162306a36Sopenharmony_ci	} else {
155262306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
155362306a36Sopenharmony_ci					      0x0, 0x0);
155462306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
155562306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
155662306a36Sopenharmony_ci	}
155762306a36Sopenharmony_ci}
155862306a36Sopenharmony_ci
155962306a36Sopenharmony_cistatic void btc8821a1ant_act_bt_sco_hid_only_busy(struct btc_coexist *btcoexist,
156062306a36Sopenharmony_ci						  u8 wifi_status)
156162306a36Sopenharmony_ci{
156262306a36Sopenharmony_ci	/* tdma and coex table */
156362306a36Sopenharmony_ci	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
156462306a36Sopenharmony_ci
156562306a36Sopenharmony_ci	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
156662306a36Sopenharmony_ci}
156762306a36Sopenharmony_ci
156862306a36Sopenharmony_cistatic void btc8821a1ant_act_wifi_con_bt_acl_busy(struct btc_coexist *btcoexist,
156962306a36Sopenharmony_ci						  u8 wifi_status)
157062306a36Sopenharmony_ci{
157162306a36Sopenharmony_ci	u8 bt_rssi_state;
157262306a36Sopenharmony_ci
157362306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
157462306a36Sopenharmony_ci
157562306a36Sopenharmony_ci	bt_rssi_state = btc8821a1ant_bt_rssi_state(btcoexist, 2, 28, 0);
157662306a36Sopenharmony_ci
157762306a36Sopenharmony_ci	if (bt_link_info->hid_only) {
157862306a36Sopenharmony_ci		/* HID */
157962306a36Sopenharmony_ci		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
158062306a36Sopenharmony_ci						      wifi_status);
158162306a36Sopenharmony_ci		coex_dm->auto_tdma_adjust = false;
158262306a36Sopenharmony_ci		return;
158362306a36Sopenharmony_ci	} else if (bt_link_info->a2dp_only) {
158462306a36Sopenharmony_ci		/* A2DP */
158562306a36Sopenharmony_ci		if (wifi_status == BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE) {
158662306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
158762306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
158862306a36Sopenharmony_ci							  NORMAL_EXEC, 1);
158962306a36Sopenharmony_ci			coex_dm->auto_tdma_adjust = false;
159062306a36Sopenharmony_ci		} else if ((bt_rssi_state != BTC_RSSI_STATE_HIGH) &&
159162306a36Sopenharmony_ci			   (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
159262306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
159362306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
159462306a36Sopenharmony_ci							  NORMAL_EXEC, 1);
159562306a36Sopenharmony_ci		} else {
159662306a36Sopenharmony_ci			/* for low BT RSSI */
159762306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
159862306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
159962306a36Sopenharmony_ci							  NORMAL_EXEC, 1);
160062306a36Sopenharmony_ci			coex_dm->auto_tdma_adjust = false;
160162306a36Sopenharmony_ci		}
160262306a36Sopenharmony_ci	} else if (bt_link_info->hid_exist && bt_link_info->a2dp_exist) {
160362306a36Sopenharmony_ci		/* HID+A2DP (no need to consider BT RSSI) */
160462306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC,
160562306a36Sopenharmony_ci				     true, 14);
160662306a36Sopenharmony_ci		coex_dm->auto_tdma_adjust = false;
160762306a36Sopenharmony_ci
160862306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
160962306a36Sopenharmony_ci	} else if ((bt_link_info->pan_only) ||
161062306a36Sopenharmony_ci		(bt_link_info->hid_exist && bt_link_info->pan_exist)) {
161162306a36Sopenharmony_ci		/* PAN(OPP, FTP), HID+PAN(OPP, FTP) */
161262306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3);
161362306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6);
161462306a36Sopenharmony_ci		coex_dm->auto_tdma_adjust = false;
161562306a36Sopenharmony_ci	} else if (((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) ||
161662306a36Sopenharmony_ci		   (bt_link_info->hid_exist && bt_link_info->a2dp_exist &&
161762306a36Sopenharmony_ci		    bt_link_info->pan_exist)) {
161862306a36Sopenharmony_ci		/* A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP) */
161962306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 43);
162062306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
162162306a36Sopenharmony_ci		coex_dm->auto_tdma_adjust = false;
162262306a36Sopenharmony_ci	} else {
162362306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11);
162462306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
162562306a36Sopenharmony_ci		coex_dm->auto_tdma_adjust = false;
162662306a36Sopenharmony_ci	}
162762306a36Sopenharmony_ci}
162862306a36Sopenharmony_ci
162962306a36Sopenharmony_cistatic
163062306a36Sopenharmony_civoid btc8821a1ant_action_wifi_not_connected(struct btc_coexist *btcoexist)
163162306a36Sopenharmony_ci{
163262306a36Sopenharmony_ci	/* power save state */
163362306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
163462306a36Sopenharmony_ci
163562306a36Sopenharmony_ci	/* tdma and coex table */
163662306a36Sopenharmony_ci	btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
163762306a36Sopenharmony_ci	btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
163862306a36Sopenharmony_ci}
163962306a36Sopenharmony_ci
164062306a36Sopenharmony_cistatic void btc8821a1ant_act_wifi_not_conn_scan(struct btc_coexist *btcoexist)
164162306a36Sopenharmony_ci{
164262306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
164362306a36Sopenharmony_ci
164462306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
164562306a36Sopenharmony_ci
164662306a36Sopenharmony_ci	/* tdma and coex table */
164762306a36Sopenharmony_ci	if (coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_ACL_BUSY) {
164862306a36Sopenharmony_ci		if (bt_link_info->a2dp_exist) {
164962306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
165062306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
165162306a36Sopenharmony_ci							  NORMAL_EXEC, 1);
165262306a36Sopenharmony_ci		} else if (bt_link_info->a2dp_exist &&
165362306a36Sopenharmony_ci			   bt_link_info->pan_exist) {
165462306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
165562306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
165662306a36Sopenharmony_ci							  NORMAL_EXEC, 4);
165762306a36Sopenharmony_ci		} else {
165862306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
165962306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
166062306a36Sopenharmony_ci							  NORMAL_EXEC, 4);
166162306a36Sopenharmony_ci		}
166262306a36Sopenharmony_ci	} else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
166362306a36Sopenharmony_ci		   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
166462306a36Sopenharmony_ci		    coex_dm->bt_status)) {
166562306a36Sopenharmony_ci		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
166662306a36Sopenharmony_ci				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
166762306a36Sopenharmony_ci	} else {
166862306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
166962306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
167062306a36Sopenharmony_ci	}
167162306a36Sopenharmony_ci}
167262306a36Sopenharmony_ci
167362306a36Sopenharmony_cistatic
167462306a36Sopenharmony_civoid btc8821a1ant_action_wifi_connected_scan(struct btc_coexist *btcoexist)
167562306a36Sopenharmony_ci{
167662306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
167762306a36Sopenharmony_ci
167862306a36Sopenharmony_ci	/* power save state */
167962306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist,
168062306a36Sopenharmony_ci				      BTC_PS_WIFI_NATIVE, 0x0, 0x0);
168162306a36Sopenharmony_ci
168262306a36Sopenharmony_ci	/* tdma and coex table */
168362306a36Sopenharmony_ci	if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
168462306a36Sopenharmony_ci		if (bt_link_info->a2dp_exist) {
168562306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
168662306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
168762306a36Sopenharmony_ci							  NORMAL_EXEC, 1);
168862306a36Sopenharmony_ci		} else {
168962306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
169062306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
169162306a36Sopenharmony_ci							  NORMAL_EXEC, 4);
169262306a36Sopenharmony_ci		}
169362306a36Sopenharmony_ci	} else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
169462306a36Sopenharmony_ci		   (coex_dm->bt_status ==
169562306a36Sopenharmony_ci		    BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY)) {
169662306a36Sopenharmony_ci		btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
169762306a36Sopenharmony_ci			BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
169862306a36Sopenharmony_ci	} else {
169962306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
170062306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
170162306a36Sopenharmony_ci	}
170262306a36Sopenharmony_ci}
170362306a36Sopenharmony_ci
170462306a36Sopenharmony_cistatic void btc8821a1ant_act_wifi_conn_sp_pkt(struct btc_coexist *btcoexist)
170562306a36Sopenharmony_ci{
170662306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
170762306a36Sopenharmony_ci
170862306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
170962306a36Sopenharmony_ci				      0x0, 0x0);
171062306a36Sopenharmony_ci
171162306a36Sopenharmony_ci	/* tdma and coex table */
171262306a36Sopenharmony_ci	if ((bt_link_info->sco_exist) || (bt_link_info->hid_exist) ||
171362306a36Sopenharmony_ci	    (bt_link_info->a2dp_exist)) {
171462306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
171562306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
171662306a36Sopenharmony_ci	}
171762306a36Sopenharmony_ci
171862306a36Sopenharmony_ci	if ((bt_link_info->hid_exist) && (bt_link_info->a2dp_exist)) {
171962306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
172062306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
172162306a36Sopenharmony_ci	} else if (bt_link_info->pan_exist) {
172262306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
172362306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
172462306a36Sopenharmony_ci	} else {
172562306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
172662306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
172762306a36Sopenharmony_ci	}
172862306a36Sopenharmony_ci}
172962306a36Sopenharmony_ci
173062306a36Sopenharmony_cistatic void btc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist)
173162306a36Sopenharmony_ci{
173262306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
173362306a36Sopenharmony_ci	bool wifi_busy = false;
173462306a36Sopenharmony_ci	bool scan = false, link = false, roam = false;
173562306a36Sopenharmony_ci	bool under_4way = false;
173662306a36Sopenharmony_ci	bool ap_enable = false;
173762306a36Sopenharmony_ci
173862306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
173962306a36Sopenharmony_ci		"[BTCoex], CoexForWifiConnect()===>\n");
174062306a36Sopenharmony_ci
174162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
174262306a36Sopenharmony_ci			   &under_4way);
174362306a36Sopenharmony_ci	if (under_4way) {
174462306a36Sopenharmony_ci		btc8821a1ant_act_wifi_conn_sp_pkt(btcoexist);
174562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
174662306a36Sopenharmony_ci			"[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n");
174762306a36Sopenharmony_ci		return;
174862306a36Sopenharmony_ci	}
174962306a36Sopenharmony_ci
175062306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
175162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
175262306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
175362306a36Sopenharmony_ci	if (scan || link || roam) {
175462306a36Sopenharmony_ci		if (scan)
175562306a36Sopenharmony_ci			btc8821a1ant_action_wifi_connected_scan(btcoexist);
175662306a36Sopenharmony_ci		else
175762306a36Sopenharmony_ci			btc8821a1ant_act_wifi_conn_sp_pkt(btcoexist);
175862306a36Sopenharmony_ci
175962306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
176062306a36Sopenharmony_ci			"[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n");
176162306a36Sopenharmony_ci		return;
176262306a36Sopenharmony_ci	}
176362306a36Sopenharmony_ci
176462306a36Sopenharmony_ci	/* power save state*/
176562306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
176662306a36Sopenharmony_ci			   &ap_enable);
176762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
176862306a36Sopenharmony_ci	if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY ==
176962306a36Sopenharmony_ci	    coex_dm->bt_status && !ap_enable &&
177062306a36Sopenharmony_ci	    !btcoexist->bt_link_info.hid_only) {
177162306a36Sopenharmony_ci		if (!wifi_busy && btcoexist->bt_link_info.a2dp_only)
177262306a36Sopenharmony_ci			/* A2DP */
177362306a36Sopenharmony_ci			btc8821a1ant_power_save_state(btcoexist,
177462306a36Sopenharmony_ci						BTC_PS_WIFI_NATIVE, 0x0, 0x0);
177562306a36Sopenharmony_ci		else
177662306a36Sopenharmony_ci			btc8821a1ant_power_save_state(btcoexist, BTC_PS_LPS_ON,
177762306a36Sopenharmony_ci						      0x50, 0x4);
177862306a36Sopenharmony_ci	} else {
177962306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist,
178062306a36Sopenharmony_ci					      BTC_PS_WIFI_NATIVE,
178162306a36Sopenharmony_ci					      0x0, 0x0);
178262306a36Sopenharmony_ci	}
178362306a36Sopenharmony_ci
178462306a36Sopenharmony_ci	/* tdma and coex table */
178562306a36Sopenharmony_ci	if (!wifi_busy) {
178662306a36Sopenharmony_ci		if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
178762306a36Sopenharmony_ci			btc8821a1ant_act_wifi_con_bt_acl_busy(btcoexist,
178862306a36Sopenharmony_ci				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
178962306a36Sopenharmony_ci		} else if ((BT_8821A_1ANT_BT_STATUS_SCO_BUSY ==
179062306a36Sopenharmony_ci			    coex_dm->bt_status) ||
179162306a36Sopenharmony_ci			   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
179262306a36Sopenharmony_ci			    coex_dm->bt_status)) {
179362306a36Sopenharmony_ci			btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
179462306a36Sopenharmony_ci				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE);
179562306a36Sopenharmony_ci		} else {
179662306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
179762306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
179862306a36Sopenharmony_ci							  NORMAL_EXEC, 2);
179962306a36Sopenharmony_ci		}
180062306a36Sopenharmony_ci	} else {
180162306a36Sopenharmony_ci		if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) {
180262306a36Sopenharmony_ci			btc8821a1ant_act_wifi_con_bt_acl_busy(btcoexist,
180362306a36Sopenharmony_ci				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
180462306a36Sopenharmony_ci		} else if ((BT_8821A_1ANT_BT_STATUS_SCO_BUSY ==
180562306a36Sopenharmony_ci			    coex_dm->bt_status) ||
180662306a36Sopenharmony_ci			   (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
180762306a36Sopenharmony_ci			    coex_dm->bt_status)) {
180862306a36Sopenharmony_ci			btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
180962306a36Sopenharmony_ci				BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY);
181062306a36Sopenharmony_ci		} else {
181162306a36Sopenharmony_ci			btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
181262306a36Sopenharmony_ci			btc8821a1ant_coex_table_with_type(btcoexist,
181362306a36Sopenharmony_ci							  NORMAL_EXEC, 2);
181462306a36Sopenharmony_ci		}
181562306a36Sopenharmony_ci	}
181662306a36Sopenharmony_ci}
181762306a36Sopenharmony_ci
181862306a36Sopenharmony_cistatic void btc8821a1ant_run_sw_coex_mech(struct btc_coexist *btcoexist)
181962306a36Sopenharmony_ci{
182062306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
182162306a36Sopenharmony_ci	u8 algorithm = 0;
182262306a36Sopenharmony_ci
182362306a36Sopenharmony_ci	algorithm = btc8821a1ant_action_algorithm(btcoexist);
182462306a36Sopenharmony_ci	coex_dm->cur_algorithm = algorithm;
182562306a36Sopenharmony_ci
182662306a36Sopenharmony_ci	if (!btc8821a1ant_is_common_action(btcoexist)) {
182762306a36Sopenharmony_ci		switch (coex_dm->cur_algorithm) {
182862306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_SCO:
182962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
183062306a36Sopenharmony_ci				"[BTCoex], Action algorithm = SCO\n");
183162306a36Sopenharmony_ci			btc8821a1ant_action_sco(btcoexist);
183262306a36Sopenharmony_ci			break;
183362306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_HID:
183462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
183562306a36Sopenharmony_ci				"[BTCoex], Action algorithm = HID\n");
183662306a36Sopenharmony_ci			btc8821a1ant_action_hid(btcoexist);
183762306a36Sopenharmony_ci			break;
183862306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_A2DP:
183962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
184062306a36Sopenharmony_ci				"[BTCoex], Action algorithm = A2DP\n");
184162306a36Sopenharmony_ci			btc8821a1ant_action_a2dp(btcoexist);
184262306a36Sopenharmony_ci			break;
184362306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS:
184462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
184562306a36Sopenharmony_ci				"[BTCoex], Action algorithm = A2DP+PAN(HS)\n");
184662306a36Sopenharmony_ci			btc8821a1ant_action_a2dp_pan_hs(btcoexist);
184762306a36Sopenharmony_ci			break;
184862306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_PANEDR:
184962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
185062306a36Sopenharmony_ci				"[BTCoex], Action algorithm = PAN(EDR)\n");
185162306a36Sopenharmony_ci			btc8821a1ant_action_pan_edr(btcoexist);
185262306a36Sopenharmony_ci			break;
185362306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_PANHS:
185462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
185562306a36Sopenharmony_ci				"[BTCoex], Action algorithm = HS mode\n");
185662306a36Sopenharmony_ci			btc8821a1ant_action_pan_hs(btcoexist);
185762306a36Sopenharmony_ci			break;
185862306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP:
185962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
186062306a36Sopenharmony_ci				"[BTCoex], Action algorithm = PAN+A2DP\n");
186162306a36Sopenharmony_ci			btc8821a1ant_action_pan_edr_a2dp(btcoexist);
186262306a36Sopenharmony_ci			break;
186362306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_PANEDR_HID:
186462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
186562306a36Sopenharmony_ci				"[BTCoex], Action algorithm = PAN(EDR)+HID\n");
186662306a36Sopenharmony_ci			btc8821a1ant_action_pan_edr_hid(btcoexist);
186762306a36Sopenharmony_ci			break;
186862306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR:
186962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
187062306a36Sopenharmony_ci				"[BTCoex], Action algorithm = HID+A2DP+PAN\n");
187162306a36Sopenharmony_ci			btc8821a1ant_action_hid_a2dp_pan_edr(btcoexist);
187262306a36Sopenharmony_ci			break;
187362306a36Sopenharmony_ci		case BT_8821A_1ANT_COEX_ALGO_HID_A2DP:
187462306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
187562306a36Sopenharmony_ci				"[BTCoex], Action algorithm = HID+A2DP\n");
187662306a36Sopenharmony_ci			btc8821a1ant_action_hid_a2dp(btcoexist);
187762306a36Sopenharmony_ci			break;
187862306a36Sopenharmony_ci		default:
187962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
188062306a36Sopenharmony_ci				"[BTCoex], Action algorithm = coexist All Off!!\n");
188162306a36Sopenharmony_ci			/*btc8821a1ant_coex_all_off(btcoexist);*/
188262306a36Sopenharmony_ci			break;
188362306a36Sopenharmony_ci		}
188462306a36Sopenharmony_ci		coex_dm->pre_algorithm = coex_dm->cur_algorithm;
188562306a36Sopenharmony_ci	}
188662306a36Sopenharmony_ci}
188762306a36Sopenharmony_ci
188862306a36Sopenharmony_cistatic void btc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist)
188962306a36Sopenharmony_ci{
189062306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
189162306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
189262306a36Sopenharmony_ci	bool wifi_connected = false, bt_hs_on = false;
189362306a36Sopenharmony_ci	bool increase_scan_dev_num = false;
189462306a36Sopenharmony_ci	bool bt_ctrl_agg_buf_size = false;
189562306a36Sopenharmony_ci	u8 agg_buf_size = 5;
189662306a36Sopenharmony_ci	u32 wifi_link_status = 0;
189762306a36Sopenharmony_ci	u32 num_of_wifi_link = 0;
189862306a36Sopenharmony_ci	bool wifi_under_5g = false;
189962306a36Sopenharmony_ci
190062306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
190162306a36Sopenharmony_ci		"[BTCoex], RunCoexistMechanism()===>\n");
190262306a36Sopenharmony_ci
190362306a36Sopenharmony_ci	if (btcoexist->manual_control) {
190462306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
190562306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n");
190662306a36Sopenharmony_ci		return;
190762306a36Sopenharmony_ci	}
190862306a36Sopenharmony_ci
190962306a36Sopenharmony_ci	if (btcoexist->stop_coex_dm) {
191062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
191162306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n");
191262306a36Sopenharmony_ci		return;
191362306a36Sopenharmony_ci	}
191462306a36Sopenharmony_ci
191562306a36Sopenharmony_ci	if (coex_sta->under_ips) {
191662306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
191762306a36Sopenharmony_ci			"[BTCoex], wifi is under IPS !!!\n");
191862306a36Sopenharmony_ci		return;
191962306a36Sopenharmony_ci	}
192062306a36Sopenharmony_ci
192162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
192262306a36Sopenharmony_ci	if (wifi_under_5g) {
192362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
192462306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
192562306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
192662306a36Sopenharmony_ci		return;
192762306a36Sopenharmony_ci	}
192862306a36Sopenharmony_ci
192962306a36Sopenharmony_ci	if ((BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
193062306a36Sopenharmony_ci	    (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
193162306a36Sopenharmony_ci	    (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status))
193262306a36Sopenharmony_ci		increase_scan_dev_num = true;
193362306a36Sopenharmony_ci
193462306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM,
193562306a36Sopenharmony_ci			   &increase_scan_dev_num);
193662306a36Sopenharmony_ci
193762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
193862306a36Sopenharmony_ci			   &wifi_connected);
193962306a36Sopenharmony_ci
194062306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
194162306a36Sopenharmony_ci			   &wifi_link_status);
194262306a36Sopenharmony_ci	num_of_wifi_link = wifi_link_status >> 16;
194362306a36Sopenharmony_ci	if ((num_of_wifi_link >= 2) ||
194462306a36Sopenharmony_ci	    (wifi_link_status & WIFI_P2P_GO_CONNECTED)) {
194562306a36Sopenharmony_ci		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
194662306a36Sopenharmony_ci		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
194762306a36Sopenharmony_ci					bt_ctrl_agg_buf_size, agg_buf_size);
194862306a36Sopenharmony_ci		btc8821a1ant_action_wifi_multi_port(btcoexist);
194962306a36Sopenharmony_ci		return;
195062306a36Sopenharmony_ci	}
195162306a36Sopenharmony_ci
195262306a36Sopenharmony_ci	if (!bt_link_info->sco_exist && !bt_link_info->hid_exist) {
195362306a36Sopenharmony_ci		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
195462306a36Sopenharmony_ci	} else {
195562306a36Sopenharmony_ci		if (wifi_connected) {
195662306a36Sopenharmony_ci			btc8821a1ant_wifi_rssi_state(btcoexist, 1, 2,
195762306a36Sopenharmony_ci							     30, 0);
195862306a36Sopenharmony_ci			btc8821a1ant_limited_tx(btcoexist,
195962306a36Sopenharmony_ci						NORMAL_EXEC, 1, 1,
196062306a36Sopenharmony_ci						0, 1);
196162306a36Sopenharmony_ci		} else {
196262306a36Sopenharmony_ci			btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC,
196362306a36Sopenharmony_ci						0, 0, 0, 0);
196462306a36Sopenharmony_ci		}
196562306a36Sopenharmony_ci	}
196662306a36Sopenharmony_ci
196762306a36Sopenharmony_ci	if (bt_link_info->sco_exist) {
196862306a36Sopenharmony_ci		bt_ctrl_agg_buf_size = true;
196962306a36Sopenharmony_ci		agg_buf_size = 0x3;
197062306a36Sopenharmony_ci	} else if (bt_link_info->hid_exist) {
197162306a36Sopenharmony_ci		bt_ctrl_agg_buf_size = true;
197262306a36Sopenharmony_ci		agg_buf_size = 0x5;
197362306a36Sopenharmony_ci	} else if (bt_link_info->a2dp_exist || bt_link_info->pan_exist) {
197462306a36Sopenharmony_ci		bt_ctrl_agg_buf_size = true;
197562306a36Sopenharmony_ci		agg_buf_size = 0x8;
197662306a36Sopenharmony_ci	}
197762306a36Sopenharmony_ci	btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
197862306a36Sopenharmony_ci				bt_ctrl_agg_buf_size, agg_buf_size);
197962306a36Sopenharmony_ci
198062306a36Sopenharmony_ci	btc8821a1ant_run_sw_coex_mech(btcoexist);
198162306a36Sopenharmony_ci
198262306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
198362306a36Sopenharmony_ci	if (coex_sta->c2h_bt_inquiry_page) {
198462306a36Sopenharmony_ci		btc8821a1ant_action_bt_inquiry(btcoexist);
198562306a36Sopenharmony_ci		return;
198662306a36Sopenharmony_ci	} else if (bt_hs_on) {
198762306a36Sopenharmony_ci		btc8821a1ant_action_hs(btcoexist);
198862306a36Sopenharmony_ci		return;
198962306a36Sopenharmony_ci	}
199062306a36Sopenharmony_ci
199162306a36Sopenharmony_ci	if (!wifi_connected) {
199262306a36Sopenharmony_ci		bool scan = false, link = false, roam = false;
199362306a36Sopenharmony_ci
199462306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
199562306a36Sopenharmony_ci			"[BTCoex], wifi is non connected-idle !!!\n");
199662306a36Sopenharmony_ci
199762306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
199862306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
199962306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
200062306a36Sopenharmony_ci
200162306a36Sopenharmony_ci		if (scan || link || roam) {
200262306a36Sopenharmony_ci			if (scan)
200362306a36Sopenharmony_ci				btc8821a1ant_act_wifi_not_conn_scan(btcoexist);
200462306a36Sopenharmony_ci			else
200562306a36Sopenharmony_ci				btc8821a1ant_action_wifi_not_connected_asso_auth(
200662306a36Sopenharmony_ci					btcoexist);
200762306a36Sopenharmony_ci		} else {
200862306a36Sopenharmony_ci			btc8821a1ant_action_wifi_not_connected(btcoexist);
200962306a36Sopenharmony_ci		}
201062306a36Sopenharmony_ci	} else {
201162306a36Sopenharmony_ci		/* wifi LPS/Busy */
201262306a36Sopenharmony_ci		btc8821a1ant_action_wifi_connected(btcoexist);
201362306a36Sopenharmony_ci	}
201462306a36Sopenharmony_ci}
201562306a36Sopenharmony_ci
201662306a36Sopenharmony_cistatic void btc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist)
201762306a36Sopenharmony_ci{
201862306a36Sopenharmony_ci	/* force to reset coex mechanism
201962306a36Sopenharmony_ci	 * sw all off
202062306a36Sopenharmony_ci	 */
202162306a36Sopenharmony_ci	btc8821a1ant_sw_mechanism(btcoexist, false);
202262306a36Sopenharmony_ci
202362306a36Sopenharmony_ci	btc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
202462306a36Sopenharmony_ci}
202562306a36Sopenharmony_ci
202662306a36Sopenharmony_cistatic void btc8821a1ant_init_hw_config(struct btc_coexist *btcoexist,
202762306a36Sopenharmony_ci					bool back_up, bool wifi_only)
202862306a36Sopenharmony_ci{
202962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
203062306a36Sopenharmony_ci	u8 u1_tmp = 0;
203162306a36Sopenharmony_ci	bool wifi_under_5g = false;
203262306a36Sopenharmony_ci
203362306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
203462306a36Sopenharmony_ci		"[BTCoex], 1Ant Init HW Config!!\n");
203562306a36Sopenharmony_ci
203662306a36Sopenharmony_ci	if (wifi_only)
203762306a36Sopenharmony_ci		return;
203862306a36Sopenharmony_ci
203962306a36Sopenharmony_ci	if (back_up) {
204062306a36Sopenharmony_ci		coex_dm->backup_arfr_cnt1 = btcoexist->btc_read_4byte(btcoexist,
204162306a36Sopenharmony_ci								      0x430);
204262306a36Sopenharmony_ci		coex_dm->backup_arfr_cnt2 = btcoexist->btc_read_4byte(btcoexist,
204362306a36Sopenharmony_ci								      0x434);
204462306a36Sopenharmony_ci		coex_dm->backup_retry_limit =
204562306a36Sopenharmony_ci			btcoexist->btc_read_2byte(btcoexist, 0x42a);
204662306a36Sopenharmony_ci		coex_dm->backup_ampdu_max_time =
204762306a36Sopenharmony_ci			btcoexist->btc_read_1byte(btcoexist, 0x456);
204862306a36Sopenharmony_ci	}
204962306a36Sopenharmony_ci
205062306a36Sopenharmony_ci	/* 0x790[5:0] = 0x5 */
205162306a36Sopenharmony_ci	u1_tmp = btcoexist->btc_read_1byte(btcoexist, 0x790);
205262306a36Sopenharmony_ci	u1_tmp &= 0xc0;
205362306a36Sopenharmony_ci	u1_tmp |= 0x5;
205462306a36Sopenharmony_ci	btcoexist->btc_write_1byte(btcoexist, 0x790, u1_tmp);
205562306a36Sopenharmony_ci
205662306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
205762306a36Sopenharmony_ci
205862306a36Sopenharmony_ci	/* Antenna config */
205962306a36Sopenharmony_ci	if (wifi_under_5g)
206062306a36Sopenharmony_ci		btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT,
206162306a36Sopenharmony_ci					  true, false);
206262306a36Sopenharmony_ci	else
206362306a36Sopenharmony_ci		btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA,
206462306a36Sopenharmony_ci					  true, false);
206562306a36Sopenharmony_ci	/* PTA parameter */
206662306a36Sopenharmony_ci	btc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0);
206762306a36Sopenharmony_ci
206862306a36Sopenharmony_ci	/* Enable counter statistics
206962306a36Sopenharmony_ci	 * 0x76e[3] =1, WLAN_Act control by PTA
207062306a36Sopenharmony_ci	 */
207162306a36Sopenharmony_ci	btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc);
207262306a36Sopenharmony_ci	btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3);
207362306a36Sopenharmony_ci	btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1);
207462306a36Sopenharmony_ci}
207562306a36Sopenharmony_ci
207662306a36Sopenharmony_ci/**************************************************************
207762306a36Sopenharmony_ci * extern function start with ex_btc8821a1ant_
207862306a36Sopenharmony_ci **************************************************************/
207962306a36Sopenharmony_civoid ex_btc8821a1ant_init_hwconfig(struct btc_coexist *btcoexist, bool wifionly)
208062306a36Sopenharmony_ci{
208162306a36Sopenharmony_ci	btc8821a1ant_init_hw_config(btcoexist, true, wifionly);
208262306a36Sopenharmony_ci	btcoexist->auto_report_1ant = true;
208362306a36Sopenharmony_ci}
208462306a36Sopenharmony_ci
208562306a36Sopenharmony_civoid ex_btc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist)
208662306a36Sopenharmony_ci{
208762306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
208862306a36Sopenharmony_ci
208962306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
209062306a36Sopenharmony_ci		"[BTCoex], Coex Mechanism Init!!\n");
209162306a36Sopenharmony_ci
209262306a36Sopenharmony_ci	btcoexist->stop_coex_dm = false;
209362306a36Sopenharmony_ci
209462306a36Sopenharmony_ci	btc8821a1ant_init_coex_dm(btcoexist);
209562306a36Sopenharmony_ci
209662306a36Sopenharmony_ci	btc8821a1ant_query_bt_info(btcoexist);
209762306a36Sopenharmony_ci}
209862306a36Sopenharmony_ci
209962306a36Sopenharmony_civoid ex_btc8821a1ant_display_coex_info(struct btc_coexist *btcoexist,
210062306a36Sopenharmony_ci				       struct seq_file *m)
210162306a36Sopenharmony_ci{
210262306a36Sopenharmony_ci	struct btc_board_info *board_info = &btcoexist->board_info;
210362306a36Sopenharmony_ci	struct btc_stack_info *stack_info = &btcoexist->stack_info;
210462306a36Sopenharmony_ci	struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
210562306a36Sopenharmony_ci	u8 u1_tmp[4], i, bt_info_ext, ps_tdma_case = 0;
210662306a36Sopenharmony_ci	u16 u2_tmp[4];
210762306a36Sopenharmony_ci	u32 u4_tmp[4];
210862306a36Sopenharmony_ci	bool roam = false, scan = false, link = false, wifi_under_5g = false;
210962306a36Sopenharmony_ci	bool bt_hs_on = false, wifi_busy = false;
211062306a36Sopenharmony_ci	long wifi_rssi = 0, bt_hs_rssi = 0;
211162306a36Sopenharmony_ci	u32 wifi_bw, wifi_traffic_dir;
211262306a36Sopenharmony_ci	u8 wifi_dot11_chnl, wifi_hs_chnl;
211362306a36Sopenharmony_ci	u32 fw_ver = 0, bt_patch_ver = 0;
211462306a36Sopenharmony_ci
211562306a36Sopenharmony_ci	seq_puts(m, "\n ============[BT Coexist info]============");
211662306a36Sopenharmony_ci
211762306a36Sopenharmony_ci	if (btcoexist->manual_control) {
211862306a36Sopenharmony_ci		seq_puts(m, "\n ============[Under Manual Control]============");
211962306a36Sopenharmony_ci		seq_puts(m, "\n ==========================================");
212062306a36Sopenharmony_ci	}
212162306a36Sopenharmony_ci	if (btcoexist->stop_coex_dm) {
212262306a36Sopenharmony_ci		seq_puts(m, "\n ============[Coex is STOPPED]============");
212362306a36Sopenharmony_ci		seq_puts(m, "\n ==========================================");
212462306a36Sopenharmony_ci	}
212562306a36Sopenharmony_ci
212662306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d/ %d/ %d",
212762306a36Sopenharmony_ci		   "Ant PG Num/ Ant Mech/ Ant Pos:",
212862306a36Sopenharmony_ci		   board_info->pg_ant_num,
212962306a36Sopenharmony_ci		   board_info->btdm_ant_num,
213062306a36Sopenharmony_ci		   board_info->btdm_ant_pos);
213162306a36Sopenharmony_ci
213262306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %s / %d", "BT stack/ hci ext ver",
213362306a36Sopenharmony_ci		   ((stack_info->profile_notified) ? "Yes" : "No"),
213462306a36Sopenharmony_ci		   stack_info->hci_version);
213562306a36Sopenharmony_ci
213662306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER,
213762306a36Sopenharmony_ci			   &bt_patch_ver);
213862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
213962306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)",
214062306a36Sopenharmony_ci		   "CoexVer/ FwVer/ PatchVer",
214162306a36Sopenharmony_ci		   glcoex_ver_date_8821a_1ant,
214262306a36Sopenharmony_ci		   glcoex_ver_8821a_1ant,
214362306a36Sopenharmony_ci		   fw_ver, bt_patch_ver,
214462306a36Sopenharmony_ci		   bt_patch_ver);
214562306a36Sopenharmony_ci
214662306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION,
214762306a36Sopenharmony_ci			   &bt_hs_on);
214862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL,
214962306a36Sopenharmony_ci			   &wifi_dot11_chnl);
215062306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL,
215162306a36Sopenharmony_ci			   &wifi_hs_chnl);
215262306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d / %d(%d)",
215362306a36Sopenharmony_ci		   "Dot11 channel / HsChnl(HsMode)",
215462306a36Sopenharmony_ci		   wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on);
215562306a36Sopenharmony_ci
215662306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %3ph ",
215762306a36Sopenharmony_ci		   "H2C Wifi inform bt chnl Info",
215862306a36Sopenharmony_ci		   coex_dm->wifi_chnl_info);
215962306a36Sopenharmony_ci
216062306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi);
216162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi);
216262306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d/ %d", "Wifi rssi/ HS rssi",
216362306a36Sopenharmony_ci		   (int)wifi_rssi, (int)bt_hs_rssi);
216462306a36Sopenharmony_ci
216562306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan);
216662306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link);
216762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam);
216862306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d/ %d/ %d ", "Wifi link/ roam/ scan",
216962306a36Sopenharmony_ci		   link, roam, scan);
217062306a36Sopenharmony_ci
217162306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G,
217262306a36Sopenharmony_ci			   &wifi_under_5g);
217362306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW,
217462306a36Sopenharmony_ci			   &wifi_bw);
217562306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY,
217662306a36Sopenharmony_ci			   &wifi_busy);
217762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION,
217862306a36Sopenharmony_ci			   &wifi_traffic_dir);
217962306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %s / %s/ %s ", "Wifi status",
218062306a36Sopenharmony_ci		   (wifi_under_5g ? "5G" : "2.4G"),
218162306a36Sopenharmony_ci		   ((wifi_bw == BTC_WIFI_BW_LEGACY) ? "Legacy" :
218262306a36Sopenharmony_ci		   (((wifi_bw == BTC_WIFI_BW_HT40) ? "HT40" : "HT20"))),
218362306a36Sopenharmony_ci		   ((!wifi_busy) ? "idle" :
218462306a36Sopenharmony_ci		   ((wifi_traffic_dir == BTC_WIFI_TRAFFIC_TX) ?
218562306a36Sopenharmony_ci		   "uplink" : "downlink")));
218662306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = [%s/ %d/ %d] ",
218762306a36Sopenharmony_ci		   "BT [status/ rssi/ retryCnt]",
218862306a36Sopenharmony_ci		   ((coex_sta->bt_disabled) ? ("disabled") :
218962306a36Sopenharmony_ci		   ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") :
219062306a36Sopenharmony_ci		   ((BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE ==
219162306a36Sopenharmony_ci		     coex_dm->bt_status) ?
219262306a36Sopenharmony_ci		   "non-connected idle" :
219362306a36Sopenharmony_ci		   ((BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE ==
219462306a36Sopenharmony_ci		     coex_dm->bt_status) ?
219562306a36Sopenharmony_ci		   "connected-idle" : "busy")))),
219662306a36Sopenharmony_ci		   coex_sta->bt_rssi, coex_sta->bt_retry_cnt);
219762306a36Sopenharmony_ci
219862306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP",
219962306a36Sopenharmony_ci		   bt_link_info->sco_exist,
220062306a36Sopenharmony_ci		   bt_link_info->hid_exist,
220162306a36Sopenharmony_ci		   bt_link_info->pan_exist,
220262306a36Sopenharmony_ci		   bt_link_info->a2dp_exist);
220362306a36Sopenharmony_ci	btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO, m);
220462306a36Sopenharmony_ci
220562306a36Sopenharmony_ci	bt_info_ext = coex_sta->bt_info_ext;
220662306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %s",
220762306a36Sopenharmony_ci		   "BT Info A2DP rate",
220862306a36Sopenharmony_ci		   (bt_info_ext & BIT0) ?
220962306a36Sopenharmony_ci		   "Basic rate" : "EDR rate");
221062306a36Sopenharmony_ci
221162306a36Sopenharmony_ci	for (i = 0; i < BT_INFO_SRC_8821A_1ANT_MAX; i++) {
221262306a36Sopenharmony_ci		if (coex_sta->bt_info_c2h_cnt[i]) {
221362306a36Sopenharmony_ci			seq_printf(m, "\n %-35s = %7ph(%d)",
221462306a36Sopenharmony_ci				   glbt_info_src_8821a_1ant[i],
221562306a36Sopenharmony_ci				   coex_sta->bt_info_c2h[i],
221662306a36Sopenharmony_ci				   coex_sta->bt_info_c2h_cnt[i]);
221762306a36Sopenharmony_ci		}
221862306a36Sopenharmony_ci	}
221962306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %s/%s, (0x%x/0x%x)",
222062306a36Sopenharmony_ci		   "PS state, IPS/LPS, (lps/rpwm)",
222162306a36Sopenharmony_ci		   ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")),
222262306a36Sopenharmony_ci		   ((coex_sta->under_lps ? "LPS ON" : "LPS OFF")),
222362306a36Sopenharmony_ci		   btcoexist->bt_info.lps_val,
222462306a36Sopenharmony_ci		   btcoexist->bt_info.rpwm_val);
222562306a36Sopenharmony_ci	btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD, m);
222662306a36Sopenharmony_ci
222762306a36Sopenharmony_ci	if (!btcoexist->manual_control) {
222862306a36Sopenharmony_ci		/* Sw mechanism*/
222962306a36Sopenharmony_ci		seq_printf(m, "\n %-35s",
223062306a36Sopenharmony_ci			   "============[Sw mechanism]============");
223162306a36Sopenharmony_ci
223262306a36Sopenharmony_ci		seq_printf(m, "\n %-35s = %d", "SM[LowPenaltyRA]",
223362306a36Sopenharmony_ci			   coex_dm->cur_low_penalty_ra);
223462306a36Sopenharmony_ci
223562306a36Sopenharmony_ci		seq_printf(m, "\n %-35s = %s/ %s/ %d ",
223662306a36Sopenharmony_ci			   "DelBA/ BtCtrlAgg/ AggSize",
223762306a36Sopenharmony_ci			   (btcoexist->bt_info.reject_agg_pkt ? "Yes" : "No"),
223862306a36Sopenharmony_ci			   (btcoexist->bt_info.bt_ctrl_buf_size ? "Yes" : "No"),
223962306a36Sopenharmony_ci			   btcoexist->bt_info.agg_buf_size);
224062306a36Sopenharmony_ci		seq_printf(m, "\n %-35s = 0x%x ", "Rate Mask",
224162306a36Sopenharmony_ci			   btcoexist->bt_info.ra_mask);
224262306a36Sopenharmony_ci
224362306a36Sopenharmony_ci		/* Fw mechanism */
224462306a36Sopenharmony_ci		seq_printf(m, "\n %-35s",
224562306a36Sopenharmony_ci			   "============[Fw mechanism]============");
224662306a36Sopenharmony_ci
224762306a36Sopenharmony_ci		ps_tdma_case = coex_dm->cur_ps_tdma;
224862306a36Sopenharmony_ci		seq_printf(m, "\n %-35s = %5ph case-%d (auto:%d)",
224962306a36Sopenharmony_ci			   "PS TDMA",
225062306a36Sopenharmony_ci			   coex_dm->ps_tdma_para,
225162306a36Sopenharmony_ci			   ps_tdma_case,
225262306a36Sopenharmony_ci			   coex_dm->auto_tdma_adjust);
225362306a36Sopenharmony_ci
225462306a36Sopenharmony_ci		seq_printf(m, "\n %-35s = 0x%x ",
225562306a36Sopenharmony_ci			   "Latest error condition(should be 0)",
225662306a36Sopenharmony_ci			   coex_dm->error_condition);
225762306a36Sopenharmony_ci
225862306a36Sopenharmony_ci		seq_printf(m, "\n %-35s = %d ", "IgnWlanAct",
225962306a36Sopenharmony_ci			   coex_dm->cur_ignore_wlan_act);
226062306a36Sopenharmony_ci	}
226162306a36Sopenharmony_ci
226262306a36Sopenharmony_ci	/* Hw setting */
226362306a36Sopenharmony_ci	seq_printf(m, "\n %-35s", "============[Hw setting]============");
226462306a36Sopenharmony_ci
226562306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/0x%x/0x%x/0x%x",
226662306a36Sopenharmony_ci		   "backup ARFR1/ARFR2/RL/AMaxTime",
226762306a36Sopenharmony_ci		   coex_dm->backup_arfr_cnt1,
226862306a36Sopenharmony_ci		   coex_dm->backup_arfr_cnt2,
226962306a36Sopenharmony_ci		   coex_dm->backup_retry_limit,
227062306a36Sopenharmony_ci		   coex_dm->backup_ampdu_max_time);
227162306a36Sopenharmony_ci
227262306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430);
227362306a36Sopenharmony_ci	u4_tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434);
227462306a36Sopenharmony_ci	u2_tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a);
227562306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456);
227662306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/0x%x/0x%x/0x%x",
227762306a36Sopenharmony_ci		   "0x430/0x434/0x42a/0x456",
227862306a36Sopenharmony_ci		   u4_tmp[0], u4_tmp[1], u2_tmp[0], u1_tmp[0]);
227962306a36Sopenharmony_ci
228062306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778);
228162306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc58);
228262306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/ 0x%x", "0x778/ 0xc58[29:25]",
228362306a36Sopenharmony_ci		   u1_tmp[0], (u4_tmp[0] & 0x3e000000) >> 25);
228462306a36Sopenharmony_ci
228562306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x8db);
228662306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x", "0x8db[6:5]",
228762306a36Sopenharmony_ci		   ((u1_tmp[0] & 0x60) >> 5));
228862306a36Sopenharmony_ci
228962306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x975);
229062306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xcb4);
229162306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x",
229262306a36Sopenharmony_ci		   "0xcb4[29:28]/0xcb4[7:0]/0x974[9:8]",
229362306a36Sopenharmony_ci		   (u4_tmp[0] & 0x30000000) >> 28,
229462306a36Sopenharmony_ci		    u4_tmp[0] & 0xff,
229562306a36Sopenharmony_ci		    u1_tmp[0] & 0x3);
229662306a36Sopenharmony_ci
229762306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40);
229862306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c);
229962306a36Sopenharmony_ci	u1_tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x64);
230062306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x",
230162306a36Sopenharmony_ci		   "0x40/0x4c[24:23]/0x64[0]",
230262306a36Sopenharmony_ci		   u1_tmp[0], ((u4_tmp[0] & 0x01800000) >> 23),
230362306a36Sopenharmony_ci		   u1_tmp[1] & 0x1);
230462306a36Sopenharmony_ci
230562306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550);
230662306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522);
230762306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522",
230862306a36Sopenharmony_ci		   u4_tmp[0], u1_tmp[0]);
230962306a36Sopenharmony_ci
231062306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50);
231162306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x", "0xc50(dig)",
231262306a36Sopenharmony_ci		   u4_tmp[0] & 0xff);
231362306a36Sopenharmony_ci
231462306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48);
231562306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5d);
231662306a36Sopenharmony_ci	u1_tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c);
231762306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/ 0x%x", "OFDM-FA/ CCK-FA",
231862306a36Sopenharmony_ci		   u4_tmp[0], (u1_tmp[0] << 8) + u1_tmp[1]);
231962306a36Sopenharmony_ci
232062306a36Sopenharmony_ci	u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0);
232162306a36Sopenharmony_ci	u4_tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4);
232262306a36Sopenharmony_ci	u4_tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8);
232362306a36Sopenharmony_ci	u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc);
232462306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x",
232562306a36Sopenharmony_ci		   "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)",
232662306a36Sopenharmony_ci		   u4_tmp[0], u4_tmp[1], u4_tmp[2], u1_tmp[0]);
232762306a36Sopenharmony_ci
232862306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d/ %d", "0x770(high-pri rx/tx)",
232962306a36Sopenharmony_ci		   coex_sta->high_priority_rx, coex_sta->high_priority_tx);
233062306a36Sopenharmony_ci	seq_printf(m, "\n %-35s = %d/ %d", "0x774(low-pri rx/tx)",
233162306a36Sopenharmony_ci		   coex_sta->low_priority_rx, coex_sta->low_priority_tx);
233262306a36Sopenharmony_ci	if (btcoexist->auto_report_1ant)
233362306a36Sopenharmony_ci		btc8821a1ant_monitor_bt_ctr(btcoexist);
233462306a36Sopenharmony_ci	btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS, m);
233562306a36Sopenharmony_ci}
233662306a36Sopenharmony_ci
233762306a36Sopenharmony_civoid ex_btc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type)
233862306a36Sopenharmony_ci{
233962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
234062306a36Sopenharmony_ci	bool wifi_under_5g = false;
234162306a36Sopenharmony_ci
234262306a36Sopenharmony_ci	if (btcoexist->manual_control || btcoexist->stop_coex_dm)
234362306a36Sopenharmony_ci		return;
234462306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
234562306a36Sopenharmony_ci	if (wifi_under_5g) {
234662306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
234762306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
234862306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
234962306a36Sopenharmony_ci		return;
235062306a36Sopenharmony_ci	}
235162306a36Sopenharmony_ci
235262306a36Sopenharmony_ci	if (BTC_IPS_ENTER == type) {
235362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
235462306a36Sopenharmony_ci			"[BTCoex], IPS ENTER notify\n");
235562306a36Sopenharmony_ci		coex_sta->under_ips = true;
235662306a36Sopenharmony_ci		btc8821a1ant_set_ant_path(btcoexist,
235762306a36Sopenharmony_ci					  BTC_ANT_PATH_BT, false, true);
235862306a36Sopenharmony_ci		/* set PTA control */
235962306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
236062306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist,
236162306a36Sopenharmony_ci						  NORMAL_EXEC, 0);
236262306a36Sopenharmony_ci	} else if (BTC_IPS_LEAVE == type) {
236362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
236462306a36Sopenharmony_ci			"[BTCoex], IPS LEAVE notify\n");
236562306a36Sopenharmony_ci		coex_sta->under_ips = false;
236662306a36Sopenharmony_ci
236762306a36Sopenharmony_ci		btc8821a1ant_init_hw_config(btcoexist, false, false);
236862306a36Sopenharmony_ci		btc8821a1ant_init_coex_dm(btcoexist);
236962306a36Sopenharmony_ci		btc8821a1ant_query_bt_info(btcoexist);
237062306a36Sopenharmony_ci	}
237162306a36Sopenharmony_ci}
237262306a36Sopenharmony_ci
237362306a36Sopenharmony_civoid ex_btc8821a1ant_lps_notify(struct btc_coexist *btcoexist, u8 type)
237462306a36Sopenharmony_ci{
237562306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
237662306a36Sopenharmony_ci
237762306a36Sopenharmony_ci	if (btcoexist->manual_control || btcoexist->stop_coex_dm)
237862306a36Sopenharmony_ci		return;
237962306a36Sopenharmony_ci
238062306a36Sopenharmony_ci	if (BTC_LPS_ENABLE == type) {
238162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
238262306a36Sopenharmony_ci			"[BTCoex], LPS ENABLE notify\n");
238362306a36Sopenharmony_ci		coex_sta->under_lps = true;
238462306a36Sopenharmony_ci	} else if (BTC_LPS_DISABLE == type) {
238562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
238662306a36Sopenharmony_ci			"[BTCoex], LPS DISABLE notify\n");
238762306a36Sopenharmony_ci		coex_sta->under_lps = false;
238862306a36Sopenharmony_ci	}
238962306a36Sopenharmony_ci}
239062306a36Sopenharmony_ci
239162306a36Sopenharmony_civoid ex_btc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type)
239262306a36Sopenharmony_ci{
239362306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
239462306a36Sopenharmony_ci	bool wifi_connected = false, bt_hs_on = false;
239562306a36Sopenharmony_ci	bool bt_ctrl_agg_buf_size = false;
239662306a36Sopenharmony_ci	bool wifi_under_5g = false;
239762306a36Sopenharmony_ci	u32 wifi_link_status = 0;
239862306a36Sopenharmony_ci	u32 num_of_wifi_link = 0;
239962306a36Sopenharmony_ci	u8 agg_buf_size = 5;
240062306a36Sopenharmony_ci
240162306a36Sopenharmony_ci	if (btcoexist->manual_control || btcoexist->stop_coex_dm)
240262306a36Sopenharmony_ci		return;
240362306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
240462306a36Sopenharmony_ci	if (wifi_under_5g) {
240562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
240662306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
240762306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
240862306a36Sopenharmony_ci		return;
240962306a36Sopenharmony_ci	}
241062306a36Sopenharmony_ci
241162306a36Sopenharmony_ci	if (type == BTC_SCAN_START) {
241262306a36Sopenharmony_ci		coex_sta->wifi_is_high_pri_task = true;
241362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
241462306a36Sopenharmony_ci			"[BTCoex], SCAN START notify\n");
241562306a36Sopenharmony_ci
241662306a36Sopenharmony_ci		/* Force antenna setup for no scan result issue */
241762306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8);
241862306a36Sopenharmony_ci	} else {
241962306a36Sopenharmony_ci		coex_sta->wifi_is_high_pri_task = false;
242062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
242162306a36Sopenharmony_ci			"[BTCoex], SCAN FINISH notify\n");
242262306a36Sopenharmony_ci	}
242362306a36Sopenharmony_ci
242462306a36Sopenharmony_ci	if (coex_sta->bt_disabled)
242562306a36Sopenharmony_ci		return;
242662306a36Sopenharmony_ci
242762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist,
242862306a36Sopenharmony_ci		 BTC_GET_BL_HS_OPERATION, &bt_hs_on);
242962306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist,
243062306a36Sopenharmony_ci		 BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
243162306a36Sopenharmony_ci
243262306a36Sopenharmony_ci	btc8821a1ant_query_bt_info(btcoexist);
243362306a36Sopenharmony_ci
243462306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
243562306a36Sopenharmony_ci			   &wifi_link_status);
243662306a36Sopenharmony_ci	num_of_wifi_link = wifi_link_status >> 16;
243762306a36Sopenharmony_ci	if (num_of_wifi_link >= 2) {
243862306a36Sopenharmony_ci		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
243962306a36Sopenharmony_ci		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
244062306a36Sopenharmony_ci					bt_ctrl_agg_buf_size, agg_buf_size);
244162306a36Sopenharmony_ci		btc8821a1ant_action_wifi_multi_port(btcoexist);
244262306a36Sopenharmony_ci		return;
244362306a36Sopenharmony_ci	}
244462306a36Sopenharmony_ci
244562306a36Sopenharmony_ci	if (coex_sta->c2h_bt_inquiry_page) {
244662306a36Sopenharmony_ci		btc8821a1ant_action_bt_inquiry(btcoexist);
244762306a36Sopenharmony_ci		return;
244862306a36Sopenharmony_ci	} else if (bt_hs_on) {
244962306a36Sopenharmony_ci		btc8821a1ant_action_hs(btcoexist);
245062306a36Sopenharmony_ci		return;
245162306a36Sopenharmony_ci	}
245262306a36Sopenharmony_ci
245362306a36Sopenharmony_ci	if (BTC_SCAN_START == type) {
245462306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
245562306a36Sopenharmony_ci			"[BTCoex], SCAN START notify\n");
245662306a36Sopenharmony_ci		if (!wifi_connected) {
245762306a36Sopenharmony_ci			/* non-connected scan */
245862306a36Sopenharmony_ci			btc8821a1ant_act_wifi_not_conn_scan(btcoexist);
245962306a36Sopenharmony_ci		} else {
246062306a36Sopenharmony_ci			/* wifi is connected */
246162306a36Sopenharmony_ci			btc8821a1ant_action_wifi_connected_scan(btcoexist);
246262306a36Sopenharmony_ci		}
246362306a36Sopenharmony_ci	} else if (BTC_SCAN_FINISH == type) {
246462306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
246562306a36Sopenharmony_ci			"[BTCoex], SCAN FINISH notify\n");
246662306a36Sopenharmony_ci		if (!wifi_connected) {
246762306a36Sopenharmony_ci			/* non-connected scan */
246862306a36Sopenharmony_ci			btc8821a1ant_action_wifi_not_connected(btcoexist);
246962306a36Sopenharmony_ci		} else {
247062306a36Sopenharmony_ci			btc8821a1ant_action_wifi_connected(btcoexist);
247162306a36Sopenharmony_ci		}
247262306a36Sopenharmony_ci	}
247362306a36Sopenharmony_ci}
247462306a36Sopenharmony_ci
247562306a36Sopenharmony_civoid ex_btc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type)
247662306a36Sopenharmony_ci{
247762306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
247862306a36Sopenharmony_ci	bool wifi_connected = false, bt_hs_on = false;
247962306a36Sopenharmony_ci	u32 wifi_link_status = 0;
248062306a36Sopenharmony_ci	u32 num_of_wifi_link = 0;
248162306a36Sopenharmony_ci	bool bt_ctrl_agg_buf_size = false;
248262306a36Sopenharmony_ci	bool wifi_under_5g = false;
248362306a36Sopenharmony_ci	u8 agg_buf_size = 5;
248462306a36Sopenharmony_ci
248562306a36Sopenharmony_ci	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
248662306a36Sopenharmony_ci	    coex_sta->bt_disabled)
248762306a36Sopenharmony_ci		return;
248862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
248962306a36Sopenharmony_ci	if (wifi_under_5g) {
249062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
249162306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
249262306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
249362306a36Sopenharmony_ci		return;
249462306a36Sopenharmony_ci	}
249562306a36Sopenharmony_ci
249662306a36Sopenharmony_ci	if (type == BTC_ASSOCIATE_START) {
249762306a36Sopenharmony_ci		coex_sta->wifi_is_high_pri_task = true;
249862306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
249962306a36Sopenharmony_ci			"[BTCoex], CONNECT START notify\n");
250062306a36Sopenharmony_ci		coex_dm->arp_cnt = 0;
250162306a36Sopenharmony_ci	} else {
250262306a36Sopenharmony_ci		coex_sta->wifi_is_high_pri_task = false;
250362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
250462306a36Sopenharmony_ci			"[BTCoex], CONNECT FINISH notify\n");
250562306a36Sopenharmony_ci		coex_dm->arp_cnt = 0;
250662306a36Sopenharmony_ci	}
250762306a36Sopenharmony_ci
250862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
250962306a36Sopenharmony_ci			   &wifi_link_status);
251062306a36Sopenharmony_ci	num_of_wifi_link = wifi_link_status >> 16;
251162306a36Sopenharmony_ci	if (num_of_wifi_link >= 2) {
251262306a36Sopenharmony_ci		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
251362306a36Sopenharmony_ci		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
251462306a36Sopenharmony_ci					bt_ctrl_agg_buf_size, agg_buf_size);
251562306a36Sopenharmony_ci		btc8821a1ant_action_wifi_multi_port(btcoexist);
251662306a36Sopenharmony_ci		return;
251762306a36Sopenharmony_ci	}
251862306a36Sopenharmony_ci
251962306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
252062306a36Sopenharmony_ci	if (coex_sta->c2h_bt_inquiry_page) {
252162306a36Sopenharmony_ci		btc8821a1ant_action_bt_inquiry(btcoexist);
252262306a36Sopenharmony_ci		return;
252362306a36Sopenharmony_ci	} else if (bt_hs_on) {
252462306a36Sopenharmony_ci		btc8821a1ant_action_hs(btcoexist);
252562306a36Sopenharmony_ci		return;
252662306a36Sopenharmony_ci	}
252762306a36Sopenharmony_ci
252862306a36Sopenharmony_ci	if (BTC_ASSOCIATE_START == type) {
252962306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
253062306a36Sopenharmony_ci			"[BTCoex], CONNECT START notify\n");
253162306a36Sopenharmony_ci		btc8821a1ant_act_wifi_not_conn_scan(btcoexist);
253262306a36Sopenharmony_ci	} else if (BTC_ASSOCIATE_FINISH == type) {
253362306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
253462306a36Sopenharmony_ci			"[BTCoex], CONNECT FINISH notify\n");
253562306a36Sopenharmony_ci
253662306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist,
253762306a36Sopenharmony_ci			 BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
253862306a36Sopenharmony_ci		if (!wifi_connected) {
253962306a36Sopenharmony_ci			/* non-connected scan */
254062306a36Sopenharmony_ci			btc8821a1ant_action_wifi_not_connected(btcoexist);
254162306a36Sopenharmony_ci		} else {
254262306a36Sopenharmony_ci			btc8821a1ant_action_wifi_connected(btcoexist);
254362306a36Sopenharmony_ci		}
254462306a36Sopenharmony_ci	}
254562306a36Sopenharmony_ci}
254662306a36Sopenharmony_ci
254762306a36Sopenharmony_civoid ex_btc8821a1ant_media_status_notify(struct btc_coexist *btcoexist,
254862306a36Sopenharmony_ci					 u8 type)
254962306a36Sopenharmony_ci{
255062306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
255162306a36Sopenharmony_ci	u8 h2c_parameter[3] = {0};
255262306a36Sopenharmony_ci	u32 wifi_bw;
255362306a36Sopenharmony_ci	u8 wifi_central_chnl;
255462306a36Sopenharmony_ci	bool wifi_under_5g = false;
255562306a36Sopenharmony_ci
255662306a36Sopenharmony_ci	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
255762306a36Sopenharmony_ci	    coex_sta->bt_disabled)
255862306a36Sopenharmony_ci		return;
255962306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
256062306a36Sopenharmony_ci	if (wifi_under_5g) {
256162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
256262306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
256362306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
256462306a36Sopenharmony_ci		return;
256562306a36Sopenharmony_ci	}
256662306a36Sopenharmony_ci
256762306a36Sopenharmony_ci	if (BTC_MEDIA_CONNECT == type) {
256862306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
256962306a36Sopenharmony_ci			"[BTCoex], MEDIA connect notify\n");
257062306a36Sopenharmony_ci	} else {
257162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
257262306a36Sopenharmony_ci			"[BTCoex], MEDIA disconnect notify\n");
257362306a36Sopenharmony_ci		coex_dm->arp_cnt = 0;
257462306a36Sopenharmony_ci	}
257562306a36Sopenharmony_ci
257662306a36Sopenharmony_ci	/* only 2.4G we need to inform bt the chnl mask */
257762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist,
257862306a36Sopenharmony_ci			   BTC_GET_U1_WIFI_CENTRAL_CHNL,
257962306a36Sopenharmony_ci			   &wifi_central_chnl);
258062306a36Sopenharmony_ci	if ((type == BTC_MEDIA_CONNECT) &&
258162306a36Sopenharmony_ci	    (wifi_central_chnl <= 14)) {
258262306a36Sopenharmony_ci		h2c_parameter[0] = 0x0;
258362306a36Sopenharmony_ci		h2c_parameter[1] = wifi_central_chnl;
258462306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw);
258562306a36Sopenharmony_ci		if (wifi_bw == BTC_WIFI_BW_HT40)
258662306a36Sopenharmony_ci			h2c_parameter[2] = 0x30;
258762306a36Sopenharmony_ci		else
258862306a36Sopenharmony_ci			h2c_parameter[2] = 0x20;
258962306a36Sopenharmony_ci	}
259062306a36Sopenharmony_ci
259162306a36Sopenharmony_ci	coex_dm->wifi_chnl_info[0] = h2c_parameter[0];
259262306a36Sopenharmony_ci	coex_dm->wifi_chnl_info[1] = h2c_parameter[1];
259362306a36Sopenharmony_ci	coex_dm->wifi_chnl_info[2] = h2c_parameter[2];
259462306a36Sopenharmony_ci
259562306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
259662306a36Sopenharmony_ci		"[BTCoex], FW write 0x66 = 0x%x\n",
259762306a36Sopenharmony_ci		h2c_parameter[0] << 16 |
259862306a36Sopenharmony_ci		h2c_parameter[1] << 8 |
259962306a36Sopenharmony_ci		h2c_parameter[2]);
260062306a36Sopenharmony_ci
260162306a36Sopenharmony_ci	btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter);
260262306a36Sopenharmony_ci}
260362306a36Sopenharmony_ci
260462306a36Sopenharmony_civoid ex_btc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist,
260562306a36Sopenharmony_ci					   u8 type)
260662306a36Sopenharmony_ci{
260762306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
260862306a36Sopenharmony_ci	bool bt_hs_on = false;
260962306a36Sopenharmony_ci	bool bt_ctrl_agg_buf_size = false;
261062306a36Sopenharmony_ci	bool wifi_under_5g = false;
261162306a36Sopenharmony_ci	u32 wifi_link_status = 0;
261262306a36Sopenharmony_ci	u32 num_of_wifi_link = 0;
261362306a36Sopenharmony_ci	u8 agg_buf_size = 5;
261462306a36Sopenharmony_ci
261562306a36Sopenharmony_ci	if (btcoexist->manual_control || btcoexist->stop_coex_dm ||
261662306a36Sopenharmony_ci	    coex_sta->bt_disabled)
261762306a36Sopenharmony_ci		return;
261862306a36Sopenharmony_ci
261962306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
262062306a36Sopenharmony_ci	if (wifi_under_5g) {
262162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
262262306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
262362306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
262462306a36Sopenharmony_ci		return;
262562306a36Sopenharmony_ci	}
262662306a36Sopenharmony_ci
262762306a36Sopenharmony_ci	if (type == BTC_PACKET_DHCP || type == BTC_PACKET_EAPOL ||
262862306a36Sopenharmony_ci	    type == BTC_PACKET_ARP) {
262962306a36Sopenharmony_ci		coex_sta->wifi_is_high_pri_task = true;
263062306a36Sopenharmony_ci
263162306a36Sopenharmony_ci		if (type == BTC_PACKET_ARP) {
263262306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
263362306a36Sopenharmony_ci				"[BTCoex], specific Packet ARP notify\n");
263462306a36Sopenharmony_ci		} else {
263562306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
263662306a36Sopenharmony_ci				"[BTCoex], specific Packet DHCP or EAPOL notify\n");
263762306a36Sopenharmony_ci		}
263862306a36Sopenharmony_ci	} else {
263962306a36Sopenharmony_ci		coex_sta->wifi_is_high_pri_task = false;
264062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
264162306a36Sopenharmony_ci			"[BTCoex], specific Packet [Type = %d] notify\n",
264262306a36Sopenharmony_ci			type);
264362306a36Sopenharmony_ci	}
264462306a36Sopenharmony_ci
264562306a36Sopenharmony_ci	coex_sta->special_pkt_period_cnt = 0;
264662306a36Sopenharmony_ci
264762306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS,
264862306a36Sopenharmony_ci			   &wifi_link_status);
264962306a36Sopenharmony_ci	num_of_wifi_link = wifi_link_status >> 16;
265062306a36Sopenharmony_ci	if (num_of_wifi_link >= 2) {
265162306a36Sopenharmony_ci		btc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0);
265262306a36Sopenharmony_ci		btc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false,
265362306a36Sopenharmony_ci					bt_ctrl_agg_buf_size, agg_buf_size);
265462306a36Sopenharmony_ci		btc8821a1ant_action_wifi_multi_port(btcoexist);
265562306a36Sopenharmony_ci		return;
265662306a36Sopenharmony_ci	}
265762306a36Sopenharmony_ci
265862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
265962306a36Sopenharmony_ci	if (coex_sta->c2h_bt_inquiry_page) {
266062306a36Sopenharmony_ci		btc8821a1ant_action_bt_inquiry(btcoexist);
266162306a36Sopenharmony_ci		return;
266262306a36Sopenharmony_ci	} else if (bt_hs_on) {
266362306a36Sopenharmony_ci		btc8821a1ant_action_hs(btcoexist);
266462306a36Sopenharmony_ci		return;
266562306a36Sopenharmony_ci	}
266662306a36Sopenharmony_ci
266762306a36Sopenharmony_ci	if (type == BTC_PACKET_DHCP || type == BTC_PACKET_EAPOL ||
266862306a36Sopenharmony_ci	    type == BTC_PACKET_ARP) {
266962306a36Sopenharmony_ci		if (type == BTC_PACKET_ARP) {
267062306a36Sopenharmony_ci			coex_dm->arp_cnt++;
267162306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
267262306a36Sopenharmony_ci				"[BTCoex], ARP Packet Count = %d\n",
267362306a36Sopenharmony_ci				coex_dm->arp_cnt);
267462306a36Sopenharmony_ci			if (coex_dm->arp_cnt >= 10)
267562306a36Sopenharmony_ci				/* if APR PKT > 10 after connect, do not go to
267662306a36Sopenharmony_ci				 * btc8821a1ant_act_wifi_conn_sp_pkt
267762306a36Sopenharmony_ci				 */
267862306a36Sopenharmony_ci				return;
267962306a36Sopenharmony_ci		}
268062306a36Sopenharmony_ci
268162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
268262306a36Sopenharmony_ci			"[BTCoex], special Packet(%d) notify\n", type);
268362306a36Sopenharmony_ci		btc8821a1ant_act_wifi_conn_sp_pkt(btcoexist);
268462306a36Sopenharmony_ci	}
268562306a36Sopenharmony_ci}
268662306a36Sopenharmony_ci
268762306a36Sopenharmony_civoid ex_btc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist,
268862306a36Sopenharmony_ci				    u8 *tmp_buf, u8 length)
268962306a36Sopenharmony_ci{
269062306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
269162306a36Sopenharmony_ci	u8 i;
269262306a36Sopenharmony_ci	u8 bt_info = 0;
269362306a36Sopenharmony_ci	u8 rsp_source = 0;
269462306a36Sopenharmony_ci	bool wifi_connected = false;
269562306a36Sopenharmony_ci	bool bt_busy = false;
269662306a36Sopenharmony_ci	bool wifi_under_5g = false;
269762306a36Sopenharmony_ci
269862306a36Sopenharmony_ci	coex_sta->c2h_bt_info_req_sent = false;
269962306a36Sopenharmony_ci
270062306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist,
270162306a36Sopenharmony_ci		 BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
270262306a36Sopenharmony_ci
270362306a36Sopenharmony_ci	rsp_source = tmp_buf[0] & 0xf;
270462306a36Sopenharmony_ci	if (rsp_source >= BT_INFO_SRC_8821A_1ANT_MAX)
270562306a36Sopenharmony_ci		rsp_source = BT_INFO_SRC_8821A_1ANT_WIFI_FW;
270662306a36Sopenharmony_ci	coex_sta->bt_info_c2h_cnt[rsp_source]++;
270762306a36Sopenharmony_ci
270862306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
270962306a36Sopenharmony_ci		"[BTCoex], Bt info[%d], length = %d, hex data = [",
271062306a36Sopenharmony_ci		rsp_source, length);
271162306a36Sopenharmony_ci	for (i = 0; i < length; i++) {
271262306a36Sopenharmony_ci		coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i];
271362306a36Sopenharmony_ci		if (i == 1)
271462306a36Sopenharmony_ci			bt_info = tmp_buf[i];
271562306a36Sopenharmony_ci		if (i == length - 1) {
271662306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
271762306a36Sopenharmony_ci				"0x%02x]\n", tmp_buf[i]);
271862306a36Sopenharmony_ci		} else {
271962306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
272062306a36Sopenharmony_ci				"0x%02x, ", tmp_buf[i]);
272162306a36Sopenharmony_ci		}
272262306a36Sopenharmony_ci	}
272362306a36Sopenharmony_ci
272462306a36Sopenharmony_ci	if (BT_INFO_SRC_8821A_1ANT_WIFI_FW != rsp_source) {
272562306a36Sopenharmony_ci		/* [3:0] */
272662306a36Sopenharmony_ci		coex_sta->bt_retry_cnt =
272762306a36Sopenharmony_ci			coex_sta->bt_info_c2h[rsp_source][2] & 0xf;
272862306a36Sopenharmony_ci
272962306a36Sopenharmony_ci		coex_sta->bt_rssi =
273062306a36Sopenharmony_ci			coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10;
273162306a36Sopenharmony_ci
273262306a36Sopenharmony_ci		coex_sta->bt_info_ext = coex_sta->bt_info_c2h[rsp_source][4];
273362306a36Sopenharmony_ci
273462306a36Sopenharmony_ci		coex_sta->bt_tx_rx_mask =
273562306a36Sopenharmony_ci			(coex_sta->bt_info_c2h[rsp_source][2] & 0x40);
273662306a36Sopenharmony_ci		btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TX_RX_MASK,
273762306a36Sopenharmony_ci				   &coex_sta->bt_tx_rx_mask);
273862306a36Sopenharmony_ci		if (!coex_sta->bt_tx_rx_mask) {
273962306a36Sopenharmony_ci			/* BT into is responded by BT FW and BT RF REG 0x3C !=
274062306a36Sopenharmony_ci			 * 0x15 => Need to switch BT TRx Mask
274162306a36Sopenharmony_ci			 */
274262306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
274362306a36Sopenharmony_ci				"[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n");
274462306a36Sopenharmony_ci			btcoexist->btc_set_bt_reg(btcoexist, BTC_BT_REG_RF,
274562306a36Sopenharmony_ci						  0x3c, 0x15);
274662306a36Sopenharmony_ci		}
274762306a36Sopenharmony_ci
274862306a36Sopenharmony_ci		/* Here we need to resend some wifi info to BT
274962306a36Sopenharmony_ci		 * because bt is reset and lost the info
275062306a36Sopenharmony_ci		 */
275162306a36Sopenharmony_ci		if (coex_sta->bt_info_ext & BIT1) {
275262306a36Sopenharmony_ci			rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
275362306a36Sopenharmony_ci				"[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n");
275462306a36Sopenharmony_ci			btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
275562306a36Sopenharmony_ci					   &wifi_connected);
275662306a36Sopenharmony_ci			if (wifi_connected) {
275762306a36Sopenharmony_ci				ex_btc8821a1ant_media_status_notify(btcoexist,
275862306a36Sopenharmony_ci							       BTC_MEDIA_CONNECT);
275962306a36Sopenharmony_ci			} else {
276062306a36Sopenharmony_ci				ex_btc8821a1ant_media_status_notify(btcoexist,
276162306a36Sopenharmony_ci							       BTC_MEDIA_DISCONNECT);
276262306a36Sopenharmony_ci			}
276362306a36Sopenharmony_ci		}
276462306a36Sopenharmony_ci
276562306a36Sopenharmony_ci		if ((coex_sta->bt_info_ext & BIT3) && !wifi_under_5g) {
276662306a36Sopenharmony_ci			if (!btcoexist->manual_control &&
276762306a36Sopenharmony_ci			    !btcoexist->stop_coex_dm) {
276862306a36Sopenharmony_ci				rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
276962306a36Sopenharmony_ci					"[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n");
277062306a36Sopenharmony_ci				btc8821a1ant_ignore_wlan_act(btcoexist,
277162306a36Sopenharmony_ci							     FORCE_EXEC,
277262306a36Sopenharmony_ci							     false);
277362306a36Sopenharmony_ci			}
277462306a36Sopenharmony_ci		}
277562306a36Sopenharmony_ci	}
277662306a36Sopenharmony_ci
277762306a36Sopenharmony_ci	/* check BIT2 first ==> check if bt is under inquiry or page scan */
277862306a36Sopenharmony_ci	if (bt_info & BT_INFO_8821A_1ANT_B_INQ_PAGE)
277962306a36Sopenharmony_ci		coex_sta->c2h_bt_inquiry_page = true;
278062306a36Sopenharmony_ci	else
278162306a36Sopenharmony_ci		coex_sta->c2h_bt_inquiry_page = false;
278262306a36Sopenharmony_ci
278362306a36Sopenharmony_ci	/* set link exist status */
278462306a36Sopenharmony_ci	if (!(bt_info & BT_INFO_8821A_1ANT_B_CONNECTION)) {
278562306a36Sopenharmony_ci		coex_sta->bt_link_exist = false;
278662306a36Sopenharmony_ci		coex_sta->pan_exist = false;
278762306a36Sopenharmony_ci		coex_sta->a2dp_exist = false;
278862306a36Sopenharmony_ci		coex_sta->hid_exist = false;
278962306a36Sopenharmony_ci		coex_sta->sco_exist = false;
279062306a36Sopenharmony_ci	} else {
279162306a36Sopenharmony_ci		/* connection exists */
279262306a36Sopenharmony_ci		coex_sta->bt_link_exist = true;
279362306a36Sopenharmony_ci		if (bt_info & BT_INFO_8821A_1ANT_B_FTP)
279462306a36Sopenharmony_ci			coex_sta->pan_exist = true;
279562306a36Sopenharmony_ci		else
279662306a36Sopenharmony_ci			coex_sta->pan_exist = false;
279762306a36Sopenharmony_ci		if (bt_info & BT_INFO_8821A_1ANT_B_A2DP)
279862306a36Sopenharmony_ci			coex_sta->a2dp_exist = true;
279962306a36Sopenharmony_ci		else
280062306a36Sopenharmony_ci			coex_sta->a2dp_exist = false;
280162306a36Sopenharmony_ci		if (bt_info & BT_INFO_8821A_1ANT_B_HID)
280262306a36Sopenharmony_ci			coex_sta->hid_exist = true;
280362306a36Sopenharmony_ci		else
280462306a36Sopenharmony_ci			coex_sta->hid_exist = false;
280562306a36Sopenharmony_ci		if (bt_info & BT_INFO_8821A_1ANT_B_SCO_ESCO)
280662306a36Sopenharmony_ci			coex_sta->sco_exist = true;
280762306a36Sopenharmony_ci		else
280862306a36Sopenharmony_ci			coex_sta->sco_exist = false;
280962306a36Sopenharmony_ci	}
281062306a36Sopenharmony_ci
281162306a36Sopenharmony_ci	btc8821a1ant_update_bt_link_info(btcoexist);
281262306a36Sopenharmony_ci
281362306a36Sopenharmony_ci	/* mask profile bit for connect-ilde identification
281462306a36Sopenharmony_ci	 * (for CSR case: A2DP idle --> 0x41)
281562306a36Sopenharmony_ci	 */
281662306a36Sopenharmony_ci	bt_info = bt_info & 0x1f;
281762306a36Sopenharmony_ci
281862306a36Sopenharmony_ci	if (!(bt_info & BT_INFO_8821A_1ANT_B_CONNECTION)) {
281962306a36Sopenharmony_ci		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE;
282062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
282162306a36Sopenharmony_ci			"[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n");
282262306a36Sopenharmony_ci	} else if (bt_info == BT_INFO_8821A_1ANT_B_CONNECTION) {
282362306a36Sopenharmony_ci		/* connection exists but no busy */
282462306a36Sopenharmony_ci		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE;
282562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
282662306a36Sopenharmony_ci			"[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n");
282762306a36Sopenharmony_ci	} else if ((bt_info&BT_INFO_8821A_1ANT_B_SCO_ESCO) ||
282862306a36Sopenharmony_ci		(bt_info & BT_INFO_8821A_1ANT_B_SCO_BUSY)) {
282962306a36Sopenharmony_ci		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_SCO_BUSY;
283062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
283162306a36Sopenharmony_ci			"[BTCoex], BtInfoNotify(), BT SCO busy!!!\n");
283262306a36Sopenharmony_ci	} else if (bt_info & BT_INFO_8821A_1ANT_B_ACL_BUSY) {
283362306a36Sopenharmony_ci		if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status)
283462306a36Sopenharmony_ci			coex_dm->auto_tdma_adjust = false;
283562306a36Sopenharmony_ci		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_ACL_BUSY;
283662306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
283762306a36Sopenharmony_ci			"[BTCoex], BtInfoNotify(), BT ACL busy!!!\n");
283862306a36Sopenharmony_ci	} else {
283962306a36Sopenharmony_ci		coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_MAX;
284062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
284162306a36Sopenharmony_ci			"[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n");
284262306a36Sopenharmony_ci	}
284362306a36Sopenharmony_ci
284462306a36Sopenharmony_ci	if ((BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) ||
284562306a36Sopenharmony_ci	    (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) ||
284662306a36Sopenharmony_ci	    (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status))
284762306a36Sopenharmony_ci		bt_busy = true;
284862306a36Sopenharmony_ci	else
284962306a36Sopenharmony_ci		bt_busy = false;
285062306a36Sopenharmony_ci	btcoexist->btc_set(btcoexist,
285162306a36Sopenharmony_ci			   BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
285262306a36Sopenharmony_ci
285362306a36Sopenharmony_ci	btc8821a1ant_run_coexist_mechanism(btcoexist);
285462306a36Sopenharmony_ci}
285562306a36Sopenharmony_ci
285662306a36Sopenharmony_civoid ex_btc8821a1ant_halt_notify(struct btc_coexist *btcoexist)
285762306a36Sopenharmony_ci{
285862306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
285962306a36Sopenharmony_ci	bool wifi_under_5g = false;
286062306a36Sopenharmony_ci
286162306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
286262306a36Sopenharmony_ci		"[BTCoex], Halt notify\n");
286362306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
286462306a36Sopenharmony_ci	if (wifi_under_5g) {
286562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
286662306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
286762306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
286862306a36Sopenharmony_ci		return;
286962306a36Sopenharmony_ci	}
287062306a36Sopenharmony_ci
287162306a36Sopenharmony_ci
287262306a36Sopenharmony_ci	btcoexist->stop_coex_dm = true;
287362306a36Sopenharmony_ci
287462306a36Sopenharmony_ci	btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false, true);
287562306a36Sopenharmony_ci	btc8821a1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true);
287662306a36Sopenharmony_ci
287762306a36Sopenharmony_ci	btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
287862306a36Sopenharmony_ci	btc8821a1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0);
287962306a36Sopenharmony_ci
288062306a36Sopenharmony_ci	ex_btc8821a1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT);
288162306a36Sopenharmony_ci}
288262306a36Sopenharmony_ci
288362306a36Sopenharmony_civoid ex_btc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state)
288462306a36Sopenharmony_ci{
288562306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
288662306a36Sopenharmony_ci	bool wifi_under_5g = false;
288762306a36Sopenharmony_ci
288862306a36Sopenharmony_ci	btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g);
288962306a36Sopenharmony_ci	if (wifi_under_5g) {
289062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
289162306a36Sopenharmony_ci			"[BTCoex], RunCoexistMechanism(), return for 5G <===\n");
289262306a36Sopenharmony_ci		btc8821a1ant_coex_under_5g(btcoexist);
289362306a36Sopenharmony_ci		return;
289462306a36Sopenharmony_ci	}
289562306a36Sopenharmony_ci
289662306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
289762306a36Sopenharmony_ci		"[BTCoex], Pnp notify\n");
289862306a36Sopenharmony_ci
289962306a36Sopenharmony_ci	if (BTC_WIFI_PNP_SLEEP == pnp_state) {
290062306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
290162306a36Sopenharmony_ci			"[BTCoex], Pnp notify to SLEEP\n");
290262306a36Sopenharmony_ci		/* BT should clear UnderIPS/UnderLPS state to avoid mismatch
290362306a36Sopenharmony_ci		 * state after wakeup.
290462306a36Sopenharmony_ci		 */
290562306a36Sopenharmony_ci		coex_sta->under_ips = false;
290662306a36Sopenharmony_ci		coex_sta->under_lps = false;
290762306a36Sopenharmony_ci		btcoexist->stop_coex_dm = true;
290862306a36Sopenharmony_ci		btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
290962306a36Sopenharmony_ci					      0x0, 0x0);
291062306a36Sopenharmony_ci		btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0);
291162306a36Sopenharmony_ci		btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
291262306a36Sopenharmony_ci		btc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false,
291362306a36Sopenharmony_ci					  true);
291462306a36Sopenharmony_ci	} else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) {
291562306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
291662306a36Sopenharmony_ci			"[BTCoex], Pnp notify to WAKE UP\n");
291762306a36Sopenharmony_ci		btcoexist->stop_coex_dm = false;
291862306a36Sopenharmony_ci		btc8821a1ant_init_hw_config(btcoexist, false, false);
291962306a36Sopenharmony_ci		btc8821a1ant_init_coex_dm(btcoexist);
292062306a36Sopenharmony_ci		btc8821a1ant_query_bt_info(btcoexist);
292162306a36Sopenharmony_ci	}
292262306a36Sopenharmony_ci}
292362306a36Sopenharmony_ci
292462306a36Sopenharmony_civoid ex_btc8821a1ant_periodical(struct btc_coexist *btcoexist)
292562306a36Sopenharmony_ci{
292662306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = btcoexist->adapter;
292762306a36Sopenharmony_ci	static u8 dis_ver_info_cnt;
292862306a36Sopenharmony_ci	u32 fw_ver = 0, bt_patch_ver = 0;
292962306a36Sopenharmony_ci	struct btc_board_info *board_info = &btcoexist->board_info;
293062306a36Sopenharmony_ci	struct btc_stack_info *stack_info = &btcoexist->stack_info;
293162306a36Sopenharmony_ci
293262306a36Sopenharmony_ci	rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
293362306a36Sopenharmony_ci		"[BTCoex], ==========================Periodical===========================\n");
293462306a36Sopenharmony_ci
293562306a36Sopenharmony_ci	if (dis_ver_info_cnt <= 5) {
293662306a36Sopenharmony_ci		dis_ver_info_cnt += 1;
293762306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
293862306a36Sopenharmony_ci			"[BTCoex], ****************************************************************\n");
293962306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
294062306a36Sopenharmony_ci			"[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n",
294162306a36Sopenharmony_ci			board_info->pg_ant_num,
294262306a36Sopenharmony_ci			board_info->btdm_ant_num,
294362306a36Sopenharmony_ci			board_info->btdm_ant_pos);
294462306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
294562306a36Sopenharmony_ci			"[BTCoex], BT stack/ hci ext ver = %s / %d\n",
294662306a36Sopenharmony_ci			stack_info->profile_notified ? "Yes" : "No",
294762306a36Sopenharmony_ci			stack_info->hci_version);
294862306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER,
294962306a36Sopenharmony_ci				   &bt_patch_ver);
295062306a36Sopenharmony_ci		btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver);
295162306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
295262306a36Sopenharmony_ci			"[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n",
295362306a36Sopenharmony_ci			glcoex_ver_date_8821a_1ant,
295462306a36Sopenharmony_ci			glcoex_ver_8821a_1ant,
295562306a36Sopenharmony_ci			fw_ver, bt_patch_ver,
295662306a36Sopenharmony_ci			bt_patch_ver);
295762306a36Sopenharmony_ci		rtl_dbg(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
295862306a36Sopenharmony_ci			"[BTCoex], ****************************************************************\n");
295962306a36Sopenharmony_ci	}
296062306a36Sopenharmony_ci
296162306a36Sopenharmony_ci	if (!btcoexist->auto_report_1ant) {
296262306a36Sopenharmony_ci		btc8821a1ant_query_bt_info(btcoexist);
296362306a36Sopenharmony_ci		btc8821a1ant_monitor_bt_ctr(btcoexist);
296462306a36Sopenharmony_ci	} else {
296562306a36Sopenharmony_ci		coex_sta->special_pkt_period_cnt++;
296662306a36Sopenharmony_ci	}
296762306a36Sopenharmony_ci}
2968